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-kw: add fixed size methods #45

Merged
merged 1 commit into from
Nov 11, 2024
Merged

aes-kw: add fixed size methods #45

merged 1 commit into from
Nov 11, 2024

Conversation

newpavlov
Copy link
Member

Also rename wrap/unwrap methods to wrap_key/unwrap_key for consistency with belt-kwp and to better indicate the intended use.

@@ -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;
Copy link
Member Author

@newpavlov newpavlov Nov 11, 2024

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...

Copy link
Member Author

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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, typenum is fun. :)

Copy link
Member

@baloo baloo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

aes-kw/src/kwp.rs Show resolved Hide resolved
@newpavlov newpavlov merged commit bb44028 into master Nov 11, 2024
9 checks passed
@newpavlov newpavlov deleted the aes-kw/fixed branch November 11, 2024 17:56
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

Successfully merging this pull request may close these issues.

2 participants