MIRA
Friends | List of all members
RSAKey Class Reference

Definition of a RSA key (public or private) More...

#include <security/RSAKey.h>

Public Member Functions

Constructors and destructor
 RSAKey ()
 Default constructor. More...
 
 RSAKey (const RSAKey &key)
 The copy constructor. More...
 
 RSAKey (const std::string &n, const std::string &e, const std::string &d)
 Construct a new RSAKey with specific N, E and D (all in hex). More...
 
virtual ~ RSAKey ()
 The destructor. More...
 
Reflect operation
template<typename Reflector >
MIRA_SPLIT_REFLECT_MEMBER void reflectRead (Reflector &r)
 Reflect. More...
 
template<typename Reflector >
void reflectWrite (Reflector &r)
 
General operations
bool isValid () const
 Is this a valid key? More...
 
bool isPublicKey () const
 Is this a public key? More...
 
bool isPrivateKey () const
 Is this a private key? More...
 
bool clear ()
 Clear the key values. More...
 
Operators
RSAKeyoperator= (const RSAKey &key)
 The '=' operator. More...
 
bool operator== (const RSAKey &key)
 The '==' operator. More...
 
bool operator!= (const RSAKey &key)
 The '!=' operator. More...
 
Accessing the key components
const OpenSSLRSAWrapper * getOpenSSLKey () const
 Return a pointer to the OpenSSL RSA key wrapper. More...
 
std::string getNStr () const
 Get N as a hexadecimal number. More...
 
std::string getEStr () const
 Get E as a hexadecimal number. More...
 
std::string getDStr () const
 Get D as a hexadecimal number. More...
 

Static Public Member Functions

Static methods
static void generateKey (unsigned int iKeyBitLength, RSAKey &oPublicKey, RSAKey &oPrivateKey)
 Generate a new RSA key. More...
 
static void feedRandomNumberGenerator (size_t count)
 Feed the random number generator. More...
 

Friends

MIRA_BASE_EXPORT std::ostream & operator<< (std::ostream &stream, const RSAKey &key)
 The '<<' operator for RSAKey. More...
 
MIRA_BASE_EXPORT std::istream & operator>> (std::istream &stream, RSAKey &key)
 The '>>' operator for RSAKey. More...
 

Detailed Description

Definition of a RSA key (public or private)

Constructor & Destructor Documentation

◆ RSAKey() [1/3]

RSAKey ( )

Default constructor.

◆ RSAKey() [2/3]

RSAKey ( const RSAKey key)

The copy constructor.

◆ RSAKey() [3/3]

RSAKey ( const std::string &  n,
const std::string &  e,
const std::string &  d 
)

Construct a new RSAKey with specific N, E and D (all in hex).

◆ ~ RSAKey()

virtual ~ RSAKey ( )

The destructor.

Member Function Documentation

◆ reflectRead()

MIRA_SPLIT_REFLECT_MEMBER void reflectRead ( Reflector &  r)
inline

Reflect.

◆ reflectWrite()

void reflectWrite ( Reflector &  r)
inline

◆ isValid()

bool isValid ( ) const

Is this a valid key?

◆ isPublicKey()

bool isPublicKey ( ) const

Is this a public key?

◆ isPrivateKey()

bool isPrivateKey ( ) const

Is this a private key?

◆ clear()

bool clear ( )

Clear the key values.

◆ operator=()

RSAKey& operator= ( const RSAKey key)

The '=' operator.

◆ operator==()

bool operator== ( const RSAKey key)

The '==' operator.

◆ operator!=()

bool operator!= ( const RSAKey key)

The '!=' operator.

◆ getOpenSSLKey()

const OpenSSLRSAWrapper* getOpenSSLKey ( ) const
inline

Return a pointer to the OpenSSL RSA key wrapper.

◆ getNStr()

std::string getNStr ( ) const

Get N as a hexadecimal number.

◆ getEStr()

std::string getEStr ( ) const

Get E as a hexadecimal number.

◆ getDStr()

std::string getDStr ( ) const

Get D as a hexadecimal number.

◆ generateKey()

static void generateKey ( unsigned int  iKeyBitLength,
RSAKey oPublicKey,
RSAKey oPrivateKey 
)
static

Generate a new RSA key.

Parameters
[in]iKeyBitLengthNumber of bits (must be greater than 127).
[out]oPublicKeyThe public key.
[out]oPrivateKeyThe private key.

◆ feedRandomNumberGenerator()

static void feedRandomNumberGenerator ( size_t  count)
static

Feed the random number generator.

Parameters
[in]countThe number for random bytes.

Friends And Related Function Documentation

◆ operator<<

MIRA_BASE_EXPORT std::ostream& operator<< ( std::ostream &  stream,
const RSAKey key 
)
friend

The '<<' operator for RSAKey.

Public keys: "PUBLIC:Len:HexData;"

Private keys: "PRIVATE:Len:HexData;"

◆ operator>>

MIRA_BASE_EXPORT std::istream& operator>> ( std::istream &  stream,
RSAKey key 
)
friend

The '>>' operator for RSAKey.


The documentation for this class was generated from the following file: