OLD | NEW |
1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 3 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
8 * | 8 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 20 matching lines...) Expand all Loading... |
31 * and other provisions required by the GPL or the LGPL. If you do not delete | 31 * and other provisions required by the GPL or the LGPL. If you do not delete |
32 * the provisions above, a recipient may use your version of this file under | 32 * the provisions above, a recipient may use your version of this file under |
33 * the terms of any one of the MPL, the GPL or the LGPL. | 33 * the terms of any one of the MPL, the GPL or the LGPL. |
34 * | 34 * |
35 * ***** END LICENSE BLOCK ***** */ | 35 * ***** END LICENSE BLOCK ***** */ |
36 /* $Id: rijndael.h,v 1.11 2005/08/06 07:24:21 nelsonb%netscape.com Exp $ */ | 36 /* $Id: rijndael.h,v 1.11 2005/08/06 07:24:21 nelsonb%netscape.com Exp $ */ |
37 | 37 |
38 #ifndef _RIJNDAEL_H_ | 38 #ifndef _RIJNDAEL_H_ |
39 #define _RIJNDAEL_H_ 1 | 39 #define _RIJNDAEL_H_ 1 |
40 | 40 |
| 41 #include "blapii.h" |
| 42 |
41 #define RIJNDAEL_MIN_BLOCKSIZE 16 /* bytes */ | 43 #define RIJNDAEL_MIN_BLOCKSIZE 16 /* bytes */ |
42 #define RIJNDAEL_MAX_BLOCKSIZE 32 /* bytes */ | 44 #define RIJNDAEL_MAX_BLOCKSIZE 32 /* bytes */ |
43 | 45 |
44 typedef SECStatus AESFunc(AESContext *cx, unsigned char *output, | |
45 unsigned int *outputLen, unsigned int maxOutputLen, | |
46 const unsigned char *input, unsigned int inputLen, | |
47 unsigned int blocksize); | |
48 | |
49 typedef SECStatus AESBlockFunc(AESContext *cx, | 46 typedef SECStatus AESBlockFunc(AESContext *cx, |
50 unsigned char *output, | 47 unsigned char *output, |
51 const unsigned char *input); | 48 const unsigned char *input); |
52 | 49 |
53 /* RIJNDAEL_NUM_ROUNDS | 50 /* RIJNDAEL_NUM_ROUNDS |
54 * | 51 * |
55 * Number of rounds per execution | 52 * Number of rounds per execution |
56 * Nk - number of key bytes | 53 * Nk - number of key bytes |
57 * Nb - blocksize (in bytes) | 54 * Nb - blocksize (in bytes) |
58 */ | 55 */ |
(...skipping 15 matching lines...) Expand all Loading... |
74 #define RIJNDAEL_MAX_EXP_KEY_SIZE (8 * 15) | 71 #define RIJNDAEL_MAX_EXP_KEY_SIZE (8 * 15) |
75 | 72 |
76 /* AESContextStr | 73 /* AESContextStr |
77 * | 74 * |
78 * Values which maintain the state for Rijndael encryption/decryption. | 75 * Values which maintain the state for Rijndael encryption/decryption. |
79 * | 76 * |
80 * iv - initialization vector for CBC mode | 77 * iv - initialization vector for CBC mode |
81 * Nb - the number of bytes in a block, specified by user | 78 * Nb - the number of bytes in a block, specified by user |
82 * Nr - the number of rounds, specified by a table | 79 * Nr - the number of rounds, specified by a table |
83 * expandedKey - the round keys in 4-byte words, the length is Nr * Nb | 80 * expandedKey - the round keys in 4-byte words, the length is Nr * Nb |
84 * worker - the encryption/decryption function to use with this context | 81 * worker - the encryption/decryption function to use with worker_cx |
| 82 * destroy - if not NULL, the destroy function to use with worker_cx |
| 83 * worker_cx - the context for worker and destroy |
| 84 * isBlock - is the mode of operation a block cipher or a stream cipher? |
85 */ | 85 */ |
86 struct AESContextStr | 86 struct AESContextStr |
87 { | 87 { |
88 unsigned int Nb; | 88 unsigned int Nb; |
89 unsigned int Nr; | 89 unsigned int Nr; |
90 AESFunc *worker; | 90 freeblCipherFunc worker; |
| 91 /* NOTE: The offsets of iv and expandedKey are hardcoded in intel-aes.s. |
| 92 * Don't add new members before them without updating intel-aes.s. */ |
91 unsigned char iv[RIJNDAEL_MAX_BLOCKSIZE]; | 93 unsigned char iv[RIJNDAEL_MAX_BLOCKSIZE]; |
92 PRUint32 expandedKey[RIJNDAEL_MAX_EXP_KEY_SIZE]; | 94 PRUint32 expandedKey[RIJNDAEL_MAX_EXP_KEY_SIZE]; |
| 95 freeblDestroyFunc destroy; |
| 96 void *worker_cx; |
| 97 PRBool isBlock; |
93 }; | 98 }; |
94 | 99 |
95 #endif /* _RIJNDAEL_H_ */ | 100 #endif /* _RIJNDAEL_H_ */ |
OLD | NEW |