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

Support 192 and 256-bit keys for AES #1316

Merged
merged 8 commits into from
Apr 16, 2024
Merged

Conversation

playfulFence
Copy link
Contributor

@playfulFence playfulFence commented Mar 20, 2024

closes #1234

examples/src/bin/aes.rs Outdated Show resolved Hide resolved
@jessebraham
Copy link
Member

Not a huge fan of just panicking on invalid key length, as there's no way for an application to recover from that. I guess without const_generic_exprs there's not much else we can do other than make the method fallible (which might be preferable?).

@bjoernQ what do you think?

@bjoernQ
Copy link
Contributor

bjoernQ commented Mar 21, 2024

Not a huge fan of just panicking on invalid key length, as there's no way for an application to recover from that. I guess without const_generic_exprs there's not much else we can do other than make the method fallible (which might be preferable?).

@bjoernQ what do you think?

Not exactly nice, true. Fallible would be better or maybe we define an Enum for the keysizes, like

pub enum Key {
  Key16([u8;16),
  #[cfg(any(feature = "esp32", feature = "esp32s2")]
  Key24([u8;24),
  Key32([u8;32),
}

Also don't we define cfg-symbols for the chip? Like #[cfg(any(esp32,esp32s2)]

esp-hal/src/aes/mod.rs Outdated Show resolved Hide resolved
@jessebraham
Copy link
Member

Thanks for the input @bjoernQ. Not quite sure what is best right now, I think making it fallible or the key size enum are both probably fine solutions. So, no strong opinions now, will sleep on it.

@MabezDev
Copy link
Member

MabezDev commented Apr 4, 2024

Can we decide on a path forward here?

@jessebraham
Copy link
Member

jessebraham commented Apr 4, 2024

I've suggested a solution, so has Bjoern. I'm not going to be too picky about what we decide on as long as it doesn't just panic. If nobody else has any input then we should probably just make it fallible and we can revisit it at some other time.

@bjoernQ
Copy link
Contributor

bjoernQ commented Apr 4, 2024

I'm fine with making it fallible for now. I think the Key enum would be a better solution if we don't end up in having a hell lot of key lengths. But for the sake to get this forward - let's make it fallible

@playfulFence
Copy link
Contributor Author

playfulFence commented Apr 4, 2024

I think, as Key enum is currently a "nicest" solution, we can proceed with it 🤔

@jessebraham
Copy link
Member

I think, as Key enum is currently a "nicest" solution, we can proceed with it 🤔

Sure, that's fine too. A fallible API is probably simpler, though.

@MabezDev
Copy link
Member

MabezDev commented Apr 5, 2024

Let's go with the Key enum, I think we can make the API simpler like @jessebraham was suggesting by adding From<[u8; 16]> impls for Key, meaning the API doesn't get much harder to use, users only need to call into(). We could even add the trait bound for Into<Key> if we wanted to go the extra mile.

@playfulFence playfulFence marked this pull request as draft April 16, 2024 11:29
@playfulFence playfulFence marked this pull request as ready for review April 16, 2024 12:05
Update comment
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM - the key-enum is really the nicer solution

esp-hal/src/aes/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/aes/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/aes/mod.rs Show resolved Hide resolved
esp-hal/src/aes/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for making those changes, and thanks for sticking it out through all these review comments!

@jessebraham jessebraham enabled auto-merge April 16, 2024 16:49
@jessebraham jessebraham dismissed MabezDev’s stale review April 16, 2024 16:51

Review comments have been addressed

@jessebraham jessebraham added this pull request to the merge queue Apr 16, 2024
Merged via the queue into esp-rs:main with commit 17492f6 Apr 16, 2024
22 checks passed
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.

AES seems to only support 128-bit keys
6 participants