diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-02-27 12:32:03 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-11-06 23:03:30 +0100 |
commit | b2e7241f83a19057d86a840d0d154bc2703272e0 (patch) | |
tree | aaff33cf668bca6e1371c180180143daea57f571 /openpgp/src/serialize.rs | |
parent | ad10cd5a7c597f85009e7b3cbc3e04173d054db8 (diff) |
openpgp: Implement the new CFRG public key algorithms.
- X25519 and Ed25519 are the new MTI algorithms, X448 and Ed448 are
optional.
Diffstat (limited to 'openpgp/src/serialize.rs')
-rw-r--r-- | openpgp/src/serialize.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs index 44584956..468d920d 100644 --- a/openpgp/src/serialize.rs +++ b/openpgp/src/serialize.rs @@ -1003,6 +1003,11 @@ impl Marshal for crypto::mpi::PublicKey { w.write_all(&[3u8, 1u8, u8::from(*hash), u8::from(*sym)])?; } + X25519 { u } => w.write_all(&u[..])?, + X448 { u } => w.write_all(&u[..])?, + Ed25519 { a } => w.write_all(&a[..])?, + Ed448 { a } => w.write_all(&a[..])?, + Unknown { ref mpis, ref rest } => { for mpi in mpis.iter() { mpi.serialize(w)?; @@ -1044,6 +1049,11 @@ impl MarshalInto for crypto::mpi::PublicKey { 1 + curve.oid().len() + q.serialized_len() + 4 } + X25519 { .. } => 32, + X448 { .. } => 56, + Ed25519 { .. } => 32, + Ed448 { .. } => 57, + Unknown { ref mpis, ref rest } => { mpis.iter().map(|mpi| mpi.serialized_len()).sum::<usize>() + rest.len() @@ -1089,6 +1099,11 @@ impl Marshal for crypto::mpi::SecretKeyMaterial { scalar.serialize(w)?; } + X25519 { x } => w.write_all(x)?, + X448 { x } => w.write_all(x)?, + Ed25519 { x } => w.write_all(x)?, + Ed448 { x } => w.write_all(x)?, + Unknown { ref mpis, ref rest } => { for mpi in mpis.iter() { mpi.serialize(w)?; @@ -1130,6 +1145,11 @@ impl MarshalInto for crypto::mpi::SecretKeyMaterial { scalar.serialized_len() } + X25519 { .. } => 32, + X448 { .. } => 56, + Ed25519 { .. } => 32, + Ed448 { .. } => 57, + Unknown { ref mpis, ref rest } => { mpis.iter().map(|mpi| mpi.serialized_len()).sum::<usize>() + rest.len() @@ -1192,6 +1212,16 @@ impl Marshal for crypto::mpi::Ciphertext { write_field_with_u8_size(w, "Key", key)?; } + X25519 { e, key } => { + w.write_all(&e[..])?; + write_field_with_u8_size(w, "Key", key)?; + } + + X448 { e, key } => { + w.write_all(&e[..])?; + write_field_with_u8_size(w, "Key", key)?; + } + Unknown { ref mpis, ref rest } => { for mpi in mpis.iter() { mpi.serialize(w)?; @@ -1220,6 +1250,14 @@ impl MarshalInto for crypto::mpi::Ciphertext { e.serialized_len() + 1 + key.len() } + X25519 { key, .. } => { + 32 + 1 + key.len() + } + + X448 { key, .. } => { + 56 + 1 + key.len() + } + Unknown { ref mpis, ref rest } => { mpis.iter().map(|mpi| mpi.serialized_len()).sum::<usize>() + rest.len() @@ -1258,6 +1296,9 @@ impl Marshal for crypto::mpi::Signature { s.serialize(w)?; } + Ed25519 { s } => w.write_all(&s[..])?, + Ed448 { s } => w.write_all(&s[..])?, + Unknown { ref mpis, ref rest } => { for mpi in mpis.iter() { mpi.serialize(w)?; @@ -1290,6 +1331,9 @@ impl MarshalInto for crypto::mpi::Signature { r.serialized_len() + s.serialized_len() } + Ed25519 { .. } => 64, + Ed448 { .. } => 114, + Unknown { ref mpis, ref rest } => { mpis.iter().map(|mpi| mpi.serialized_len()).sum::<usize>() + rest.len() |