From a5b36e8961f0f790db673987bbd93ecea7f755b0 Mon Sep 17 00:00:00 2001 From: Jacob Appelbaum Date: Sat, 17 Aug 2024 15:01:22 +0200 Subject: [PATCH 1/2] Fix monocypher.argon2i_32 While using pymonocypher for a cryptographic protocol, we encountered an AttributeError: File "c_monocypher.pyx", line 328, in monocypher.argon2i_32 AttributeError: 'dict' object has no attribute 'nb_block' Using the Python console to reproduce the error with monocypher 4.0.2.3: >>> import monocypher >>> monocypher.argon2i_32(nb_blocks=100000, nb_iterations=3, password=password, salt=salt, key=None, ad=None) This will result in the following exception: Traceback (most recent call last): File "", line 1, in File "c_monocypher.pyx", line 328, in monocypher.argon2i_32 AttributeError: 'dict' object has no attribute 'nb_block' It appears that the c_monocypher.pyx is defined in the singular 'nb_block' for the binding when it should be 'nb_blocks'. After changing that value to 'nb_blocks', it works as expected: >>> password = b'123456' >>> salt = b'00125235' >>> monocypher.argon2i_32(nb_blocks=100000, nb_iterations=3, password=password, salt=salt, key=None, ad=None) This produces a bytes object as expected: b'\x8cj\x88\xc7\xda}\x7f\x18Z\x01\xbf\xbb\xd5\x01\x13\xd9<\xb4\xb9\'c\x8f\x98\xee\x96\x04E-\xfc"\xd9o' --- c_monocypher.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c_monocypher.pyx b/c_monocypher.pyx index 01ecafe..d1cb562 100644 --- a/c_monocypher.pyx +++ b/c_monocypher.pyx @@ -325,7 +325,7 @@ def argon2i_32(nb_blocks, nb_iterations, password, salt, key=None, ad=None) -> b cdef crypto_argon2_config config; config.algorithm = 1 - config.nb_block = nb_blocks + config.nb_blocks = nb_blocks config.nb_passes = nb_iterations config.nb_lanes = 1 From 9af645a9d53510813170e53bddbceb9814258d5b Mon Sep 17 00:00:00 2001 From: Jacob Appelbaum Date: Sat, 17 Aug 2024 15:26:23 +0200 Subject: [PATCH 2/2] Increment VERSION and __version__ --- c_monocypher.pyx | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/c_monocypher.pyx b/c_monocypher.pyx index d1cb562..ce579c9 100644 --- a/c_monocypher.pyx +++ b/c_monocypher.pyx @@ -12,7 +12,7 @@ import warnings # also edit setup.py -__version__ = '4.0.2.3' # also change setup.py +__version__ = '4.0.2.4' # also change setup.py __title__ = 'pymonocypher' __description__ = 'Python ctypes bindings to the Monocypher library' __url__ = 'https://github.com/jetperch/pymonocypher' diff --git a/setup.py b/setup.py index e9bf884..175a5bf 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ import os MYPATH = os.path.abspath(os.path.dirname(__file__)) -VERSION = '4.0.2.3' # also change c_monocypher.pyx +VERSION = '4.0.2.4' # also change c_monocypher.pyx try: