diff --git a/sm2/src/pke/decrypting.rs b/sm2/src/pke/decrypting.rs index 82295a37..fec475f2 100644 --- a/sm2/src/pke/decrypting.rs +++ b/sm2/src/pke/decrypting.rs @@ -98,7 +98,7 @@ impl DecryptingKey { } /// Decrypts a ciphertext in-place from ASN.1 format using the default digest algorithm (`Sm3`). - pub fn decrypt_asna1(&self, ciphertext: &[u8]) -> Result> { + pub fn decrypt_der(&self, ciphertext: &[u8]) -> Result> { self.decrypt_asna1_digest::(ciphertext) } diff --git a/sm2/src/pke/encrypting.rs b/sm2/src/pke/encrypting.rs index 82d274e7..a31ca4b7 100644 --- a/sm2/src/pke/encrypting.rs +++ b/sm2/src/pke/encrypting.rs @@ -84,8 +84,8 @@ impl EncryptingKey { /// /// This method calculates the digest using the `Sm3` hash function and performs encryption, /// then encodes the result in ASN.1 format. - pub fn encrypt_asna1(&self, msg: &[u8]) -> Result> { - self.encrypt_asna1_digest::(msg) + pub fn encrypt_der(&self, msg: &[u8]) -> Result> { + self.encrypt_der_digest::(msg) } /// Encrypts a message using a specified digest algorithm. @@ -98,7 +98,7 @@ impl EncryptingKey { } /// Encrypts a message using a specified digest algorithm and returns the result in ASN.1 format. - pub fn encrypt_asna1_digest(&self, msg: &[u8]) -> Result> + pub fn encrypt_der_digest(&self, msg: &[u8]) -> Result> where D: 'static + Digest + DynDigest + Send + Sync, { diff --git a/sm2/tests/sm2pke.rs b/sm2/tests/sm2pke.rs index fd65afe6..1ce84b9d 100644 --- a/sm2/tests/sm2pke.rs +++ b/sm2/tests/sm2pke.rs @@ -36,7 +36,7 @@ fn decrypt_asna1_verify() { NonZeroScalar::::try_from(PRIVATE_KEY.as_ref() as &[u8]).unwrap(), sm2::pke::Mode::C1C2C3, ); - assert_eq!(dk.decrypt_asna1(&ASN1_CIPHER).unwrap(), MSG); + assert_eq!(dk.decrypt_der(&ASN1_CIPHER).unwrap(), MSG); } prop_compose! { @@ -65,8 +65,8 @@ proptest! { #[test] fn encrypt_and_decrpyt_asna1(dk in decrypting_key()) { let ek = dk.encrypting_key(); - let cipher_bytes = ek.encrypt_asna1(MSG).unwrap(); - prop_assert!(dk.decrypt_asna1(&cipher_bytes).is_ok()); + let cipher_bytes = ek.encrypt_der(MSG).unwrap(); + prop_assert!(dk.decrypt_der(&cipher_bytes).is_ok()); } #[test]