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

AES-SIV-CMAC nonce sizes #496

Open
davidv1992 opened this issue Dec 23, 2022 · 5 comments
Open

AES-SIV-CMAC nonce sizes #496

davidv1992 opened this issue Dec 23, 2022 · 5 comments

Comments

@davidv1992
Copy link

RFC 5297 specifies AES-CIV-CMAC as being able to accept any nonce size >= 1. However, the implementation here only supports 16 byte nonces. Would it be possible to support the other nonce sizes? I guess this would require a more general change to move closer to the aead interface specified in rfc 5116?

I am specifically asking for this as it would be required for me to support those different nonce sizes if I want to build a RFC-8915 compliant NTS server.

@tarcieri
Copy link
Member

It could potentially use a similar technique to the aes-gcm crate, which is generic around nonce sizes:

https://docs.rs/aes-gcm/latest/aes_gcm/struct.AesGcm.html

@tarcieri
Copy link
Member

Re: RFC5116, it was the original design impetus for the aead crate

@davidv1992
Copy link
Author

Hmm, that design is distinctly non-optimal for my usecase, as nonce length is really only known at runtime and is technically allowed to vary between 1 and infinity, and as such this would require a lot of instantiations of the types.

@tarcieri
Copy link
Member

If you really need a nonce whose length varies at runtime, I’d suggest building on top of the core Siv type:

https://docs.rs/aes-siv/latest/aes_siv/siv/struct.Siv.html

See the SivAead type for how the AEAD construction is built on top of it.

You can open an issue on the upstream traits repo to discuss traits for runtime-variable nonce lengths, though it’s obscure enough of a usecase and effectively an antipattern to the point that I’m not sure the additional complexity is worth it.

@tarcieri
Copy link
Member

Whoops, should probably leave this open to track potential support for type-level nonce size control

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

3 participants
@tarcieri @davidv1992 and others