1/* 2 * Copyright (c) 2000-2001,2011,2014 Apple 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#include "aesCommon.h" 28 29#define MAXBC (MAX_AES_BLOCK_BITS/32) 30#define MAXKC (MAX_AES_KEY_BITS/32) 31#define MAXROUNDS 14 32 33#ifdef __cplusplus 34extern "C" { 35#endif 36 37typedef unsigned char word8; 38typedef unsigned short word16; 39typedef unsigned int word32; 40 41 42int rijndaelKeySched (word8 k[4][MAXKC], int keyBits, int blockBits, 43 word8 rk[MAXROUNDS+1][4][MAXBC]); 44int rijndaelEncrypt (word8 a[4][MAXBC], int keyBits, int blockBits, 45 word8 rk[MAXROUNDS+1][4][MAXBC]); 46#ifndef __APPLE__ 47int rijndaelEncryptRound (word8 a[4][MAXBC], int keyBits, int blockBits, 48 word8 rk[MAXROUNDS+1][4][MAXBC], int rounds); 49#endif 50int rijndaelDecrypt (word8 a[4][MAXBC], int keyBits, int blockBits, 51 word8 rk[MAXROUNDS+1][4][MAXBC]); 52#ifndef __APPLE__ 53int rijndaelDecryptRound (word8 a[4][MAXBC], int keyBits, int blockBits, 54 word8 rk[MAXROUNDS+1][4][MAXBC], int rounds); 55#endif 56 57#if !GLADMAN_AES_128_ENABLE 58 59/* 60 * Optimized routines for 128-bit block and key. 61 */ 62#define ROUNDS_128_OPT 10 63#define BC_128_OPT 4 64#define KC_128_OPT 4 65 66/* 67 * These require 32-bit word-aligned a, k, and rk arrays 68 */ 69int rijndaelKeySched128 (word8 k[4][KC_128_OPT], 70 word8 rk[MAXROUNDS+1][4][MAXBC]); 71int rijndaelEncrypt128 (word8 a[4][BC_128_OPT], 72 word8 rk[MAXROUNDS+1][4][MAXBC]); 73int rijndaelDecrypt128 (word8 a[4][BC_128_OPT], 74 word8 rk[MAXROUNDS+1][4][MAXBC]); 75 76#endif /* !GLADMAN_AES_128_ENABLE */ 77 78#ifdef __cplusplus 79} 80#endif 81 82#endif /* __RIJNDAEL_ALG_H */ 83