]>
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
27 #include "aesCommon.h"
29 #define MAXBC (MAX_AES_BLOCK_BITS/32)
30 #define MAXKC (MAX_AES_KEY_BITS/32)
37 typedef unsigned char word8
;
38 typedef unsigned short word16
;
39 typedef unsigned long word32
;
42 int rijndaelKeySched (word8 k
[4][MAXKC
], int keyBits
, int blockBits
,
43 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
44 int rijndaelEncrypt (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
45 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
47 int rijndaelEncryptRound (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
48 word8 rk
[MAXROUNDS
+1][4][MAXBC
], int rounds
);
50 int rijndaelDecrypt (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
51 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
53 int rijndaelDecryptRound (word8 a
[4][MAXBC
], int keyBits
, int blockBits
,
54 word8 rk
[MAXROUNDS
+1][4][MAXBC
], int rounds
);
57 #if !GLADMAN_AES_128_ENABLE
60 * Optimized routines for 128-bit block and key.
62 #define ROUNDS_128_OPT 10
67 * These require 32-bit word-aligned a, k, and rk arrays
69 int rijndaelKeySched128 (word8 k
[4][KC_128_OPT
],
70 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
71 int rijndaelEncrypt128 (word8 a
[4][BC_128_OPT
],
72 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
73 int rijndaelDecrypt128 (word8 a
[4][BC_128_OPT
],
74 word8 rk
[MAXROUNDS
+1][4][MAXBC
]);
76 #endif /* !GLADMAN_AES_128_ENABLE */
82 #endif /* __RIJNDAEL_ALG_H */