| 1 | /* |
| 2 | * AES Cryptographic Algorithm Header File. Include this header file in |
| 3 | * your source which uses these given APIs. (This source is kept under |
| 4 | * public domain) |
| 5 | */ |
| 6 | |
| 7 | // AES context structure |
| 8 | typedef struct { |
| 9 | unsigned int Ek[60]; |
| 10 | unsigned int Dk[60]; |
| 11 | unsigned int Iv[4]; |
| 12 | unsigned char Nr; |
| 13 | unsigned char Mode; |
| 14 | } AesCtx; |
| 15 | |
| 16 | // key length in bytes |
| 17 | #define KEY128 16 |
| 18 | #define KEY192 24 |
| 19 | #define KEY256 32 |
| 20 | // block size in bytes |
| 21 | #define BLOCKSZ 16 |
| 22 | // mode |
| 23 | #define EBC 0 |
| 24 | #define CBC 1 |
| 25 | |
| 26 | // AES API function prototype |
| 27 | |
| 28 | int AesCtxIni(AesCtx *pCtx, unsigned char *pIV, unsigned char *pKey, unsigned int KeyLen, unsigned char Mode); |
| 29 | int AesEncrypt(AesCtx *pCtx, unsigned char *pData, unsigned char *pCipher, unsigned int DataLen); |
| 30 | int AesDecrypt(AesCtx *pCtx, unsigned char *pCipher, unsigned char *pData, unsigned int CipherLen); |