| OLD | NEW |
| (Empty) |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 4 /* $Id: rijndael.h,v 1.13 2012/09/28 22:46:32 rrelyea%redhat.com Exp $ */ | |
| 5 | |
| 6 #ifndef _RIJNDAEL_H_ | |
| 7 #define _RIJNDAEL_H_ 1 | |
| 8 | |
| 9 #include "blapii.h" | |
| 10 | |
| 11 #define RIJNDAEL_MIN_BLOCKSIZE 16 /* bytes */ | |
| 12 #define RIJNDAEL_MAX_BLOCKSIZE 32 /* bytes */ | |
| 13 | |
| 14 typedef SECStatus AESBlockFunc(AESContext *cx, | |
| 15 unsigned char *output, | |
| 16 const unsigned char *input); | |
| 17 | |
| 18 /* RIJNDAEL_NUM_ROUNDS | |
| 19 * | |
| 20 * Number of rounds per execution | |
| 21 * Nk - number of key bytes | |
| 22 * Nb - blocksize (in bytes) | |
| 23 */ | |
| 24 #define RIJNDAEL_NUM_ROUNDS(Nk, Nb) \ | |
| 25 (PR_MAX(Nk, Nb) + 6) | |
| 26 | |
| 27 /* RIJNDAEL_MAX_STATE_SIZE | |
| 28 * | |
| 29 * Maximum number of bytes in the state (spec includes up to 256-bit block | |
| 30 * size) | |
| 31 */ | |
| 32 #define RIJNDAEL_MAX_STATE_SIZE 32 | |
| 33 | |
| 34 /* | |
| 35 * This magic number is (Nb_max * (Nr_max + 1)) | |
| 36 * where Nb_max is the maximum block size in 32-bit words, | |
| 37 * Nr_max is the maximum number of rounds, which is Nb_max + 6 | |
| 38 */ | |
| 39 #define RIJNDAEL_MAX_EXP_KEY_SIZE (8 * 15) | |
| 40 | |
| 41 /* AESContextStr | |
| 42 * | |
| 43 * Values which maintain the state for Rijndael encryption/decryption. | |
| 44 * | |
| 45 * iv - initialization vector for CBC mode | |
| 46 * Nb - the number of bytes in a block, specified by user | |
| 47 * Nr - the number of rounds, specified by a table | |
| 48 * expandedKey - the round keys in 4-byte words, the length is Nr * Nb | |
| 49 * worker - the encryption/decryption function to use with worker_cx | |
| 50 * destroy - if not NULL, the destroy function to use with worker_cx | |
| 51 * worker_cx - the context for worker and destroy | |
| 52 * isBlock - is the mode of operation a block cipher or a stream cipher? | |
| 53 */ | |
| 54 struct AESContextStr | |
| 55 { | |
| 56 unsigned int Nb; | |
| 57 unsigned int Nr; | |
| 58 freeblCipherFunc worker; | |
| 59 /* NOTE: The offsets of iv and expandedKey are hardcoded in intel-aes.s. | |
| 60 * Don't add new members before them without updating intel-aes.s. */ | |
| 61 unsigned char iv[RIJNDAEL_MAX_BLOCKSIZE]; | |
| 62 PRUint32 expandedKey[RIJNDAEL_MAX_EXP_KEY_SIZE]; | |
| 63 freeblDestroyFunc destroy; | |
| 64 void *worker_cx; | |
| 65 PRBool isBlock; | |
| 66 }; | |
| 67 | |
| 68 #endif /* _RIJNDAEL_H_ */ | |
| OLD | NEW |