Skip to content

Commit

Permalink
{Public,Private}Key::from_ed25519 should not set keyid_hash_algorithms
Browse files Browse the repository at this point in the history
python-tuf is [considering] getting rid of keyid_hash_algorithms, so we
shouldn't default to generating keys with them specified.

[considering]: theupdateframework/python-tuf#848

Change-Id: I2c3af5d5eb7b0cc30793b54e45155320164cf706
  • Loading branch information
erickt committed Jan 23, 2020
1 parent 60f2b3a commit 99f2c11
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ impl PrivateKey {
/// Create a new `PrivateKey` from an ed25519 keypair, a 64 byte slice, where the first 32
/// bytes are the ed25519 seed, and the second 32 bytes are the public key.
pub fn from_ed25519(key: &[u8]) -> Result<Self> {
Self::from_ed25519_with_keyid_hash_algorithms(
key,
python_tuf_compatibility_keyid_hash_algorithms(),
)
Self::from_ed25519_with_keyid_hash_algorithms(key, None)
}

fn from_ed25519_with_keyid_hash_algorithms(
Expand Down Expand Up @@ -661,10 +658,7 @@ impl PublicKey {

/// Parse ED25519 bytes as a public key.
pub fn from_ed25519<T: Into<Vec<u8>>>(bytes: T) -> Result<Self> {
Self::from_ed25519_with_keyid_hash_algorithms(
bytes,
python_tuf_compatibility_keyid_hash_algorithms(),
)
Self::from_ed25519_with_keyid_hash_algorithms(bytes, None)
}

/// Parse ED25519 bytes as a public key with a custom `keyid_hash_algorithms`.
Expand Down Expand Up @@ -1026,7 +1020,7 @@ mod test {
let key = PublicKey::from_ed25519(ED25519_1_PUBLIC_KEY).unwrap();
assert_eq!(
key.key_id(),
&KeyId::from_str("a9f3ebc9b138762563a9c27b6edd439959e559709babd123e8d449ba2c18c61a")
&KeyId::from_str("e0294a3f17cc8563c3ed5fceb3bd8d3f6bfeeaca499b5c9572729ae015566554")
.unwrap()
);
assert_eq!(key.typ, KeyType::Ed25519);
Expand Down

0 comments on commit 99f2c11

Please sign in to comment.