]>
git.saurik.com Git - apple/security.git/blob - AppleCSP/AES/rijndael-alg-ref.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
19 /* rijndael-alg-ref.h v2.0 August '99
20 * Reference ANSI C code
21 * authors: Paulo Barreto
24 #ifndef __RIJNDAEL_ALG_H
25 #define __RIJNDAEL_ALG_H
28 #define MIN_AES_KEY_BITS 128
29 #define MID_AES_KEY_BITS 192
30 #define MAX_AES_KEY_BITS 256
32 #define MIN_AES_BLOCK_BITS 128
33 #define MID_AES_BLOCK_BITS 192
34 #define MAX_AES_BLOCK_BITS 256
36 #define MAXBC (MAX_AES_BLOCK_BITS/32)
37 #define MAXKC (MAX_AES_KEY_BITS/32)
44 typedef unsigned char word8
;
45 typedef unsigned short word16
;
46 typedef unsigned long word32
;
49 int rijndaelKeySched (word8 k
[4][MAXKC
], int keyBits
, int blockBits
,
50 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
51 int rijndaelEncrypt (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
52 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
54 int rijndaelEncryptRound (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
55 word8 rk
[MAXROUNDS
+1][4][MAXBC
], int rounds
);
57 int rijndaelDecrypt (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
58 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
60 int rijndaelDecryptRound (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
61 word8 rk
[MAXROUNDS
+1][4][MAXBC
], int rounds
);
65 * Optimized routines for 128-bit block and key.
67 #define ROUNDS_128_OPT 10
72 * These require 32-bit word-aligned a, k, and rk arrays
74 int rijndaelKeySched128 (word8 k
[4][KC_128_OPT
],
75 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
76 int rijndaelEncrypt128 (word8 a
[4][BC_128_OPT
],
77 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
78 int rijndaelDecrypt128 (word8 a
[4][BC_128_OPT
],
79 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
85 #endif /* __RIJNDAEL_ALG_H */