-
Notifications
You must be signed in to change notification settings - Fork 170
Implement belt dwp #604
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
Implement belt dwp #604
Conversation
Hey, @newpavlov! |
This could use a rebase. |
Looks like benches is broken in master |
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.
Sorry for the late review!
belt-dwp/tests/belt.rs
Outdated
use hex_literal::hex; | ||
|
||
type BeltDwp = belt_dwp::BeltDwp<BeltBlock>; |
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.
Same here, just use BeltDwp
with the default type parameter.
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.
Compiling belt-dwp v0.1.0 (/Users/makavity/dev/crypto/AEADs/belt-dwp)
error[E0283]: type annotations needed for `BeltDwp<_>`
--> belt-dwp/tests/belt.rs:39:13
|
39 | let belt_dwp = BeltDwp::new_from_slice(&vec.k).unwrap();
| ^^^^^^^^ ------- type must be known at this point
|
= note: cannot satisfy `_: cipher::block::BlockCipherEncrypt`
= help: the following types implement trait `cipher::block::BlockCipherEncrypt`:
&Alg
BeltBlock
cipher::tweak::zero::ZeroTweak<C>
note: required by a bound in `BeltDwp`
--> /Users/makavity/dev/crypto/AEADs/belt-dwp/src/lib.rs:106:8
|
104 | pub struct BeltDwp<C = BeltBlock>
| ------- required by a bound in this struct
105 | where
106 | C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
| ^^^^^^^^^^^^^^^^^^ required by this bound in `BeltDwp`
help: consider giving `belt_dwp` an explicit type, where the type for type parameter `C` is specified
|
39 | let belt_dwp: BeltDwp<C> = BeltDwp::new_from_slice(&vec.k).unwrap();
| ++++++++++++
For more information about this error, try `rustc --explain E0283`.
error: could not compile `belt-dwp` (test "belt") due to 1 previous error
Should I use
let dwp: BeltDwp = BeltDwp::new_from_slice(&vec.k).unwrap();
?
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.
Huh... weird. I guess one way to work around this issue is to write this:
pub struct Dwp<C> {
cipher: C,
}
pub type BeltDwp = Dwp<BeltBlock>;
Though I am interested in learning why the default type parameter does not work here as expected.
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.
The same problem is also in belt-ctr crate. Should I commit same fix for that?
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.
Yeah, it's probably worth to define a generic Ctr
type and BeltCtr = Ctr<BeltBlock>
type alias on top of it.
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.
Okay, thank you.
Fixed generic default by type alias, as you suggest.
Thank you! |
Implemented Belt-DWP, republic of Belarus AEAD algorithm.