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

Don't return the NUL-terminator in hash_encoded #5

Merged
merged 1 commit into from
Apr 14, 2020

Conversation

dra27
Copy link
Contributor

@dra27 dra27 commented Apr 14, 2020

On further use, I noticed that examples/examples.ml was printing the output of hash_encoded as though it was binary, which it's not! So I changed the example - then I noticed that hash_encoded is accidentally returning the NUL terminator from the C string.

I've double-checked the C code in the reference implementation - argon2_encodedlen definitely requires the space for the terminator to be included and it definitely writes the final NUL. hashlen definitely doesn't include a NUL terminator (and one is never written).

I've fixed this by subtracting 1 when the string is extracted, so that Argon2.encoded_len still returns the same value as the underlying C function (so it will necessarily be 1 more than the length of the OCaml string actually returned).

@Khady
Copy link
Owner

Khady commented Apr 14, 2020

thanks!

@Khady Khady merged commit 9ed1408 into Khady:master Apr 14, 2020
@dra27 dra27 deleted the fix-encoded branch April 14, 2020 13:42
Khady added a commit to Khady/opam-repository that referenced this pull request Apr 15, 2020
CHANGES:

- fix wrong length of hash encoded (Khady/ocaml-argon2#5)
samoht pushed a commit to ocaml/opam-repository that referenced this pull request Apr 2, 2024
CHANGES:

- fix wrong length of hash encoded (Khady/ocaml-argon2#5)
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.

None yet

2 participants