MIRA
Public Types | Friends | List of all members
RSASignature Class Reference

A class for signing and verifying messages using a RSA key pair. More...

#include <security/RSASignature.h>

Public Types

enum  DigestType { DIGEST_MD5, DIGEST_SHA1, DIGEST_SHA256, DIGEST_SHA512 }
 The digest type. More...
 

Public Member Functions

Constuctors and destructor
 RSASignature ()
 Default constructor. More...
 
 RSASignature (const RSASignature &signatur)
 The copy constructor. More...
 
virtual ~RSASignature ()
 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)
 
Operators
RSASignatureoperator= (const RSASignature &signature)
 The '=' operator. More...
 
Message signature information
size_t getSize () const
 Return the size of the RSA signature. More...
 
const uint8 * getSignature () const
 Return the signature in a binary format. More...
 

Static Public Member Functions

Sign and verify a message
static RSASignature signMessage (const RSAKey &iPrivateKey, DigestType iDigestType, const char *iMsg, size_t iMsgLen)
 Sign a message based on the private RSA key of the sender. More...
 
static bool verifyMessage (const RSAKey &iPublicKey, DigestType iDigestType, const char *iMsg, size_t iMsgLen, const RSASignature &iSignature)
 Verify a message signature based on the public RSA of the sender. More...
 

Friends

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

Detailed Description

A class for signing and verifying messages using a RSA key pair.

Member Enumeration Documentation

◆ DigestType

enum DigestType

The digest type.

Enumerator
DIGEST_MD5 
DIGEST_SHA1 
DIGEST_SHA256 
DIGEST_SHA512 

Constructor & Destructor Documentation

◆ RSASignature() [1/2]

Default constructor.

◆ RSASignature() [2/2]

RSASignature ( const RSASignature signatur)

The copy constructor.

◆ ~RSASignature()

virtual ~RSASignature ( )
virtual

The destructor.

Member Function Documentation

◆ reflectRead()

MIRA_SPLIT_REFLECT_MEMBER void reflectRead ( Reflector &  r)
inline

Reflect.

◆ reflectWrite()

void reflectWrite ( Reflector &  r)
inline

◆ operator=()

RSASignature& operator= ( const RSASignature signature)

The '=' operator.

◆ getSize()

size_t getSize ( ) const
inline

Return the size of the RSA signature.

◆ getSignature()

const uint8* getSignature ( ) const
inline

Return the signature in a binary format.

◆ signMessage()

static RSASignature signMessage ( const RSAKey iPrivateKey,
DigestType  iDigestType,
const char *  iMsg,
size_t  iMsgLen 
)
static

Sign a message based on the private RSA key of the sender.

Parameters
[in]iPrivateKeyThe private RSA key of the sender.
[in]iDigestTypeThe digest algorithm.
[in]iMsgThe message itself.
[in]iMsgLenThe size of the message.
Returns
The RSA signature of the message.

◆ verifyMessage()

static bool verifyMessage ( const RSAKey iPublicKey,
DigestType  iDigestType,
const char *  iMsg,
size_t  iMsgLen,
const RSASignature iSignature 
)
static

Verify a message signature based on the public RSA of the sender.

Parameters
[in]iPublicKeyThe public RSA key of the sender.
[in]iDigestTypeThe digest algorithm.
[in]iMsgThe message itself.
[in]iMsgLenThe size of the message.
[in]iSignatureThe signature of the message.
Returns
True, if the message was verified successfully.

Friends And Related Function Documentation

◆ operator<<

MIRA_BASE_EXPORT std::ostream& operator<< ( std::ostream &  stream,
const RSASignature signature 
)
friend

The '<<' operator for RSASignature.

Format: HexData

◆ operator>>

MIRA_BASE_EXPORT std::istream& operator>> ( std::istream &  stream,
RSASignature signature 
)
friend

The '>>' operator for RSASignature.


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