Skip to content

aead: add NewAead::new_varkey method#191

Merged
tarcieri merged 1 commit intomasterfrom
aead/new-varkey
Jun 11, 2020
Merged

aead: add NewAead::new_varkey method#191
tarcieri merged 1 commit intomasterfrom
aead/new-varkey

Conversation

@tarcieri
Copy link
Member

Adds a method which accepts a slice for a key, similar to the methods in the block-cipher and stream-cipher crates.

@tarcieri
Copy link
Member Author

@newpavlov one thing I noticed was the method names are inconsistent among the crates.

  • block-cipher uses new_varkey
  • stream-cipher uses new_var

I'd suggest either standardizing on new_varkey or, to bikeshed, something like from_slice (as a breaking change across all 3 crates, for some future hypothetical release)

@burdges
Copy link

burdges commented Jun 11, 2020

I'd suggest fn new_varkey(key: impl Borrow<[u8]>) -> Result<Self, Error> so that fixed size array work.

@newpavlov
Copy link
Member

Stream cipher initialization function takes both key and nonce, while block cipher takes only key. For example, BlockMode also uses new_var. I guess we can rename new_varkey to new_var in the next breaking release and maybe add new_var as an alias until then.

@tarcieri
Copy link
Member Author

@burdges we've used impl AsRef<[u8]> elsewhere. I think it's more exhaustive in terms of its coercions, which could be a good thing or a bad thing...

Stream cipher initialization function takes both key and nonce, while block cipher takes only key.

Ok, makes sense

Adds a method which accepts a slice for a key, similar to the methods in
the `block-cipher` and `stream-cipher` crates.
@tarcieri
Copy link
Member Author

For consistency with the other new_var / new_varkey APIs I'd suggest just taking a slice for now, and revisiting taking impl Borrow<[u8]> or impl AsRef<[u8]> across all three crates the next time we make a breaking change

@tarcieri tarcieri requested a review from newpavlov June 11, 2020 21:23
@tarcieri tarcieri merged commit 0b404c8 into master Jun 11, 2020
@tarcieri tarcieri deleted the aead/new-varkey branch June 11, 2020 21:55
@tarcieri
Copy link
Member Author

tarcieri commented Jun 12, 2020

dns2utf8 pushed a commit to dns2utf8/traits that referenced this pull request Jan 24, 2023
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.

3 participants