22
22
//! * [`SigStoreSigner`]: an abstraction for digital signing algorithms.
23
23
//!
24
24
//! The [`SigStoreKeyPair`] now includes the key types of the following algorithms:
25
- //! * [`SigStoreKeyPair::ECDSA`]: Elliptic curve digital signing algorithm
26
- //! * [`SigStoreKeyPair::ED25519`]: Edwards curve-25519 digital signing algorithm
25
+ //! * [`SigStoreKeyPair::RSA`]: RSA key pair
26
+ //! * [`SigStoreKeyPair::ECDSA`]: Elliptic curve key pair
27
+ //! * [`SigStoreKeyPair::ED25519`]: Edwards curve-25519 key pair
27
28
//!
28
29
//! The [`SigStoreSigner`] now includes the following signing schemes:
30
+ //! * [`SigStoreSigner::RSA_PSS_SHA256`]: RSA signatures using PSS padding and SHA-256.
31
+ //! * [`SigStoreSigner::RSA_PSS_SHA384`]: RSA signatures using PSS padding and SHA-384.
32
+ //! * [`SigStoreSigner::RSA_PSS_SHA512`]: RSA signatures using PSS padding and SHA-512.
33
+ //! * [`SigStoreSigner::RSA_PKCS1_SHA256`]: RSA signatures using PKCS#1v1.5 padding and SHA-256.
34
+ //! * [`SigStoreSigner::RSA_PKCS1_SHA384`]: RSA signatures using PKCS#1v1.5 padding and SHA-384.
35
+ //! * [`SigStoreSigner::RSA_PKCS1_SHA512`]: RSA signatures using PKCS#1v1.5 padding and SHA-512.
29
36
//! * [`SigStoreSigner::ECDSA_P256_SHA256_ASN1`]: ASN.1 DER-encoded ECDSA
30
37
//! signatures using the P-256 curve and SHA-256.
31
38
//! * [`SigStoreSigner::ECDSA_P384_SHA384_ASN1`]: ASN.1 DER-encoded ECDSA
@@ -68,6 +75,7 @@ use crate::errors::*;
68
75
use self :: {
69
76
ecdsa:: { ec:: EcdsaSigner , ECDSAKeys } ,
70
77
ed25519:: { Ed25519Keys , Ed25519Signer } ,
78
+ rsa:: { keypair:: RSAKeys , RSASigner } ,
71
79
} ;
72
80
73
81
use super :: { verification_key:: CosignVerificationKey , SigningScheme } ;
@@ -89,6 +97,9 @@ pub const SIGSTORE_PRIVATE_KEY_PEM_LABEL: &str = "ENCRYPTED SIGSTORE PRIVATE KEY
89
97
/// The label for pem of private keys.
90
98
pub const PRIVATE_KEY_PEM_LABEL : & str = "PRIVATE KEY" ;
91
99
100
+ /// The label for pem of RSA private keys.
101
+ pub const RSA_PRIVATE_KEY_PEM_LABEL : & str = "RSA PRIVATE KEY" ;
102
+
92
103
/// Every signing scheme must implement this interface.
93
104
/// All private export methods using the wrapper `Zeroizing`.
94
105
/// It will tell the compiler when the
@@ -125,7 +136,7 @@ pub trait KeyPair {
125
136
pub enum SigStoreKeyPair {
126
137
ECDSA ( ECDSAKeys ) ,
127
138
ED25519 ( Ed25519Keys ) ,
128
- // RSA,
139
+ RSA ( RSAKeys ) ,
129
140
}
130
141
131
142
/// This macro helps to reduce duplicated code.
@@ -147,6 +158,7 @@ macro_rules! sigstore_keypair_code {
147
158
match $obj {
148
159
SigStoreKeyPair :: ECDSA ( keys) => keys. as_inner( ) . $func( $( $args, ) * ) ,
149
160
SigStoreKeyPair :: ED25519 ( keys) => keys. $func( $( $args, ) * ) ,
161
+ SigStoreKeyPair :: RSA ( keys) => keys. $func( $( $args, ) * ) ,
150
162
}
151
163
}
152
164
}
@@ -217,6 +229,12 @@ pub trait Signer {
217
229
218
230
#[ allow( non_camel_case_types) ]
219
231
pub enum SigStoreSigner {
232
+ RSA_PSS_SHA256 ( RSASigner ) ,
233
+ RSA_PSS_SHA384 ( RSASigner ) ,
234
+ RSA_PSS_SHA512 ( RSASigner ) ,
235
+ RSA_PKCS1_SHA256 ( RSASigner ) ,
236
+ RSA_PKCS1_SHA384 ( RSASigner ) ,
237
+ RSA_PKCS1_SHA512 ( RSASigner ) ,
220
238
ECDSA_P256_SHA256_ASN1 ( EcdsaSigner < p256:: NistP256 , sha2:: Sha256 > ) ,
221
239
ECDSA_P384_SHA384_ASN1 ( EcdsaSigner < p384:: NistP384 , sha2:: Sha384 > ) ,
222
240
ED25519 ( Ed25519Signer ) ,
@@ -230,6 +248,12 @@ impl SigStoreSigner {
230
248
SigStoreSigner :: ECDSA_P256_SHA256_ASN1 ( inner) => inner,
231
249
SigStoreSigner :: ECDSA_P384_SHA384_ASN1 ( inner) => inner,
232
250
SigStoreSigner :: ED25519 ( inner) => inner,
251
+ SigStoreSigner :: RSA_PSS_SHA256 ( inner) => inner,
252
+ SigStoreSigner :: RSA_PSS_SHA384 ( inner) => inner,
253
+ SigStoreSigner :: RSA_PSS_SHA512 ( inner) => inner,
254
+ SigStoreSigner :: RSA_PKCS1_SHA256 ( inner) => inner,
255
+ SigStoreSigner :: RSA_PKCS1_SHA384 ( inner) => inner,
256
+ SigStoreSigner :: RSA_PKCS1_SHA512 ( inner) => inner,
233
257
}
234
258
}
235
259
@@ -244,6 +268,12 @@ impl SigStoreSigner {
244
268
SigStoreSigner :: ECDSA_P256_SHA256_ASN1 ( _) => SigningScheme :: ECDSA_P256_SHA256_ASN1 ,
245
269
SigStoreSigner :: ECDSA_P384_SHA384_ASN1 ( _) => SigningScheme :: ECDSA_P384_SHA384_ASN1 ,
246
270
SigStoreSigner :: ED25519 ( _) => SigningScheme :: ED25519 ,
271
+ SigStoreSigner :: RSA_PSS_SHA256 ( _) => SigningScheme :: RSA_PSS_SHA256 ( 0 ) ,
272
+ SigStoreSigner :: RSA_PSS_SHA384 ( _) => SigningScheme :: RSA_PSS_SHA384 ( 0 ) ,
273
+ SigStoreSigner :: RSA_PSS_SHA512 ( _) => SigningScheme :: RSA_PSS_SHA512 ( 0 ) ,
274
+ SigStoreSigner :: RSA_PKCS1_SHA256 ( _) => SigningScheme :: RSA_PKCS1_SHA256 ( 0 ) ,
275
+ SigStoreSigner :: RSA_PKCS1_SHA384 ( _) => SigningScheme :: RSA_PKCS1_SHA384 ( 0 ) ,
276
+ SigStoreSigner :: RSA_PKCS1_SHA512 ( _) => SigningScheme :: RSA_PKCS1_SHA512 ( 0 ) ,
247
277
} ;
248
278
self . as_inner ( )
249
279
. key_pair ( )
@@ -262,6 +292,18 @@ impl SigStoreSigner {
262
292
SigStoreSigner :: ED25519 ( inner) => {
263
293
SigStoreKeyPair :: ED25519 ( Ed25519Keys :: from_ed25519key ( inner. ed25519_keys ( ) ) ?)
264
294
}
295
+ SigStoreSigner :: RSA_PSS_SHA256 ( inner) => SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) ) ,
296
+ SigStoreSigner :: RSA_PSS_SHA384 ( inner) => SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) ) ,
297
+ SigStoreSigner :: RSA_PSS_SHA512 ( inner) => SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) ) ,
298
+ SigStoreSigner :: RSA_PKCS1_SHA256 ( inner) => {
299
+ SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) )
300
+ }
301
+ SigStoreSigner :: RSA_PKCS1_SHA384 ( inner) => {
302
+ SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) )
303
+ }
304
+ SigStoreSigner :: RSA_PKCS1_SHA512 ( inner) => {
305
+ SigStoreKeyPair :: RSA ( inner. rsa_keys ( ) . clone ( ) )
306
+ }
265
307
} )
266
308
}
267
309
}
0 commit comments