-
Notifications
You must be signed in to change notification settings - Fork 13
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
Need to dynamically configure counter limits in CTR stream cipher #4
Comments
If I understood your problem correctly, then it should be possible by implementing a custom CTR flavor. Note that the type Ctr128BE<B> = Ctr<B, Ctr128BE>; Your flavor would be generic over counter width represented using |
Maybe I am missing something, but I tried that with no success. The situation is that we need a For example, 128 bits of nonce .. but counter-length parameter (set by caller) is 4, thus counter has 124 fixed bits from nonce and 4 bits that increment and wrap, repeating the counter values every 16 blocks. Of course, security-wise nobody would do that, but the WebCrypto API allows any value of |
Ah, so you need to set the counter width at runtime. Yeah, the current version of the API-wise I think it can be done by not implementing the initialization traits and instead adding inherent methods which would accept width in addition to key/IV or block cipher/IV. |
@newpavlov I had a go at implementing variable length, based on ciphers-v0.3. In essence, Strategies I investigated:
So, option to either fork/copy the Ctr implementation to webcrypto-ctr, or alter the internals of What do you suggest? Any trait-trickery you can think of to help here? |
I think the best option will be to implement it in a separate crate. Making runtime-variable nonce part of the We are currently in the process of block mode crates migration to the RustCrypto/block-modes repository and |
Closing in favor of #1. We probably can add implementation of this mode to |
Currently working on AES-CTR support in Deno .. and W3C WebCrypto requires that the counter increments be limited in "N" RHS bits, such that the LHS is constant during stream operations. This is based on SP800-38 Annex B1.
Tried to hack something based on modified
Ctr128BE
trait but have been unable to configure the increment due to, for example, visibility ofcounter
property ofCtr<..>
or difficulties in passing in as part ofNonce
due to inicialization route viaNewCipher
/FromBlockCipher
.Will happily code this and open a PR, but would like some advice about how to best fit this into current structure and future directions.
The text was updated successfully, but these errors were encountered: