Skip to content

Commit

Permalink
Serialize the secret key to DER, not the public one
Browse files Browse the repository at this point in the history
Fixes #74
  • Loading branch information
jedisct1 committed Oct 3, 2022
1 parent 6b2ef16 commit d86040f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/algorithms/eddsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Edwards25519KeyPair {
}

pub fn to_der(&self) -> Vec<u8> {
self.ed25519_kp.pk.to_der()
self.ed25519_kp.sk.to_der()
}

pub fn to_pem(&self) -> String {
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ a3t0cyDKinOY7JGIwh8DWAa4pfEzgg56yLcilYSSohXeaQV0nR8+rm9J8GUYXjPK
assert!(claims.custom.is_custom);
}

#[test]
fn ed25519_der() {
let key_pair = Ed25519KeyPair::generate();
let der = key_pair.to_der();
let key_pair2 = Ed25519KeyPair::from_der(&der).unwrap();
assert_eq!(key_pair.to_bytes(), key_pair2.to_bytes());
}

#[test]
fn require_nonce() {
let key = HS256Key::generate();
Expand Down

0 comments on commit d86040f

Please sign in to comment.