Mayaqua: Add new cryptographic functions for X25519/X448 keys management

The files are created in a new folder to keep the source tree tidier.

Please note that only X25519/X448 keys are supported due to an OpenSSL limitation:
https://www.openssl.org/docs/manmaster/man3/EVP_PKEY_new.html

We have functions that handle AES keys in Encrypt.c/.h.
Ideally we should move them into the new files.
This commit is contained in:
Davide Beatrici committed 2021-07-07 08:11:08 +02:00
1 parent 4328e6e5ab
commit 9dbbfcd388
5 files changed
+269 -2

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#ifndef CRYPTO_KEY_H
#define CRYPTO_KEY_H
#include "MayaType.h"
#define KEY_X25519_SIZE 32
#define KEY_X448_SIZE 56
enum CRYPTO_KEY_TYPE
{
KEY_UNKNOWN,
KEY_X25519,
KEY_X448
};
struct CRYPTO_KEY_RAW
{
BYTE *Data;
UINT Size;
CRYPTO_KEY_TYPE Type;
};
UINT CryptoKeyTypeSize(const CRYPTO_KEY_TYPE type);
CRYPTO_KEY_RAW *CryptoKeyRawNew(const void *data, const UINT size, const CRYPTO_KEY_TYPE type);
void CryptoKeyRawFree(CRYPTO_KEY_RAW *key);
CRYPTO_KEY_RAW *CryptoKeyRawPublic(const CRYPTO_KEY_RAW *private);
void *CryptoKeyRawToOpaque(const CRYPTO_KEY_RAW *key, const bool public);
void *CryptoKeyOpaqueNew(const CRYPTO_KEY_TYPE type);
void CryptoKeyOpaqueFree(void *key);
bool CryptoKeyOpaqueToRaw(const void *opaque, CRYPTO_KEY_RAW **private, CRYPTO_KEY_RAW **public);
#endif