Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix monocypher.argon2i_32 #10

Merged
merged 2 commits into from
Aug 17, 2024
Merged

Conversation

ioerror
Copy link
Contributor

@ioerror ioerror commented Aug 17, 2024

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'

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 "<stdin>", line 1, in <module>
    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'
@mliberty1 mliberty1 merged commit 0ada0c8 into jetperch:main Aug 17, 2024
13 checks passed
@mliberty1
Copy link
Member

Thank you for the pull request. It looks like no one has used argon through pymonocypher yet!

I added a simple unit test and released 4.0.2.4. You should be able to upgrade using:

pip install -U pymonocypher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants