2222//! * [`SigStoreSigner`]: an abstraction for digital signing algorithms.
2323//!
2424//! 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
2728//!
2829//! 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.
2936//! * [`SigStoreSigner::ECDSA_P256_SHA256_ASN1`]: ASN.1 DER-encoded ECDSA
3037//! signatures using the P-256 curve and SHA-256.
3138//! * [`SigStoreSigner::ECDSA_P384_SHA384_ASN1`]: ASN.1 DER-encoded ECDSA
@@ -68,6 +75,7 @@ use crate::errors::*;
6875use self :: {
6976 ecdsa:: { ec:: EcdsaSigner , ECDSAKeys } ,
7077 ed25519:: { Ed25519Keys , Ed25519Signer } ,
78+ rsa:: { keypair:: RSAKeys , RSASigner } ,
7179} ;
7280
7381use super :: { verification_key:: CosignVerificationKey , SigningScheme } ;
@@ -89,6 +97,9 @@ pub const SIGSTORE_PRIVATE_KEY_PEM_LABEL: &str = "ENCRYPTED SIGSTORE PRIVATE KEY
8997/// The label for pem of private keys.
9098pub const PRIVATE_KEY_PEM_LABEL : & str = "PRIVATE KEY" ;
9199
100+ /// The label for pem of RSA private keys.
101+ pub const RSA_PRIVATE_KEY_PEM_LABEL : & str = "RSA PRIVATE KEY" ;
102+
92103/// Every signing scheme must implement this interface.
93104/// All private export methods using the wrapper `Zeroizing`.
94105/// It will tell the compiler when the
@@ -125,7 +136,7 @@ pub trait KeyPair {
125136pub enum SigStoreKeyPair {
126137 ECDSA ( ECDSAKeys ) ,
127138 ED25519 ( Ed25519Keys ) ,
128- // RSA,
139+ RSA ( RSAKeys ) ,
129140}
130141
131142/// This macro helps to reduce duplicated code.
@@ -147,6 +158,7 @@ macro_rules! sigstore_keypair_code {
147158 match $obj {
148159 SigStoreKeyPair :: ECDSA ( keys) => keys. as_inner( ) . $func( $( $args, ) * ) ,
149160 SigStoreKeyPair :: ED25519 ( keys) => keys. $func( $( $args, ) * ) ,
161+ SigStoreKeyPair :: RSA ( keys) => keys. $func( $( $args, ) * ) ,
150162 }
151163 }
152164}
@@ -217,6 +229,12 @@ pub trait Signer {
217229
218230#[ allow( non_camel_case_types) ]
219231pub 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 ) ,
220238 ECDSA_P256_SHA256_ASN1 ( EcdsaSigner < p256:: NistP256 , sha2:: Sha256 > ) ,
221239 ECDSA_P384_SHA384_ASN1 ( EcdsaSigner < p384:: NistP384 , sha2:: Sha384 > ) ,
222240 ED25519 ( Ed25519Signer ) ,
@@ -230,6 +248,12 @@ impl SigStoreSigner {
230248 SigStoreSigner :: ECDSA_P256_SHA256_ASN1 ( inner) => inner,
231249 SigStoreSigner :: ECDSA_P384_SHA384_ASN1 ( inner) => inner,
232250 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,
233257 }
234258 }
235259
@@ -244,6 +268,12 @@ impl SigStoreSigner {
244268 SigStoreSigner :: ECDSA_P256_SHA256_ASN1 ( _) => SigningScheme :: ECDSA_P256_SHA256_ASN1 ,
245269 SigStoreSigner :: ECDSA_P384_SHA384_ASN1 ( _) => SigningScheme :: ECDSA_P384_SHA384_ASN1 ,
246270 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 ) ,
247277 } ;
248278 self . as_inner ( )
249279 . key_pair ( )
@@ -262,6 +292,18 @@ impl SigStoreSigner {
262292 SigStoreSigner :: ED25519 ( inner) => {
263293 SigStoreKeyPair :: ED25519 ( Ed25519Keys :: from_ed25519key ( inner. ed25519_keys ( ) ) ?)
264294 }
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+ }
265307 } )
266308 }
267309}
0 commit comments