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

Explicit or implicit support for [email protected] #1

Open
blaxill opened this issue Jun 12, 2016 · 1 comment
Open

Explicit or implicit support for [email protected] #1

blaxill opened this issue Jun 12, 2016 · 1 comment

Comments

@blaxill
Copy link

blaxill commented Jun 12, 2016

Currently this crate only exposes the top level aead functions. Unfortunately this is not enough when attempting to use this crate for [email protected]. In particular, being able to use a raw instance of ChaCha20 (to encrypt packet lengths without authentication), and being able to explicitly set the ChaCha20 block counter used in the aead, is needed. This could either be exposed by making the Chacha20 module public and adding flexiblility to the aead routine, or by providing explicit [email protected] routines. In the current state, supporting [email protected] requires either an unnecessary fork of this module or a complete reimplementation, both of which would be a shame.

@cesarb
Copy link
Owner

cesarb commented Jun 12, 2016

I took a quick look at the link you provided, and it seems that a little more is needed. In particular, it uses a 64-bit counter and a 64-bit IV, and seems to have no padding between the AAD and the ciphertext. The AEAD part of this crate currently exploits the fact that, in the RFC 7539 variant, everything is a multiple of the Poly1305 block size.

Due to the potential for misuse, I would prefer to avoid exporting the raw ChaCha20 and Poly1305 primitives. But I believe it does make sense to implement the openssh variant in this crate, as an "openssh" module, with whichever API better fits the use case.

I won't have time to look at it for a while, but in case you want to do the work yourself, you'll just need to add the "with_long_counter" (variation of "with_counter") and "next_with_long_counter" (variation of "next") functions to the ChaCha20 impl, to be able to use a 64-bit counter and a 64-bit IV, and the rest (struct for the K_1 instance, buffering for the stream cipher, key derivation, AEAD encrypt/decrypt) can be done in the "openssh" module. You'll also need to find test vectors somewhere, to validate the implementation.

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