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

add FromStr representations of kdf, kem, and aead #40

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

jbr
Copy link
Contributor

@jbr jbr commented Aug 9, 2023

No description provided.

@jbr jbr requested a review from a team as a code owner August 9, 2023 20:17
@jbr jbr force-pushed the from-str-implementations branch from ab72e07 to 018fe22 Compare August 9, 2023 20:21
src/kdf.rs Outdated
fn from_str(s: &str) -> Result<Self, Self::Err> {
match &*s.to_lowercase() {
#[cfg(feature = "kdf-sha256")]
"sha256" | "sha-256" => Ok(Self::Sha256),
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to include the "HKDF-" prefix in these identifiers for completeness and future-proofing. See RFC9180, Table 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a second commit (869c6d8) that handles hkdf-sha256 and HkdfSha256

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we require the prefix?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think accepting either is probably fine.

src/kem.rs Outdated
Ok(Self::DhP256HkdfSha256)
}
#[cfg(feature = "kem-x25519-hkdf-sha256")]
"x25519hkdfsha256" | "x25519-hkdf-sha256" | "dhkem(x25519, hkdf-sha256)" => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the shorter nicknames for this and the P-256-based KEM are inconsistent on whether they include "dh-"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's your suggested resolution to this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend dropping "dh" from "dhp256hkdfsha256". (I think it would be unusual to abbreviate DHKEM to DH, and more natural to omit the DHKEM part altogether)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it's worth raising this with the backing crate as well. I just cargo-culted the naming from hpke::kem::DhP256HkdfSha256

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in eab5053 — i also added versions that don't label the kdf, so p256-sha256 and x25519-sha256. let me know if that's somehow inaccurate or if there are other uses of sha256 as part of these kems other than hkdf

Copy link
Contributor

@divergentdave divergentdave 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!

@jbr jbr merged commit 17832f6 into main Aug 10, 2023
10 checks passed
@jbr jbr deleted the from-str-implementations branch August 10, 2023 18:06
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