Diana Software
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
QCryptoRSA Class Reference

fixed-size encryption with the raw RSA algorithm. For envelope see QCryptoRSAEnvelope. More...

Public Types

enum  Mode { ENCRYPT , DECRYPT }
 encrypt or decrypt mode More...
 

Public Member Functions

 QCryptoRSA (const std::string &pKey, const Mode mode, bool nopad=true)
 constructor: if ENCRYPT provide public key, otherwise provide private key More...
 
virtual ~QCryptoRSA ()
 destructor More...
 
size_t GetMessageSize () const
 Get message size = lenght of key - 2. More...
 
std::vector< unsigned char > Process (const std::vector< unsigned char > &message) const
 encrypt or decrypt message More...
 

Static Public Member Functions

static std::vector< unsigned char > ConvertDouble (const double message)
 convert from double More...
 
static double ConvertDouble (const std::vector< unsigned char > &message)
 convert to double More...
 
static std::vector< unsigned char > ConvertString (const std::string &message)
 convert from string More...
 
static std::string ConvertString (const std::vector< unsigned char > &message)
 convert to string More...
 
static std::vector< unsigned char > ConvertHex (const std::string &message)
 convert from hex-string More...
 
static std::string ConvertHex (const std::vector< unsigned char > &message)
 convert to hex-string More...
 

Private Member Functions

unsigned char * ConvertArray (const std::vector< unsigned char > &input, const size_t pad=0, const size_t beginpad=0) const
 
std::vector< unsigned char > ConvertArray (const unsigned char *input, const size_t n) const
 
void Print (const char *header, const unsigned char *data, const size_t n)
 

Private Attributes

Mode fMode
 
RSAfRSA
 
unsigned char * fOutput
 
bool fNoPadding
 
int fMsgLength
 
size_t fRandomSize
 
size_t fBeginPad
 

Detailed Description

fixed-size encryption with the raw RSA algorithm. For envelope see QCryptoRSAEnvelope.

Author
Marco Vignati

Definition at line 18 of file QCryptoRSA.hh.

Member Enumeration Documentation

◆ Mode

encrypt or decrypt mode

Enumerator
ENCRYPT 
DECRYPT 

Definition at line 21 of file QCryptoRSA.hh.

Constructor & Destructor Documentation

◆ QCryptoRSA()

QCryptoRSA::QCryptoRSA ( const std::string &  pKey,
const Mode  mode,
bool  nopad = true 
)

constructor: if ENCRYPT provide public key, otherwise provide private key

◆ ~QCryptoRSA()

QCryptoRSA::~QCryptoRSA ( )
virtual

destructor

Definition at line 69 of file QCryptoRSA.cc.

Member Function Documentation

◆ ConvertArray() [1/2]

unsigned char * QCryptoRSA::ConvertArray ( const std::vector< unsigned char > &  input,
const size_t  pad = 0,
const size_t  beginpad = 0 
) const
private

Definition at line 217 of file QCryptoRSA.cc.

Referenced by Process().

◆ ConvertArray() [2/2]

std::vector< unsigned char > QCryptoRSA::ConvertArray ( const unsigned char *  input,
const size_t  n 
) const
private

Definition at line 234 of file QCryptoRSA.cc.

◆ ConvertDouble() [1/2]

std::vector< unsigned char > QCryptoRSA::ConvertDouble ( const double  message)
static

convert from double

Definition at line 124 of file QCryptoRSA.cc.

◆ ConvertDouble() [2/2]

double QCryptoRSA::ConvertDouble ( const std::vector< unsigned char > &  message)
static

convert to double

Definition at line 135 of file QCryptoRSA.cc.

References DianaThrow, err, and QERR_SIZE_NOT_MATCH.

◆ ConvertHex() [1/2]

std::vector< unsigned char > QCryptoRSA::ConvertHex ( const std::string &  message)
static

convert from hex-string

Definition at line 90 of file QCryptoRSA.cc.

References DianaThrow, err, and QERR_SIZE_NOT_MATCH.

◆ ConvertHex() [2/2]

std::string QCryptoRSA::ConvertHex ( const std::vector< unsigned char > &  message)
static

convert to hex-string

Definition at line 112 of file QCryptoRSA.cc.

◆ ConvertString() [1/2]

std::vector< unsigned char > QCryptoRSA::ConvertString ( const std::string &  message)
static

convert from string

Definition at line 73 of file QCryptoRSA.cc.

◆ ConvertString() [2/2]

std::string QCryptoRSA::ConvertString ( const std::vector< unsigned char > &  message)
static

convert to string

Definition at line 82 of file QCryptoRSA.cc.

◆ GetMessageSize()

size_t QCryptoRSA::GetMessageSize ( ) const
inline

Get message size = lenght of key - 2.

Definition at line 33 of file QCryptoRSA.hh.

References fMsgLength.

◆ Print()

void QCryptoRSA::Print ( const char *  header,
const unsigned char *  data,
const size_t  n 
)
private

Definition at line 244 of file QCryptoRSA.cc.

◆ Process()

std::vector< unsigned char > QCryptoRSA::Process ( const std::vector< unsigned char > &  message) const

encrypt or decrypt message

Definition at line 154 of file QCryptoRSA.cc.

References ConvertArray(), DECRYPT, DianaThrow, ENCRYPT, err, fBeginPad, fMode, fMsgLength, fNoPadding, fOutput, fRandomSize, fRSA, QERR_SIZE_NOT_MATCH, and QERR_UNKNOWN_ERR.

Member Data Documentation

◆ fBeginPad

size_t QCryptoRSA::fBeginPad
private

Definition at line 64 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().

◆ fMode

Mode QCryptoRSA::fMode
private

Definition at line 56 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().

◆ fMsgLength

int QCryptoRSA::fMsgLength
private

Definition at line 62 of file QCryptoRSA.hh.

Referenced by ClassImp(), GetMessageSize(), and Process().

◆ fNoPadding

bool QCryptoRSA::fNoPadding
private

Definition at line 61 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().

◆ fOutput

unsigned char* QCryptoRSA::fOutput
private

Definition at line 60 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().

◆ fRandomSize

size_t QCryptoRSA::fRandomSize
private

Definition at line 63 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().

◆ fRSA

RSA* QCryptoRSA::fRSA
private

Definition at line 58 of file QCryptoRSA.hh.

Referenced by ClassImp(), and Process().


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