Skip to content

Commit a2ed335

Browse files
expose algorithm used to create ecdsa keypair (#834)
* expose algorithm used to create ecdsa keypair * must use * Update external test to call EcdsaKeyPair::algorithm() --------- Co-authored-by: Justin Smith <[email protected]>
1 parent db7d6cd commit a2ed335

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

aws-lc-rs/src/ec/key_pair.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ impl EcdsaKeyPair {
201201
PrivateKey(self)
202202
}
203203

204+
/// [`EcdsaSigningAlgorithm`] which was used to create this [`EcdsaKeyPair`]
205+
#[must_use]
206+
pub fn algorithm(&self) -> &'static EcdsaSigningAlgorithm {
207+
self.algorithm
208+
}
209+
204210
/// Returns the signature of the message using a random nonce.
205211
///
206212
/// # *ring* Compatibility
@@ -318,5 +324,6 @@ mod tests {
318324
assert_eq!(key_pair.evp_pkey, key_pair_5208.evp_pkey);
319325
assert_eq!(key_pair.evp_pkey, key_pair_5915.evp_pkey);
320326
assert_eq!(key_pair_5208.evp_pkey, key_pair_5915.evp_pkey);
327+
assert_eq!(key_pair_5915.algorithm, &ECDSA_P256_SHA256_FIXED_SIGNING);
321328
}
322329
}

aws-lc-rs/tests/ecdsa_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ fn ecdsa_generate_pkcs8_test() {
140140
println!();
141141
println!();
142142

143-
EcdsaKeyPair::from_pkcs8(alg, pkcs8.as_ref()).unwrap();
143+
let key_pair = EcdsaKeyPair::from_pkcs8(alg, pkcs8.as_ref()).unwrap();
144+
assert_eq!(key_pair.algorithm(), *alg);
144145
}
145146
}
146147

0 commit comments

Comments
 (0)