|
Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
The crypto namespace. More...
Classes | |
| class | AES128CFB8Cipher |
| AES/CFB8 128bit cipher class. More... | |
| class | MinecraftHash |
| The Minecraft Hashing class. More... | |
| class | ZLibCompressor |
| ZLib compressor. More... | |
Enumerations | |
| enum | CipherState { DECRYPT , ENCRYPT } |
| Possible cipher states. More... | |
Functions | |
| bool | init () |
| Inits Crypto. | |
| void | cleanup () |
| Cleanups Crypto. | |
| std::unique_ptr< std::byte[]> | rsaEncrypt (const std::byte *data, size_t len, size_t *outLen) |
| Encrypts data using the server's RSA keypair. | |
| std::unique_ptr< std::byte[]> | rsaDecrypt (const std::byte *data, size_t len, size_t *outLen) |
| Decrypts data using the server's RSA keypair. | |
| std::unique_ptr< std::byte[]> | getPublicRSAKey (int *outLen) |
| Get the Public RSA Public Key. | |
| std::unique_ptr< std::byte[]> | randomSecure (size_t len) |
| Generates randoms bytes securely. | |
| std::string | md5Digest (const std::string &data) |
| MD5 digests a string. | |
Variables | |
| constexpr int | RSA_KEY_LENGTH = 1024 |
| The length of the rsa keys. | |
The crypto namespace.
The namespace containing all of the crypto-related utilities functions.
Possible cipher states.
Enum containing the possibilities of what could do a cipher, to not have to create 2 separate classes.
| void crypto::cleanup | ( | ) |
Cleanups Crypto.
Cleanups the bloat that was created when starting OpenSSL, including the RSA keypair
| std::unique_ptr< std::byte[]> crypto::getPublicRSAKey | ( | int * | outLen | ) |
Get the Public RSA Public Key.
Formats the public key from the startup keypair into DER format, which is an underlying ASN.1 format defined by x.509
| outLen | a pointer to a variable that will hold the length of the key returned |
| bool crypto::init | ( | ) |
Inits Crypto.
Inits OpenSSL and generates an RSA Keypair to be used in encryption.
| std::string crypto::md5Digest | ( | const std::string & | data | ) |
MD5 digests a string.
Returns an MD5 digest of the data given, really used just for MinecraftUUID creation from Player's usernames
| data | the data to digest |
| std::unique_ptr< std::byte[]> crypto::randomSecure | ( | size_t | len | ) |
Generates randoms bytes securely.
Generates len bytes in a secure way, which just means we let OpenSSL do the heavy lifting.
| len | the size of the bytes to generate |
| std::unique_ptr< std::byte[]> crypto::rsaDecrypt | ( | const std::byte * | data, |
| size_t | len, | ||
| size_t * | outLen ) |
Decrypts data using the server's RSA keypair.
Decrypts len of data and returns it as a unique pointer to the decrypted data of length outLen The keypair used is generated at startup in crypto::init(). It uses RSA PKCS1 padding.
| data | The data to decrypt |
| len | The length of the data to decrypt |
| outLen | A pointer to a variable that will store the encrypted data length |
| std::unique_ptr< std::byte[]> crypto::rsaEncrypt | ( | const std::byte * | data, |
| size_t | len, | ||
| size_t * | outLen ) |
Encrypts data using the server's RSA keypair.
Encrypts len of data and returns it as a unique pointer to the encrypted data of length outLen The keypair used is generated at startup in crypto::init(). It uses RSA PKCS1 padding.
| data | The data to encrypt |
| len | The length of the data to encrypt |
| outLen | A pointer to a variable that will store the encrypted data length |