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

memcpy produces differing code between GUI and CLI program if using __int128 extension #9

Closed
kennbr34 opened this issue Dec 18, 2022 · 1 comment

Comments

@kennbr34
Copy link
Owner

yaxa/crypt.c

Line 409 in cc5a22e

memcpy(&keyInt,keyBytes,sizeof(keyInt));

This call to memcpy causes keyInt to be reduced and produces an incorrect decryption as described in #8.

Replaced the call to memcpy with a loop

cryptint_t *keyIntPtr = &keyInt; for (uint8_t i = 0; i < sizeof(keyInt); i++) keyIntPtr[i] = keyBytes[i];

This solves the specific issue in #8 but since there are multiple calls to memcpy within the code it would be good to know specifically what is happening. Tested with memmove to make sure it wasn't overlapping memory, and that wasn't the issue ither.

@kennbr34
Copy link
Owner Author

cryptint_t *keyIntPtr = &keyInt; for (uint8_t i = 0; i < sizeof(keyInt); i++) keyIntPtr[i] = keyBytes[i];

Is a mistake. keyIntPtr should be of uint8_t. The previous code only works because it's overwriting the keyInt with 0s each time it's called.

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

No branches or pull requests

1 participant