1 /*********************************************************************************************************************************** 2 Crypto Common 3 ***********************************************************************************************************************************/ 4 #ifndef COMMON_CRYPTO_COMMON_H 5 #define COMMON_CRYPTO_COMMON_H 6 7 #include <common/type/stringId.h> 8 9 /*********************************************************************************************************************************** 10 Cipher modes 11 ***********************************************************************************************************************************/ 12 typedef enum 13 { 14 cipherModeEncrypt = STRID5("encrypt", 0x521990dc50), 15 cipherModeDecrypt = STRID5("decrypt", 0x521990ca40), 16 } CipherMode; 17 18 /*********************************************************************************************************************************** 19 Cipher types 20 ***********************************************************************************************************************************/ 21 typedef enum 22 { 23 cipherTypeNone = STRID5("none", 0x2b9ee0), 24 cipherTypeAes256Cbc = STRID5("aes-256-cbc", 0xc43dfbbcdcca10), 25 } CipherType; 26 27 /*********************************************************************************************************************************** 28 Functions 29 ***********************************************************************************************************************************/ 30 // Initialize crypto 31 void cryptoInit(void); 32 33 // Has crypto been initialized? 34 bool cryptoIsInit(void); 35 36 // Throw crypto errors 37 void cryptoError(bool error, const char *description); 38 void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__)); 39 40 // Generate random bytes 41 void cryptoRandomBytes(unsigned char *buffer, size_t size); 42 43 #endif 44