Skip to content

Conversation

@causalnet
Copy link
Contributor

This fixes #9 and has the incrementNonce() code that more closely matches KeepassXC's, properly handling multiple byte increments.

@causalnet
Copy link
Contributor Author

This matches what libsodium's utils.c does more accurately.

The original C code:

for (; i < nlen; i++) {
        c += (uint_fast16_t) n[i];
        n[i] = (unsigned char) c;
        c >>= 8;
    }

goes through each byte, incrementing if there is overflow in the previous byte. The Java code in this PR should do the same thing.

@purejava purejava merged commit 74da978 into purejava:develop Jan 17, 2023
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.

Nonce increment incorrect when multiple bytes need changing

2 participants