123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- #ifndef MC_CRYPTO_API_H
- #define MC_CRYPTO_API_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct CRYPT_MD5_CTX {
- int holder[28];
- } CRYPT_MD5_CTX;
- int CRYPT_MD5_Initialize(CRYPT_MD5_CTX*);
- int CRYPT_MD5_DataAdd(CRYPT_MD5_CTX*, const unsigned char*, unsigned int);
- int CRYPT_MD5_Finalize(CRYPT_MD5_CTX*, unsigned char*);
- int CRYPT_MD5_DataSizeSet(CRYPT_MD5_CTX* md5, unsigned int sz);
- enum {
- CRYPT_MD5_DIGEST_SIZE = 16
- };
- typedef struct CRYPT_SHA_CTX {
- int holder[29];
- } CRYPT_SHA_CTX;
- int CRYPT_SHA_Initialize(CRYPT_SHA_CTX*);
- int CRYPT_SHA_DataAdd(CRYPT_SHA_CTX*, const unsigned char*, unsigned int);
- int CRYPT_SHA_Finalize(CRYPT_SHA_CTX*, unsigned char*);
- int CRYPT_SHA_DataSizeSet(CRYPT_SHA_CTX* sha, unsigned int sz);
- enum {
- CRYPT_SHA_DIGEST_SIZE = 20
- };
- typedef struct CRYPT_SHA256_CTX {
- int holder[32];
- } CRYPT_SHA256_CTX;
- int CRYPT_SHA256_Initialize(CRYPT_SHA256_CTX*);
- int CRYPT_SHA256_DataAdd(CRYPT_SHA256_CTX*, const unsigned char*, unsigned int);
- int CRYPT_SHA256_Finalize(CRYPT_SHA256_CTX*, unsigned char*);
- int CRYPT_SHA256_DataSizeSet(CRYPT_SHA256_CTX* sha256, unsigned int sz);
- enum {
- CRYPT_SHA256_DIGEST_SIZE = 32
- };
- typedef struct CRYPT_SHA384_CTX {
- long long holder[36];
- } CRYPT_SHA384_CTX;
- int CRYPT_SHA384_Initialize(CRYPT_SHA384_CTX*);
- int CRYPT_SHA384_DataAdd(CRYPT_SHA384_CTX*, const unsigned char*, unsigned int);
- int CRYPT_SHA384_Finalize(CRYPT_SHA384_CTX*, unsigned char*);
- enum {
- CRYPT_SHA384_DIGEST_SIZE = 48
- };
- typedef struct CRYPT_SHA512_CTX {
- long long holder[36];
- } CRYPT_SHA512_CTX;
- int CRYPT_SHA512_Initialize(CRYPT_SHA512_CTX*);
- int CRYPT_SHA512_DataAdd(CRYPT_SHA512_CTX*, const unsigned char*, unsigned int);
- int CRYPT_SHA512_Finalize(CRYPT_SHA512_CTX*, unsigned char*);
- enum {
- CRYPT_SHA512_DIGEST_SIZE = 64
- };
- typedef struct CRYPT_HMAC_CTX {
-
- #ifdef WOLF_PRIVATE_KEY_ID
- long long holder[108];
- #else
- long long holder[98];
- #endif
- } CRYPT_HMAC_CTX;
- int CRYPT_HMAC_SetKey(CRYPT_HMAC_CTX*, int, const unsigned char*, unsigned int);
- int CRYPT_HMAC_DataAdd(CRYPT_HMAC_CTX*, const unsigned char*, unsigned int);
- int CRYPT_HMAC_Finalize(CRYPT_HMAC_CTX*, unsigned char*);
- enum {
- CRYPT_HMAC_SHA = 4,
- CRYPT_HMAC_SHA256 = 6,
- CRYPT_HMAC_SHA384 = 7,
- CRYPT_HMAC_SHA512 = 8
- };
- int CRYPT_HUFFMAN_Compress(unsigned char*, unsigned int, const unsigned char*,
- unsigned int, unsigned int);
- int CRYPT_HUFFMAN_DeCompress(unsigned char*, unsigned int, const unsigned char*,
- unsigned int);
- enum {
- CRYPT_HUFFMAN_COMPRESS_STATIC = 1
- };
- typedef struct CRYPT_RNG_CTX {
- int holder[66];
- } CRYPT_RNG_CTX;
- int CRYPT_RNG_Initialize(CRYPT_RNG_CTX*);
- int CRYPT_RNG_Get(CRYPT_RNG_CTX*, unsigned char*);
- int CRYPT_RNG_BlockGenerate(CRYPT_RNG_CTX*, unsigned char*, unsigned int);
- typedef struct CRYPT_TDES_CTX {
- int holder[104];
- } CRYPT_TDES_CTX;
- int CRYPT_TDES_KeySet(CRYPT_TDES_CTX*, const unsigned char*,
- const unsigned char*, int);
- int CRYPT_TDES_IvSet(CRYPT_TDES_CTX*, const unsigned char*);
- int CRYPT_TDES_CBC_Encrypt(CRYPT_TDES_CTX*, unsigned char*,
- const unsigned char*, unsigned int);
- int CRYPT_TDES_CBC_Decrypt(CRYPT_TDES_CTX*, unsigned char*,
- const unsigned char*, unsigned int);
- enum {
- CRYPT_TDES_ENCRYPTION = 0,
- CRYPT_TDES_DECRYPTION = 1
- };
- typedef struct CRYPT_AES_CTX {
-
- #ifdef WOLF_PRIVATE_KEY_ID
- int holder[110];
- #else
- int holder[92];
- #endif
- } CRYPT_AES_CTX;
- int CRYPT_AES_KeySet(CRYPT_AES_CTX*, const unsigned char*, unsigned int,
- const unsigned char*, int);
- int CRYPT_AES_IvSet(CRYPT_AES_CTX*, const unsigned char*);
- int CRYPT_AES_CBC_Encrypt(CRYPT_AES_CTX*, unsigned char*,
- const unsigned char*, unsigned int);
- int CRYPT_AES_CBC_Decrypt(CRYPT_AES_CTX*, unsigned char*,
- const unsigned char*, unsigned int);
- int CRYPT_AES_CTR_Encrypt(CRYPT_AES_CTX*, unsigned char*,
- const unsigned char*, unsigned int);
- int CRYPT_AES_DIRECT_Encrypt(CRYPT_AES_CTX*, unsigned char*,
- const unsigned char*);
- int CRYPT_AES_DIRECT_Decrypt(CRYPT_AES_CTX*, unsigned char*,
- const unsigned char*);
- enum {
- CRYPT_AES_ENCRYPTION = 0,
- CRYPT_AES_DECRYPTION = 1,
- CRYPT_AES_BLOCK_SIZE = 16
- };
- typedef struct CRYPT_RSA_CTX {
- void* holder;
- } CRYPT_RSA_CTX;
- int CRYPT_RSA_Initialize(CRYPT_RSA_CTX*);
- int CRYPT_RSA_Free(CRYPT_RSA_CTX*);
- int CRYPT_RSA_PublicKeyDecode(CRYPT_RSA_CTX*, const unsigned char*,
- unsigned int);
- int CRYPT_RSA_PrivateKeyDecode(CRYPT_RSA_CTX*, const unsigned char*,
- unsigned int);
- int CRYPT_RSA_PublicEncrypt(CRYPT_RSA_CTX*, unsigned char*,
- unsigned int, const unsigned char*, unsigned int,
- CRYPT_RNG_CTX*);
- int CRYPT_RSA_PrivateDecrypt(CRYPT_RSA_CTX*, unsigned char*,
- unsigned int, const unsigned char*, unsigned int);
- int CRYPT_RSA_EncryptSizeGet(CRYPT_RSA_CTX*);
- int CRYPT_RSA_SetRng(CRYPT_RSA_CTX*, CRYPT_RNG_CTX*);
- typedef struct CRYPT_ECC_CTX {
- void* holder;
- } CRYPT_ECC_CTX;
- int CRYPT_ECC_Initialize(CRYPT_ECC_CTX*);
- int CRYPT_ECC_Free(CRYPT_ECC_CTX*);
- int CRYPT_ECC_PublicExport(CRYPT_ECC_CTX*, unsigned char*, unsigned int,
- unsigned int*);
- int CRYPT_ECC_PublicImport(CRYPT_ECC_CTX*, const unsigned char*, unsigned int);
- int CRYPT_ECC_PrivateImport(CRYPT_ECC_CTX*, const unsigned char*, unsigned int,
- const unsigned char*, unsigned int);
- int CRYPT_ECC_DHE_KeyMake(CRYPT_ECC_CTX*, CRYPT_RNG_CTX*, int);
- int CRYPT_ECC_DHE_SharedSecretMake(CRYPT_ECC_CTX*, CRYPT_ECC_CTX*,
- unsigned char*, unsigned int, unsigned int*);
- int CRYPT_ECC_DSA_HashSign(CRYPT_ECC_CTX*, CRYPT_RNG_CTX*, unsigned char*,
- unsigned int, unsigned int*, const unsigned char*, unsigned int);
- int CRYPT_ECC_DSA_HashVerify(CRYPT_ECC_CTX*, const unsigned char*,
- unsigned int, unsigned char*, unsigned int, int*);
- int CRYPT_ECC_KeySizeGet(CRYPT_ECC_CTX*);
- int CRYPT_ECC_SignatureSizeGet(CRYPT_ECC_CTX*);
- int CRYPT_ERROR_StringGet(int, char*);
- #ifdef __cplusplus
- }
- #endif
- #endif
|