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

Add 32 byte default rekey() to CipherState #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robertbraeutigam
Copy link

Add the REKEY() function as specified by the Noise specification for 32 byte keys.

Patch also contains a related fix for nonce overflow check, which was -1, but the overflow actually happens at Long.MIN_VALUE which is Long.MAX_VALUE+1. -1 is actually 2^64-1, which is used for the above rekey() function.

@rweather
Copy link
Owner

I don't think the nonce overflow check is correct. Unless the specification has changed since I last looked at it, I believe that the Noise nonce value is intended to be an unsigned 64-bit value where all nonces except 0xFFFFFFFFFFFFFFFF (i.e. -1L) are valid. Unfortunately Java doesn't have unsigned types so it is necessary to fake it with a signed long type.

@robertbraeutigam
Copy link
Author

You're right. I misunderstood the overflow check to mean the actual overflow from positive to negative. But, you're right, those would be still valid values from the specification's point of view.

So -1L is disallowed, except for rekey(). I'll think I'll just copy-paste rekey() to all 3 implementations then, so I can leave that check in, but not use it for rekey(). Or do you have a better design idea maybe?

@robertbraeutigam
Copy link
Author

I moved the 3 nonce checks to a common decorator type class, so the rekey() now works, but the check is still in place for decrypt and encrypt calls from the "outside".

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