We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
sodium_pad in libsodium is specified as:
int sodium_pad(size_t *padded_buflen_p, unsigned char *buf, size_t unpadded_buflen, size_t blocksize, size_t max_buflen)
While in lazysodium it's
public native int sodium_pad(Pointer paddedBuffLen, char[] buf, int unpaddedBufLen, int blockSize, int maxBufLen);
The problem is caused by mismatch of char size in java and C, in C it's one byte, but in Java it's 2.
Modifying padding tests a bit demonstrates the problem
@Test public void pad() { IntByReference ref = new IntByReference(0); char[] b = {'a','b','c','d'}; lazySodium.sodiumPad(ref, b, 4, 4, 10); TestCase.assertEquals(8, ref.getValue()); }
Results in
b 0 = 'a' 97 1 = 'b' 98 2 = '\u0080' 128 3 = '\u0000' 0
The text was updated successfully, but these errors were encountered:
#85 #108 Update padding methods
42951ad
#85 #108 Add padding test comments
82ed606
I've updated PaddingTest.java with new code showing how to correctly create a pointer to some memory which is then padded.
PaddingTest.java
Sorry, something went wrong.
No branches or pull requests
sodium_pad in libsodium is specified as:
While in lazysodium it's
The problem is caused by mismatch of char size in java and C, in C it's one byte, but in Java it's 2.
Modifying padding tests a bit demonstrates the problem
Results in
The text was updated successfully, but these errors were encountered: