Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #844 +/- ##
===========================================
+ Coverage 99.85% 99.86% +0.01%
===========================================
Files 95 102 +7
Lines 27784 32702 +4918
Branches 2908 3139 +231
===========================================
+ Hits 27743 32658 +4915
- Misses 38 40 +2
- Partials 3 4 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hm, looks like the style of type annotations I copied relies on being evaluated lazily, i.e. requires at least python 3.14, where that lazy evaluation was introduced. Hence the failing CI checks on python < 3.14. This also means that the same style inside |
i.e. drop the digest size argument when the nettle library version 4 is loaded due to version 4 API changes fixes ronf#842
No, this is wrong. Apparently, with python < 3.14 these annotations are already lazily evaluated/ignored in a context like in Updated the pull-request with a fix for older python versions. |
|
I've tried asking the codecov/patch check to run again, but it continues to show the 78% number. I'm rerunning the other tests to see if that helps or not. |
|
Here are some additional notes from Claude:
I think I'll give Claude a chance to code this (addressing these issues) and see what it comes up with. I'll let you know how it goes. I'm not really sure longer term how to test both Nettle 3 and 4. I guess I could intentionally leave Nettle 3 libraries for one of my targets (Linux, macOS, Windows) and update the others, so the combined version ends up exercising both code paths. It'd be nice to find a way to test both Nettle 3 and 4 on all of these platforms, though, and perhaps even a version which doesn't report its major number (which we'd treat the same as 3 in terms of the API). |
|
Here's the Claude version: Author: Georg Sauthoff <mail@gms.tf>
Date: Sat Nov 14 17:41:44 2026 -0800
Support Nettle 4 in UMAC wrapper
Nettle 4 removed the length argument from digest functions, causing
the UMAC wrapper to pass the digest length as the output buffer
pointer and crash. Check nettle_version_major() when loading the
library, pass the length argument only on Nettle 3, and disable UMAC
support on unrecognized major versions. Libraries too old to export
the version function are treated as Nettle 3.
Fixes #842
Co-Authored-By: Ron Frederick <ronf@timeheart.net>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/asyncssh/crypto/umac.py b/asyncssh/crypto/umac.py
index 981be41..8f5b270 100644
--- a/asyncssh/crypto/umac.py
+++ b/asyncssh/crypto/umac.py
@@ -31,7 +31,7 @@ if TYPE_CHECKING:
_SetKey = Callable[[_ByteArray, bytes], None]
_SetNonce = Callable[[_ByteArray, ctypes.c_size_t, bytes], None]
_Update = Callable[[_ByteArray, ctypes.c_size_t, bytes], None]
- _Digest = Callable[[_ByteArray, ctypes.c_size_t, _ByteArray], None]
+ _Digest = Callable[..., None]
_New = Callable[[bytes, Optional[bytes], Optional[bytes]], object]
@@ -55,6 +55,9 @@ def _build_umac(size: int) -> '_New':
_update: _Update = getattr(_nettle, _prefix + 'update')
_digest: _Digest = getattr(_nettle, _prefix + 'digest')
+ # Nettle 4 dropped the length argument from digest functions
+ _digest_len = (ctypes.c_size_t(size // 8),) if _nettle_major == 3 else ()
+
class _UMAC:
"""Wrapper for UMAC cryptographic hash
@@ -113,7 +116,7 @@ def _build_umac(size: int) -> '_New':
"""
result = ctypes.create_string_buffer(self.digest_size)
- _digest(self._ctx, ctypes.c_size_t(self.digest_size), result)
+ _digest(self._ctx, *_digest_len, result)
return result.raw
def hexdigest(self) -> str:
@@ -136,4 +139,11 @@ else: # pragma: no cover
if _nettle_lib: # pragma: no branch
_nettle = ctypes.cdll.LoadLibrary(_nettle_lib)
- umac32, umac64, umac96, umac128 = map(_build_umac, (32, 64, 96, 128))
+ try:
+ _nettle_major: int = _nettle.nettle_version_major()
+ except AttributeError: # pragma: no cover
+ # Versions of Nettle before 3.1 don't export a version function
+ _nettle_major = 3
+
+ if _nettle_major in (3, 4): # pragma: no branch
+ umac32, umac64, umac96, umac128 = map(_build_umac, (32, 64, 96, 128))
|
|
Nettle 3.1.1 was released over 10 years ago. Asyncssh requires Python 3.10 or later which was released 5 years ago and is end of support since this October. I don't like the chatbot's regurgitation at all, because it is:
|
i.e. drop the digest size argument when the nettle library version 4 is loaded due to version 4 API changes
fixes #842