Class Poco::Crypto::RSAKeyImpl
Author: Applied Informatics Software Engineering GmbH and Contributors
Date: 2009-11-24

# Poco::Crypto

# class RSAKeyImpl

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

## Description

class RSAKeyImpl

## Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

## Member Summary

Member Functions: getRSA, save, size

Inherited Functions: duplicate, referenceCount, release

## Types

### Ptr

typedef Poco::AutoPtr < RSAKeyImpl > Ptr;

## Constructors

### RSAKeyImpl

explicit RSAKeyImpl(
const X509Certificate & cert
);

Extracts the RSA public 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

~RSAKeyImpl();

Destroys the RSAKeyImpl.

## Member Functions

### getRSA

RSA * getRSA();

Returns the OpenSSL RSA object.

### getRSA

const RSA * getRSA() const;

Returns the OpenSSL RSA object.

### save

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

Exports the public and private keys to the given files.

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

### save

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

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

int size() const;

Returns the RSA modulus size.