RSA class. More...

#include <rsa.h>

Static Public Member Functions

static void create_keypair (Random &random, Secret &out_private_exponent, DataBuffer &out_public_exponent, DataBuffer &out_modulus, int key_size_in_bits=1024, int public_exponent_value=65537)
 Create a keypair. More...
 
static Secret decrypt (const Secret &in_private_exponent, const DataBuffer &in_modulus, const DataBuffer &in_data)
 Decrypt. More...
 
static Secret decrypt (const Secret &in_private_exponent, const void *in_modulus, unsigned int in_modulus_size, const void *in_data, unsigned int in_data_size)
 Decrypt. More...
 
static DataBuffer encrypt (int block_type, Random &random, const DataBuffer &in_public_exponent, const DataBuffer &in_modulus, const Secret &in_data)
 Encrypt. More...
 
static DataBuffer encrypt (int block_type, Random &random, const void *in_public_exponent, unsigned int in_public_exponent_size, const void *in_modulus, unsigned int in_modulus_size, const void *in_data, unsigned int in_data_size)
 Encrypt. More...
 

Detailed Description

RSA class.

Important: This class has NOT been tested thoroughly by a cryptography expert.

Member Function Documentation

static void clan::RSA::create_keypair ( Random random,
Secret out_private_exponent,
DataBuffer out_public_exponent,
DataBuffer out_modulus,
int  key_size_in_bits = 1024,
int  public_exponent_value = 65537 
)
static

Create a keypair.

Parameters
random= Random number generator
out_private_exponent= Private exponent (to decrypt with)
out_public_exponent= Public exponent (to encrypt with)
out_modulus= Modulus
key_size_in_bits= key size in bits
public_exponent_value= public exponent value
static Secret clan::RSA::decrypt ( const Secret in_private_exponent,
const DataBuffer in_modulus,
const DataBuffer in_data 
)
static

Decrypt.

Warning: An exception may be thrown when decrypting if in_data is not valid. Be careful handling this, to prevent "timing attacks"

Parameters
in_private_exponent= Private exponent
in_modulus= Modulus
in_data= Data to decrypt (length equals in_modulus.get_size())
Returns
Decrypted data
static Secret clan::RSA::decrypt ( const Secret in_private_exponent,
const void *  in_modulus,
unsigned int  in_modulus_size,
const void *  in_data,
unsigned int  in_data_size 
)
static

Decrypt.

Warning: An exception may be thrown when decrypting if in_data is not valid. Be careful handling this, to prevent "timing attacks"

Parameters
in_private_exponent= Private exponent
in_modulus= Modulus
in_modulus_size= size in bytes of in_modulus
in_data= Data to encrypt
in_data_size= size in bytes of in_data (length equals in_modulus_size)
Returns
Decrypted data
static DataBuffer clan::RSA::encrypt ( int  block_type,
Random random,
const DataBuffer in_public_exponent,
const DataBuffer in_modulus,
const Secret in_data 
)
static

Encrypt.

Parameters
block_type= 0 (private key), 1 (private key) or 2 (public key)
random= Random number generator
in_public_exponent= Public exponent
in_modulus= Modulus
in_data= Data to encrypt (maximum length is in_modulus.get_size() - 11)
Returns
Encrypted data
static DataBuffer clan::RSA::encrypt ( int  block_type,
Random random,
const void *  in_public_exponent,
unsigned int  in_public_exponent_size,
const void *  in_modulus,
unsigned int  in_modulus_size,
const void *  in_data,
unsigned int  in_data_size 
)
static

Encrypt.

Parameters
block_type= 0 (private key), 1 (private key) or 2 (public key)
random= Random number generator
in_public_exponent= Public exponent
in_public_exponent_size= size in bytes of in_public_exponent
in_modulus= Modulus
in_modulus_size= size in bytes of in_modulus
in_data= Data to encrypt
in_data_size= size in bytes of in_data (maximum size is in_modulus_size - 11)
Returns
Encrypted data

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