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 (const cRsaPrivateKey &a_Other)
 Deep-copies the key from a_Other. More...
 
 cRsaPrivateKey (void)
 Creates a new empty object, the key is not assigned. More...
 
int Decrypt (ContiguousByteBufferView a_EncryptedData, Byte *a_DecryptedData, size_t a_DecryptedMaxLength)
 Decrypts 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...
 
ContiguousByteBuffer 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() [1/2]

cRsaPrivateKey::cRsaPrivateKey ( void  )

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

Definition at line 12 of file RsaPrivateKey.cpp.

◆ cRsaPrivateKey() [2/2]

cRsaPrivateKey::cRsaPrivateKey ( const cRsaPrivateKey a_Other)

Deep-copies the key from a_Other.

Definition at line 22 of file RsaPrivateKey.cpp.

◆ ~cRsaPrivateKey()

cRsaPrivateKey::~cRsaPrivateKey ( )

Definition at line 33 of file RsaPrivateKey.cpp.

Member Function Documentation

◆ Decrypt()

int cRsaPrivateKey::Decrypt ( ContiguousByteBufferView  a_EncryptedData,
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.

◆ Generate()

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.

◆ GetInternal()

mbedtls_rsa_context* cRsaPrivateKey::GetInternal ( void  )
inlineprotected

Returns the internal context ptr.

Only use in mbedTLS API calls.

Definition at line 54 of file RsaPrivateKey.h.

◆ GetPubKeyDER()

ContiguousByteBuffer 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

◆ cSslContext

friend class cSslContext
friend

Definition at line 22 of file RsaPrivateKey.h.

Member Data Documentation

◆ m_CtrDrbg

cCtrDrbgContext cRsaPrivateKey::m_CtrDrbg
protected

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

Definition at line 50 of file RsaPrivateKey.h.

◆ m_Rsa

mbedtls_rsa_context cRsaPrivateKey::m_Rsa
protected

The mbedTLS key context.

Definition at line 47 of file RsaPrivateKey.h.


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