Add typedefs for RSAES and RSASS using SHA256

Also see https://groups.google.com/g/cryptopp-users/c/0GXv5oj7RgI/m/MVZt_V8eBAAJ
This commit is contained in:
Jeffrey Walton 2023-04-20 19:08:02 -04:00
parent 03e9fa0942
commit 3b8c9303b4
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 34 additions and 2 deletions

25
rsa.h
View File

@ -203,18 +203,31 @@ struct RSASS_ISO : public TF_SS<RSA_ISO, P1363_EMSA2, H>
/// \brief \ref RSAES<STANDARD> "RSAES<PKCS1v15>::Decryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 1.0
DOCUMENTED_TYPEDEF(RSAES<PKCS1v15>::Decryptor, RSAES_PKCS1v15_Decryptor);
/// \brief \ref RSAES<STANDARD> "RSAES<PKCS1v15>::Encryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 1.0
DOCUMENTED_TYPEDEF(RSAES<PKCS1v15>::Encryptor, RSAES_PKCS1v15_Encryptor);
/// \brief \ref RSAES<STANDARD> "RSAES<OAEP<SHA1>>::Decryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 1.0
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA1> >::Decryptor, RSAES_OAEP_SHA_Decryptor);
/// \brief \ref RSAES<STANDARD> "RSAES<OAEP<SHA1>>::Encryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 1.0
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA1> >::Encryptor, RSAES_OAEP_SHA_Encryptor);
/// \brief \ref RSAES<STANDARD> "RSAES<OAEP<SHA256>>::Decryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 8.7
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA256> >::Decryptor, RSAES_OAEP_SHA256_Decryptor);
/// \brief \ref RSAES<STANDARD> "RSAES<OAEP<SHA256>>::Encryptor" typedef
/// \details RSA encryption scheme defined in PKCS #1 v2.0
/// \since Crypto++ 8.7
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA256> >::Encryptor, RSAES_OAEP_SHA256_Encryptor);
#ifdef CRYPTOPP_DOXYGEN_PROCESSING
/// \brief \ref RSASS<STANDARD,HASH> "RSASS<PKCS1v15,SHA1>::Signer" typedef
/// \details RSA signature schemes defined in PKCS #1 v2.0
@ -225,6 +238,15 @@ class RSASSA_PKCS1v15_SHA_Signer : public RSASS<PKCS1v15,SHA1>::Signer {};
/// \since Crypto++ 1.0
class RSASSA_PKCS1v15_SHA_Verifier : public RSASS<PKCS1v15,SHA1>::Verifier {};
/// \brief \ref RSASS<STANDARD,HASH> "RSASS<PKCS1v15,SHA256>::Signer" typedef
/// \details RSA signature schemes defined in PKCS #1 v2.0
/// \since Crypto++ 8.7
class RSASSA_PKCS1v15_SHA256_Signer : public RSASS<PKCS1v15,SHA256>::Signer {};
/// \brief \ref RSASS<STANDARD,HASH> "RSASS<PKCS1v15,SHA256>::Verifier" typedef
/// \details RSA signature schemes defined in PKCS #1 v2.0
/// \since Crypto++ 8.7
class RSASSA_PKCS1v15_SHA256_Verifier : public RSASS<PKCS1v15,SHA256>::Verifier {};
namespace Weak {
/// \brief \ref RSASS<STANDARD,HASH> "RSASS<PKCS1v15, Weak::MD2>::Signer" typedef
@ -250,6 +272,9 @@ class RSASSA_PKCS1v15_MD5_Verifier : public RSASS<PKCS1v15, Weak1::MD5>::Verifie
typedef RSASS<PKCS1v15,SHA1>::Signer RSASSA_PKCS1v15_SHA_Signer;
typedef RSASS<PKCS1v15,SHA1>::Verifier RSASSA_PKCS1v15_SHA_Verifier;
typedef RSASS<PKCS1v15,SHA256>::Signer RSASSA_PKCS1v15_SHA256_Signer;
typedef RSASS<PKCS1v15,SHA256>::Verifier RSASSA_PKCS1v15_SHA256_Verifier;
namespace Weak {
typedef RSASS<PKCS1v15, Weak1::MD2>::Signer RSASSA_PKCS1v15_MD2_Signer;
typedef RSASS<PKCS1v15, Weak1::MD2>::Verifier RSASSA_PKCS1v15_MD2_Verifier;

View File

@ -177,8 +177,15 @@ bool ValidateRSA_Encrypt()
pass = pass && !fail;
}
{
RSAES<OAEP<SHA1> >::Decryptor rsaPriv(GlobalRNG(), 512);
RSAES<OAEP<SHA1> >::Encryptor rsaPub(rsaPriv);
RSAES_OAEP_SHA_Decryptor rsaPriv(GlobalRNG(), 512);
RSAES_OAEP_SHA_Encryptor rsaPub(rsaPriv);
fail = !CryptoSystemValidate(rsaPriv, rsaPub);
pass = pass && !fail;
}
{
RSAES_OAEP_SHA256_Decryptor rsaPriv(GlobalRNG(), 1024);
RSAES_OAEP_SHA256_Encryptor rsaPub(rsaPriv);
fail = !CryptoSystemValidate(rsaPriv, rsaPub);
pass = pass && !fail;