Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Encapsulates an RSA private key used in PKI cryptography. More...
#include <RsaPrivateKey.h>
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 |
Encapsulates an RSA private key used in PKI cryptography.
Definition at line 20 of file RsaPrivateKey.h.
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.
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.
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.
|
inlineprotected |
Returns the internal context ptr.
Only use in mbedTLS API calls.
Definition at line 54 of file RsaPrivateKey.h.
ContiguousByteBuffer cRsaPrivateKey::GetPubKeyDER | ( | void | ) |
Returns the public key part encoded in ASN1 DER encoding.
Definition at line 58 of file RsaPrivateKey.cpp.
|
friend |
Definition at line 22 of file RsaPrivateKey.h.
|
protected |
The random generator used for generating the key and encryption / decryption.
Definition at line 50 of file RsaPrivateKey.h.
|
protected |
The mbedTLS key context.
Definition at line 47 of file RsaPrivateKey.h.