]> git.saurik.com Git - apple/security.git/blob - AppleCSP/AES/rijndael-alg-ref.h
Security-29.tar.gz
[apple/security.git] / AppleCSP / AES / rijndael-alg-ref.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 /* rijndael-alg-ref.h v2.0 August '99
20 * Reference ANSI C code
21 * authors: Paulo Barreto
22 * Vincent Rijmen
23 */
24 #ifndef __RIJNDAEL_ALG_H
25 #define __RIJNDAEL_ALG_H
26
27 #ifdef __APPLE__
28 #define MIN_AES_KEY_BITS 128
29 #define MID_AES_KEY_BITS 192
30 #define MAX_AES_KEY_BITS 256
31
32 #define MIN_AES_BLOCK_BITS 128
33 #define MID_AES_BLOCK_BITS 192
34 #define MAX_AES_BLOCK_BITS 256
35 #endif
36 #define MAXBC (MAX_AES_BLOCK_BITS/32)
37 #define MAXKC (MAX_AES_KEY_BITS/32)
38 #define MAXROUNDS 14
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 typedef unsigned char word8;
45 typedef unsigned short word16;
46 typedef unsigned long word32;
47
48
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]);
53 #ifndef __APPLE__
54 int rijndaelEncryptRound (word8 a[4][MAXBC], int keyBits, int blockBits,
55 word8 rk[MAXROUNDS+1][4][MAXBC], int rounds);
56 #endif
57 int rijndaelDecrypt (word8 a[4][MAXBC], int keyBits, int blockBits,
58 word8 rk[MAXROUNDS+1][4][MAXBC]);
59 #ifndef __APPLE__
60 int rijndaelDecryptRound (word8 a[4][MAXBC], int keyBits, int blockBits,
61 word8 rk[MAXROUNDS+1][4][MAXBC], int rounds);
62 #endif
63
64 /*
65 * Optimized routines for 128-bit block and key.
66 */
67 #define ROUNDS_128_OPT 10
68 #define BC_128_OPT 4
69 #define KC_128_OPT 4
70
71 /*
72 * These require 32-bit word-aligned a, k, and rk arrays
73 */
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]);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif /* __RIJNDAEL_ALG_H */