]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/utilLib/rijndaelApi.h
2 * rijndaelApi.h - AES API layer
4 * Based on rijndael-api-ref.h v2.0 written by Paulo Barreto
8 #ifndef _RIJNDAEL_API_REF_H_
9 #define _RIJNDAEL_API_REF_H_
12 #include "rijndael-alg-ref.h"
18 #define DIR_ENCRYPT 0 /* Are we encrpyting? */
19 #define DIR_DECRYPT 1 /* Are we decrpyting? */
20 #define MODE_ECB 1 /* Are we ciphering in ECB mode? */
21 #define MODE_CBC 2 /* Are we ciphering in CBC mode? */
27 #define BAD_KEY_DIR -1 /* Key direction is invalid, e.g.,
29 #define BAD_KEY_MAT -2 /* Key material not of correct
31 #define BAD_KEY_INSTANCE -3 /* Key passed is not valid */
32 #define BAD_CIPHER_MODE -4 /* Params struct passed to
34 #define BAD_CIPHER_STATE -5 /* Cipher in wrong state (e.g., not
36 #define BAD_CIPHER_INSTANCE -7
38 #define MAX_AES_KEY_SIZE (MAX_AES_KEY_BITS / 8)
39 #define MAX_AES_BLOCK_SIZE (MAX_AES_BLOCK_BITS / 8)
40 #define MAX_AES_IV_SIZE MAX_AES_BLOCK_SIZE
42 typedef unsigned char BYTE
;
44 /* The structure for key information */
46 BYTE direction
; /* Key used for encrypting or decrypting? */
47 int keyLen
; /* Length of the key in bits */
48 int blockLen
; /* Length of block in bits */
49 word8 keySched
[MAXROUNDS
+1][4][MAXBC
]; /* key schedule */
52 /* The structure for cipher information */
54 BYTE mode
; /* MODE_ECB, MODE_CBC, or MODE_CFB1 */
55 word8 chainBlock
[4][MAXBC
];
56 int blockLen
; /* block length in bits */
63 int keyLen
, // in BITS
64 int blockLen
, // in BITS
68 cipherInstance
*cipher
,
70 int blockLen
, // in BITS
74 cipherInstance
*cipher
,
77 int inputLen
, // in BITS
81 cipherInstance
*cipher
,
84 int inputLen
, // in BITS
88 * Apple addenda 3/28/2001: simplified single-block encrypt/decrypt.
89 * Used when chaining and padding is done in elsewhere.
91 int _rijndaelBlockEncrypt(
92 cipherInstance
*cipher
,
96 int _rijndaelBlockDecrypt(
97 cipherInstance
*cipher
,
106 #endif // RIJNDAEL_API_REF