-
Notifications
You must be signed in to change notification settings - Fork 7
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-kw: add fixed size methods #45
Conversation
@@ -19,6 +25,13 @@ const KWP_MAX_LEN: usize = u32::MAX as usize; | |||
/// ``` | |||
const KWP_IV_PREFIX: [u8; IV_LEN / 2] = [0xA6, 0x59, 0x59, 0xA6]; | |||
|
|||
/// [`IvLen`] (`U8`) minus one | |||
type IvLenM1 = U7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some very weird reason compiler does not like when we use Sub1<IvLen>
instead of this type alias despite the fact that it evaluates to the exactly same type (UInt<UInt<UInt<UTerm, B1>, B1>, B1>
). Compiler even mentions this type in the compilation error, but alas...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quot<Sum<N, IvLenM1>, IvLen>: Add<B1> + Mul<IvLen>, | ||
Add1<Quot<Sum<N, IvLenM1>, IvLen>>: Mul<IvLen>, | ||
Prod<Add1<Quot<Sum<N, IvLenM1>, IvLen>>, IvLen>: ArraySize, | ||
Prod<Quot<Sum<N, IvLenM1>, IvLen>, IvLen>: ArraySize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, typenum
is fun. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Also rename
wrap
/unwrap
methods towrap_key
/unwrap_key
for consistency withbelt-kwp
and to better indicate the intended use.