Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cRsaPrivateKey Class Reference

Encapsulates an RSA private key used in PKI cryptography. More...

#include <RsaPrivateKey.h>

Collaboration diagram for cRsaPrivateKey:
Collaboration graph
[legend]

Public Member Functions

 cRsaPrivateKey (void)
 Creates a new empty object, the key is not assigned. More...
 
 cRsaPrivateKey (const cRsaPrivateKey &a_Other)
 Deep-copies the key from a_Other. More...
 
int Decrypt (const Byte *a_EncryptedData, size_t a_EncryptedLength, Byte *a_DecryptedData, size_t a_DecryptedMaxLength)
 Decrypts the data using RSAES-PKCS#1 algorithm. More...
 
int Encrypt (const Byte *a_PlainData, size_t a_PlainLength, Byte *a_EncryptedData, size_t a_EncryptedMaxLength)
 Encrypts the data using RSAES-PKCS#1 algorithm. More...
 
bool Generate (unsigned a_KeySizeBits=1024)
 Generates a new key within this object, with the specified size in bits. More...
 
AString GetPubKeyDER (void)
 Returns the public key part encoded in ASN1 DER encoding. More...
 
 ~cRsaPrivateKey ()
 

Protected Member Functions

mbedtls_rsa_context * GetInternal (void)
 Returns the internal context ptr. More...
 

Protected Attributes

cCtrDrbgContext m_CtrDrbg
 The random generator used for generating the key and encryption / decryption. More...
 
mbedtls_rsa_context m_Rsa
 The mbedTLS key context. More...
 

Friends

class cSslContext
 

Detailed Description

Encapsulates an RSA private key used in PKI cryptography.

Definition at line 20 of file RsaPrivateKey.h.

Constructor & Destructor Documentation

cRsaPrivateKey::cRsaPrivateKey ( void  )

Creates a new empty object, the key is not assigned.

Definition at line 12 of file RsaPrivateKey.cpp.

cRsaPrivateKey::cRsaPrivateKey ( const cRsaPrivateKey a_Other)

Deep-copies the key from a_Other.

Definition at line 22 of file RsaPrivateKey.cpp.

cRsaPrivateKey::~cRsaPrivateKey ( )

Definition at line 33 of file RsaPrivateKey.cpp.

Member Function Documentation

int cRsaPrivateKey::Decrypt ( const Byte a_EncryptedData,
size_t  a_EncryptedLength,
Byte a_DecryptedData,
size_t  a_DecryptedMaxLength 
)

Decrypts the data using RSAES-PKCS#1 algorithm.

Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large. Returns the number of bytes decrypted, or negative number for error.

Definition at line 108 of file RsaPrivateKey.cpp.

int cRsaPrivateKey::Encrypt ( const Byte a_PlainData,
size_t  a_PlainLength,
Byte a_EncryptedData,
size_t  a_EncryptedMaxLength 
)

Encrypts the data using RSAES-PKCS#1 algorithm.

Both a_EncryptedData and a_DecryptedData must be at least <KeySizeBytes> bytes large. Returns the number of bytes decrypted, or negative number for error.

Definition at line 142 of file RsaPrivateKey.cpp.

bool cRsaPrivateKey::Generate ( unsigned  a_KeySizeBits = 1024)

Generates a new key within this object, with the specified size in bits.

Returns true on success, false on failure.

Definition at line 42 of file RsaPrivateKey.cpp.

mbedtls_rsa_context* cRsaPrivateKey::GetInternal ( void  )
inlineprotected

Returns the internal context ptr.

Only use in mbedTLS API calls.

Definition at line 59 of file RsaPrivateKey.h.

AString cRsaPrivateKey::GetPubKeyDER ( void  )

Returns the public key part encoded in ASN1 DER encoding.

Definition at line 58 of file RsaPrivateKey.cpp.

Friends And Related Function Documentation

friend class cSslContext
friend

Definition at line 22 of file RsaPrivateKey.h.

Member Data Documentation

cCtrDrbgContext cRsaPrivateKey::m_CtrDrbg
protected

The random generator used for generating the key and encryption / decryption.

Definition at line 55 of file RsaPrivateKey.h.

mbedtls_rsa_context cRsaPrivateKey::m_Rsa
protected

The mbedTLS key context.

Definition at line 52 of file RsaPrivateKey.h.


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