Poco::Crypto

class RSAKeyImpl

File Information

Library: Crypto
Package: RSA
Header: Poco/Crypto/RSAKeyImpl.h

Description

class RSAKeyImpl

Inheritance

Direct Base Classes: KeyPairImpl

All Base Classes: KeyPairImpl, Poco::RefCountedObject

Member Summary

Member Functions: decryptionExponent, encryptionExponent, getRSA, modulus, save, size

Inherited Functions: duplicate, name, referenceCount, release, save, size, type

Types Aliases

ByteVec

using ByteVec = std::vector < unsigned char >;

Ptr

using Ptr = Poco::AutoPtr < RSAKeyImpl >;

Constructors

RSAKeyImpl

RSAKeyImpl(
    const EVPPKey & key
);

Constructs RSAKeyImpl by extracting the RSA key.

RSAKeyImpl

RSAKeyImpl(
    const X509Certificate & cert
);

Extracts the RSA public key from the given certificate.

RSAKeyImpl

RSAKeyImpl(
    const PKCS12Container & cert
);

Extracts the RSA private key from the given certificate.

RSAKeyImpl

RSAKeyImpl(
    int keyLength,
    unsigned long exponent
);

Creates the RSAKey. Creates a new public/private keypair using the given parameters. Can be used to sign data and verify signatures.

RSAKeyImpl

RSAKeyImpl(
    const std::string & publicKeyFile,
    const std::string & privateKeyFile,
    const std::string & privateKeyPassphrase
);

Creates the RSAKey, by reading public and private key from the given files and using the given passphrase for the private key. Can only by used for signing if a private key is available.

RSAKeyImpl

RSAKeyImpl(
    std::istream * pPublicKeyStream,
    std::istream * pPrivateKeyStream,
    const std::string & privateKeyPassphrase
);

Creates the RSAKey. Can only by used for signing if pPrivKey is not null. If a private key file is specified, you don't need to specify a public key file. OpenSSL will auto-create it from the private key.

Destructor

~RSAKeyImpl virtual

~RSAKeyImpl();

Destroys the RSAKeyImpl.

Member Functions

decryptionExponent

ByteVec decryptionExponent() const;

Returns the RSA decryption exponent.

encryptionExponent

ByteVec encryptionExponent() const;

Returns the RSA encryption exponent.

getRSA inline

RSA * getRSA();

Returns the OpenSSL RSA object.

getRSA

const RSA * getRSA() const;

Returns the OpenSSL RSA object.

modulus

ByteVec modulus() const;

Returns the RSA modulus.

save virtual

void save(
    const std::string & publicKeyFile,
    const std::string & privateKeyFile = "",
    const std::string & privateKeyPassphrase = ""
) const;

Exports the public and private keys to the given files.

If an empty filename is specified, the corresponding key is not exported.

save virtual

void save(
    std::ostream * pPublicKeyStream,
    std::ostream * pPrivateKeyStream = 0,
    const std::string & privateKeyPassphrase = ""
) const;

Exports the public and private key to the given streams.

If a null pointer is passed for a stream, the corresponding key is not exported.

size virtual

int size() const;

Returns the RSA modulus size.