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

XChaCha20 - nonce size restrictions #92

Closed
antailyaqwer opened this issue Sep 14, 2023 · 4 comments
Closed

XChaCha20 - nonce size restrictions #92

antailyaqwer opened this issue Sep 14, 2023 · 4 comments

Comments

@antailyaqwer
Copy link

Hi there!
Thanks for your great library.

I have a question: why nonce size in XChaCha20 is strictly 32 in bytes, or NONCE_SIZE == 24.
In my case i need NONCE_SIZE to be eqal to 12.

Encryption with 12 value works fine, but decryption in method hChaCha20 fails with crash.

@antailyaqwer
Copy link
Author

upd: encryption doesn't work too, unfortunately.

@robxyy
Copy link
Contributor

robxyy commented Sep 14, 2023

@antailyaqwer I referenced Tink's implementation of XChaCha20. Currently it only supports NONCE_SIZE = 24 and KEY_SIZE = 32, if you want to support NONCE_SIZE = 12, PR welcome. 🍺
KEY_SIZE: InsecureNonceChaCha20Base.java#L43C36-L43C53
NONCE_SIZE: InsecureNonceXChaCha20.java#L34C27-L34C46

@antailyaqwer
Copy link
Author

If anyones wondering: I found java-only realization with custom nonce size. Converted with android studio utility and copied required files (5 files copied) - works fine.

@robxyy
Copy link
Contributor

robxyy commented Sep 19, 2023

@antailyaqwer Reference here, bcgit/bc-java#957

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

2 participants