Skip to content

Commit db7d6cd

Browse files
theswiftfoxandrewhopjustsmth
authored
Change 'try_sign' to pub in ED25519 module (#832)
* Make 'try_sign' pub in ED25519 - to allow users to sign using ed25519 without risking a panic, try_sign is made pub again. Signed-of-by: Elena Gantner <[email protected]> * Update aws-lc-rs/src/ed25519.rs Add a note that try_sign should also not be used for FIPS. * Fix clippy; update external test to use try_sign --------- Co-authored-by: Andrew Hopkins <[email protected]> Co-authored-by: Justin Smith <[email protected]>
1 parent f0a6350 commit db7d6cd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

aws-lc-rs/src/ed25519.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,15 @@ impl Ed25519KeyPair {
402402
Self::try_sign(self, msg).expect("ED25519 signing failed")
403403
}
404404

405+
/// Returns the signature of the message `msg`.
406+
///
407+
// # FIPS
408+
// This method must not be used.
409+
//
410+
/// # Errors
411+
/// Returns `error::Unspecified` if the signing operation fails.
405412
#[inline]
406-
fn try_sign(&self, msg: &[u8]) -> Result<Signature, Unspecified> {
413+
pub fn try_sign(&self, msg: &[u8]) -> Result<Signature, Unspecified> {
407414
let sig_bytes = self.evp_pkey.sign(msg, None, No_EVP_PKEY_CTX_consumer)?;
408415

409416
Ok(Signature::new(|slice| {

aws-lc-rs/tests/ed25519_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn test_signature_ed25519() {
3232
let expected_sig = test_case.consume_bytes("SIG");
3333

3434
let key_pair = Ed25519KeyPair::from_seed_unchecked(&seed).unwrap();
35-
let actual_sig = key_pair.sign(&msg);
35+
let actual_sig = key_pair.try_sign(&msg)?;
3636
assert_eq!(&expected_sig[..], actual_sig.as_ref());
3737

3838
let key_pair = Ed25519KeyPair::from_seed_and_public_key(&seed, &public_key).unwrap();

0 commit comments

Comments
 (0)