1 /* aes.h 2 * Jason E. Holt 3 * released into the public domain 4 */ 5 6 #ifndef AES_H 7 #define AES_H 8 9 #include <stdint.h> 10 11 enum AES_KEYSIZE { 12 AES_KEYSIZE_128 = 0, 13 AES_KEYSIZE_192, 14 AES_KEYSIZE_256 15 }; 16 17 #if HW_AES_IMPL 18 19 // XXX get from a better source? 20 typedef struct { 21 enum AES_KEYSIZE size; 22 uint8_t key[256/8]; 23 } AES_KEY; 24 25 #else // software implementation 26 27 struct aes_key_struct_sw { 28 unsigned long rd_key[60]; 29 int rounds; 30 }; 31 32 typedef struct aes_key_struct_sw AES_KEY; 33 34 #endif 35 36 #define AES_BLOCK_SIZE 16 37 38 int AES_set_encrypt_key(const unsigned char *userKey, const int bits, 39 AES_KEY *key); 40 41 int AES_set_decrypt_key(const unsigned char *userKey, const int bits, 42 AES_KEY *key); 43 44 void AES_decrypt(const unsigned char *in, unsigned char *out, 45 const AES_KEY *key); 46 47 void AES_encrypt(const unsigned char *in, unsigned char *out, 48 const AES_KEY *key); 49 50 51 #endif 52