9#ifndef BOTAN_P11_RSA_H_ 
   10#define BOTAN_P11_RSA_H_ 
   12#include <botan/bigint.h> 
   13#include <botan/p11_object.h> 
   14#include <botan/p11_types.h> 
   15#include <botan/pk_keys.h> 
   17#if defined(BOTAN_HAS_RSA) 
   18   #include <botan/rsa.h> 
   27      explicit RSA_PublicKeyGenerationProperties(Ulong bits);
 
   30      inline void set_pub_exponent(
const BigInt& pub_exponent = BigInt::from_word(0x10001)) {
 
   31         add_binary(AttributeType::PublicExponent, pub_exponent.serialize());
 
   40      RSA_PublicKeyImportProperties(
const BigInt& modulus, 
const BigInt& pub_exponent);
 
   43      inline const BigInt& modulus()
 const { 
return m_modulus; }
 
   46      inline const BigInt& pub_exponent()
 const { 
return m_pub_exponent; }
 
   49      const BigInt m_modulus;
 
   50      const BigInt m_pub_exponent;
 
   55                                                    public RSA_PublicKey {
 
   64      PKCS11_RSA_PublicKey(Session& session, ObjectHandle handle);
 
   71      PKCS11_RSA_PublicKey(Session& session, 
const RSA_PublicKeyImportProperties& pubkey_props);
 
   76      std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& ) 
const final {
 
   77         throw Not_Implemented(
"Cannot generate a new PKCS#11 RSA keypair from this public key");
 
   80      std::unique_ptr<PK_Ops::Encryption> create_encryption_op(RandomNumberGenerator& rng,
 
   81                                                               std::string_view params,
 
   82                                                               std::string_view provider) 
const override;
 
   84      std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
 
   85                                                                   std::string_view provider) 
const override;
 
   95      RSA_PrivateKeyImportProperties(
const BigInt& modulus, 
const BigInt& priv_exponent);
 
   98      inline void set_pub_exponent(
const BigInt& pub_exponent) {
 
   99         add_binary(AttributeType::PublicExponent, pub_exponent.serialize());
 
  103      inline void set_prime_1(
const BigInt& prime1) { add_binary(AttributeType::Prime1, prime1.serialize()); }
 
  106      inline void set_prime_2(
const BigInt& prime2) { add_binary(AttributeType::Prime2, prime2.serialize()); }
 
  109      inline void set_exponent_1(
const BigInt& exp1) { add_binary(AttributeType::Exponent1, exp1.serialize()); }
 
  112      inline void set_exponent_2(
const BigInt& exp2) { add_binary(AttributeType::Exponent2, exp2.serialize()); }
 
  115      inline void set_coefficient(
const BigInt& coeff) { add_binary(AttributeType::Coefficient, coeff.serialize()); }
 
  118      inline const BigInt& modulus()
 const { 
return m_modulus; }
 
  121      inline const BigInt& priv_exponent()
 const { 
return m_priv_exponent; }
 
  124      const BigInt m_modulus;
 
  125      const BigInt m_priv_exponent;
 
  131      RSA_PrivateKeyGenerationProperties() : PrivateKeyProperties(
KeyType::
Rsa) {}
 
  141                                                           public RSA_PublicKey {
 
  146      PKCS11_RSA_PrivateKey(Session& session, ObjectHandle handle);
 
  153      PKCS11_RSA_PrivateKey(Session& session, 
const RSA_PrivateKeyImportProperties& priv_key_props);
 
  162      PKCS11_RSA_PrivateKey(Session& session, uint32_t bits, 
const RSA_PrivateKeyGenerationProperties& priv_key_props);
 
  165      RSA_PrivateKey export_key() 
const;
 
  174      void set_use_software_padding(
bool software_padding) { m_use_software_padding = software_padding; }
 
  176      bool uses_software_padding()
 const { 
return m_use_software_padding; }
 
  178      secure_vector<uint8_t> private_key_bits() 
const override;
 
  180      std::unique_ptr<Public_Key> public_key() 
const override;
 
  182      std::unique_ptr<PK_Ops::Decryption> create_decryption_op(RandomNumberGenerator& rng,
 
  183                                                               std::string_view params,
 
  184                                                               std::string_view provider) 
const override;
 
  186      std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
 
  187                                                             std::string_view params,
 
  188                                                             std::string_view provider) 
const override;
 
  191      bool m_use_software_padding = 
false;
 
  196using PKCS11_RSA_KeyPair = std::pair<PKCS11_RSA_PublicKey, PKCS11_RSA_PrivateKey>;
 
  205PKCS11_RSA_KeyPair generate_rsa_keypair(
Session& session,
 
  206                                        const RSA_PublicKeyGenerationProperties& pub_props,
 
  207                                        const RSA_PrivateKeyGenerationProperties& priv_props);
 
#define BOTAN_DIAGNOSTIC_POP
 
#define BOTAN_DIAGNOSTIC_PUSH
 
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
 
#define BOTAN_PUBLIC_API(maj, min)
 
Common attributes of all private keys.
 
Common attributes of all public key objects.
 
Represents a PKCS#11 session.