Commit
Author: Mauro D [mauro@stalw.art]
Hash: 4f50553f1c323b2418840692f70125861ab7c10a
Timestamp: Sun, 11 Dec 2022 18:25:39 +0000 (1 year ago)

+11 -11 +/-7 browse
Renamed from_rsa methods.
1diff --git a/README.md b/README.md
2index 03edba1..4cd2f5b 100644
3--- a/README.md
4+++ b/README.md
5 @@ -50,7 +50,7 @@ Features:
6
7 ```rust
8 // Sign an e-mail message using RSA-SHA256
9- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
10+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
11 let signature_rsa = Signature::new()
12 .headers(["From", "To", "Subject"])
13 .domain("example.com")
14 @@ -117,7 +117,7 @@ Features:
15 // Seal message
16 if arc_result.can_be_sealed() {
17 // Seal the e-mail message using RSA-SHA256
18- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
19+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
20 let arc_set = ArcSet::new(&auth_results)
21 .domain("example.org")
22 .selector("default")
23 diff --git a/examples/arc_seal.rs b/examples/arc_seal.rs
24index 460b898..edb53d9 100644
25--- a/examples/arc_seal.rs
26+++ b/examples/arc_seal.rs
27 @@ -53,7 +53,7 @@ async fn main() {
28 // Seal message
29 if arc_result.can_be_sealed() {
30 // Seal the e-mail message using RSA-SHA256
31- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
32+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
33 let arc_set = ArcSet::new(&auth_results)
34 .domain("example.org")
35 .selector("default")
36 diff --git a/examples/dkim_sign.rs b/examples/dkim_sign.rs
37index 9bf3bfe..9d463fa 100644
38--- a/examples/dkim_sign.rs
39+++ b/examples/dkim_sign.rs
40 @@ -43,7 +43,7 @@ I'm going to need those TPS reports ASAP. So, if you could do that, that'd be gr
41
42 fn main() {
43 // Sign an e-mail message using RSA-SHA256
44- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
45+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
46 let signature_rsa = Signature::new()
47 .headers(["From", "To", "Subject"])
48 .domain("example.com")
49 diff --git a/src/arc/seal.rs b/src/arc/seal.rs
50index 1deea47..17602c1 100644
51--- a/src/arc/seal.rs
52+++ b/src/arc/seal.rs
53 @@ -281,7 +281,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
54 );
55
56 // Create private keys
57- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
58+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
59 let pk_ed = Ed25519Key::from_bytes(
60 &base64_decode(ED25519_PUBLIC_KEY.rsplit_once("p=").unwrap().1.as_bytes()).unwrap(),
61 &base64_decode(ED25519_PRIVATE_KEY.as_bytes()).unwrap(),
62 diff --git a/src/common/crypto.rs b/src/common/crypto.rs
63index aa50931..6c5b17b 100644
64--- a/src/common/crypto.rs
65+++ b/src/common/crypto.rs
66 @@ -31,7 +31,7 @@ pub struct RsaKey<T> {
67
68 impl<T: Digest + AssociatedOid + io::Write> RsaKey<T> {
69 /// Creates a new RSA private key from a PKCS1 PEM string.
70- pub fn from_rsa_pkcs1_pem(private_key_pem: &str) -> Result<Self> {
71+ pub fn from_pkcs1_pem(private_key_pem: &str) -> Result<Self> {
72 let inner = RsaPrivateKey::from_pkcs1_pem(private_key_pem)
73 .map_err(|err| Error::CryptoError(err.to_string()))?;
74
75 @@ -42,7 +42,7 @@ impl<T: Digest + AssociatedOid + io::Write> RsaKey<T> {
76 }
77
78 /// Creates a new RSA private key from a PKCS1 binary slice.
79- pub fn from_rsa_pkcs1_der(private_key_bytes: &[u8]) -> Result<Self> {
80+ pub fn from_pkcs1_der(private_key_bytes: &[u8]) -> Result<Self> {
81 let inner = RsaPrivateKey::from_pkcs1_der(private_key_bytes)
82 .map_err(|err| Error::CryptoError(err.to_string()))?;
83
84 diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs
85index 7e694f3..c9fdb10 100644
86--- a/src/dkim/sign.rs
87+++ b/src/dkim/sign.rs
88 @@ -194,7 +194,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
89
90 #[test]
91 fn dkim_sign() {
92- let pk = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
93+ let pk = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
94 let signature = Signature::new()
95 .headers(["From", "To", "Subject"])
96 .domain("stalw.art")
97 @@ -250,7 +250,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc=
98 );
99
100 // Create private keys
101- let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
102+ let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
103 let pk_ed = Ed25519Key::from_bytes(
104 &base64_decode(ED25519_PUBLIC_KEY.rsplit_once("p=").unwrap().1.as_bytes()).unwrap(),
105 &base64_decode(ED25519_PRIVATE_KEY.as_bytes()).unwrap(),
106 diff --git a/src/lib.rs b/src/lib.rs
107index c3de0f5..52fc139 100644
108--- a/src/lib.rs
109+++ b/src/lib.rs
110 @@ -60,7 +60,7 @@
111 //!
112 //! ```rust
113 //! // Sign an e-mail message using RSA-SHA256
114- //! let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
115+ //! let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
116 //! let signature_rsa = Signature::new()
117 //! .headers(["From", "To", "Subject"])
118 //! .domain("example.com")
119 @@ -127,7 +127,7 @@
120 //! // Seal message
121 //! if arc_result.can_be_sealed() {
122 //! // Seal the e-mail message using RSA-SHA256
123- //! let pk_rsa = RsaKey::<Sha256>::from_rsa_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
124+ //! let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap();
125 //! let arc_set = ArcSet::new(&auth_results)
126 //! .domain("example.org")
127 //! .selector("default")