OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 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 | 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/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* Prototypes of the functions defined in the assembler file. */ | 5 /* Prototypes of the functions defined in the assembler file. */ |
6 void intel_aes_encrypt_init_128(const unsigned char *key, PRUint32 *expanded); | 6 void intel_aes_encrypt_init_128(const unsigned char *key, PRUint32 *expanded); |
7 void intel_aes_encrypt_init_192(const unsigned char *key, PRUint32 *expanded); | 7 void intel_aes_encrypt_init_192(const unsigned char *key, PRUint32 *expanded); |
8 void intel_aes_encrypt_init_256(const unsigned char *key, PRUint32 *expanded); | 8 void intel_aes_encrypt_init_256(const unsigned char *key, PRUint32 *expanded); |
9 void intel_aes_decrypt_init_128(const unsigned char *key, PRUint32 *expanded); | 9 void intel_aes_decrypt_init_128(const unsigned char *key, PRUint32 *expanded); |
10 void intel_aes_decrypt_init_192(const unsigned char *key, PRUint32 *expanded); | 10 void intel_aes_decrypt_init_192(const unsigned char *key, PRUint32 *expanded); |
11 void intel_aes_decrypt_init_256(const unsigned char *key, PRUint32 *expanded); | 11 void intel_aes_decrypt_init_256(const unsigned char *key, PRUint32 *expanded); |
12 SECStatus intel_aes_encrypt_ecb_128(AESContext *cx, unsigned char *output, | 12 SECStatus intel_aes_encrypt_ecb_128(AESContext *cx, unsigned char *output, |
13 » » » » unsigned int *outputLen, | 13 unsigned int *outputLen, |
14 » » » » unsigned int maxOutputLen, | 14 unsigned int maxOutputLen, |
15 » » » » const unsigned char *input, | 15 const unsigned char *input, |
16 » » » » unsigned int inputLen, | 16 unsigned int inputLen, |
17 » » » » unsigned int blocksize); | 17 unsigned int blocksize); |
18 SECStatus intel_aes_decrypt_ecb_128(AESContext *cx, unsigned char *output, | 18 SECStatus intel_aes_decrypt_ecb_128(AESContext *cx, unsigned char *output, |
19 » » » » unsigned int *outputLen, | 19 unsigned int *outputLen, |
20 » » » » unsigned int maxOutputLen, | 20 unsigned int maxOutputLen, |
21 » » » » const unsigned char *input, | 21 const unsigned char *input, |
22 » » » » unsigned int inputLen, | 22 unsigned int inputLen, |
23 » » » » unsigned int blocksize); | 23 unsigned int blocksize); |
24 SECStatus intel_aes_encrypt_cbc_128(AESContext *cx, unsigned char *output, | 24 SECStatus intel_aes_encrypt_cbc_128(AESContext *cx, unsigned char *output, |
25 » » » » unsigned int *outputLen, | 25 unsigned int *outputLen, |
26 » » » » unsigned int maxOutputLen, | 26 unsigned int maxOutputLen, |
27 » » » » const unsigned char *input, | 27 const unsigned char *input, |
28 » » » » unsigned int inputLen, | 28 unsigned int inputLen, |
29 » » » » unsigned int blocksize); | 29 unsigned int blocksize); |
30 SECStatus intel_aes_decrypt_cbc_128(AESContext *cx, unsigned char *output, | 30 SECStatus intel_aes_decrypt_cbc_128(AESContext *cx, unsigned char *output, |
31 » » » » unsigned int *outputLen, | 31 unsigned int *outputLen, |
32 » » » » unsigned int maxOutputLen, | 32 unsigned int maxOutputLen, |
33 » » » » const unsigned char *input, | 33 const unsigned char *input, |
34 » » » » unsigned int inputLen, | 34 unsigned int inputLen, |
35 » » » » unsigned int blocksize); | 35 unsigned int blocksize); |
36 SECStatus intel_aes_encrypt_ctr_128(CTRContext *cx, unsigned char *output, | 36 SECStatus intel_aes_encrypt_ctr_128(CTRContext *cx, unsigned char *output, |
37 » » » » unsigned int *outputLen, | 37 unsigned int *outputLen, |
38 » » » » unsigned int maxOutputLen, | 38 unsigned int maxOutputLen, |
39 » » » » const unsigned char *input, | 39 const unsigned char *input, |
40 » » » » unsigned int inputLen, | 40 unsigned int inputLen, |
41 » » » » unsigned int blocksize); | 41 unsigned int blocksize); |
42 SECStatus intel_aes_encrypt_ecb_192(AESContext *cx, unsigned char *output, | 42 SECStatus intel_aes_encrypt_ecb_192(AESContext *cx, unsigned char *output, |
43 » » » » unsigned int *outputLen, | 43 unsigned int *outputLen, |
44 » » » » unsigned int maxOutputLen, | 44 unsigned int maxOutputLen, |
45 » » » » const unsigned char *input, | 45 const unsigned char *input, |
46 » » » » unsigned int inputLen, | 46 unsigned int inputLen, |
47 » » » » unsigned int blocksize); | 47 unsigned int blocksize); |
48 SECStatus intel_aes_decrypt_ecb_192(AESContext *cx, unsigned char *output, | 48 SECStatus intel_aes_decrypt_ecb_192(AESContext *cx, unsigned char *output, |
49 » » » » unsigned int *outputLen, | 49 unsigned int *outputLen, |
50 » » » » unsigned int maxOutputLen, | 50 unsigned int maxOutputLen, |
51 » » » » const unsigned char *input, | 51 const unsigned char *input, |
52 » » » » unsigned int inputLen, | 52 unsigned int inputLen, |
53 » » » » unsigned int blocksize); | 53 unsigned int blocksize); |
54 SECStatus intel_aes_encrypt_cbc_192(AESContext *cx, unsigned char *output, | 54 SECStatus intel_aes_encrypt_cbc_192(AESContext *cx, unsigned char *output, |
55 » » » » unsigned int *outputLen, | 55 unsigned int *outputLen, |
56 » » » » unsigned int maxOutputLen, | 56 unsigned int maxOutputLen, |
57 » » » » const unsigned char *input, | 57 const unsigned char *input, |
58 » » » » unsigned int inputLen, | 58 unsigned int inputLen, |
59 » » » » unsigned int blocksize); | 59 unsigned int blocksize); |
60 SECStatus intel_aes_decrypt_cbc_192(AESContext *cx, unsigned char *output, | 60 SECStatus intel_aes_decrypt_cbc_192(AESContext *cx, unsigned char *output, |
61 » » » » unsigned int *outputLen, | 61 unsigned int *outputLen, |
62 » » » » unsigned int maxOutputLen, | 62 unsigned int maxOutputLen, |
63 » » » » const unsigned char *input, | 63 const unsigned char *input, |
64 » » » » unsigned int inputLen, | 64 unsigned int inputLen, |
65 » » » » unsigned int blocksize); | 65 unsigned int blocksize); |
66 SECStatus intel_aes_encrypt_ctr_192(CTRContext *cx, unsigned char *output, | 66 SECStatus intel_aes_encrypt_ctr_192(CTRContext *cx, unsigned char *output, |
67 » » » » unsigned int *outputLen, | 67 unsigned int *outputLen, |
68 » » » » unsigned int maxOutputLen, | 68 unsigned int maxOutputLen, |
69 » » » » const unsigned char *input, | 69 const unsigned char *input, |
70 » » » » unsigned int inputLen, | 70 unsigned int inputLen, |
71 » » » » unsigned int blocksize); | 71 unsigned int blocksize); |
72 SECStatus intel_aes_encrypt_ecb_256(AESContext *cx, unsigned char *output, | 72 SECStatus intel_aes_encrypt_ecb_256(AESContext *cx, unsigned char *output, |
73 » » » » unsigned int *outputLen, | 73 unsigned int *outputLen, |
74 » » » » unsigned int maxOutputLen, | 74 unsigned int maxOutputLen, |
75 » » » » const unsigned char *input, | 75 const unsigned char *input, |
76 » » » » unsigned int inputLen, | 76 unsigned int inputLen, |
77 » » » » unsigned int blocksize); | 77 unsigned int blocksize); |
78 SECStatus intel_aes_decrypt_ecb_256(AESContext *cx, unsigned char *output, | 78 SECStatus intel_aes_decrypt_ecb_256(AESContext *cx, unsigned char *output, |
79 » » » » unsigned int *outputLen, | 79 unsigned int *outputLen, |
80 » » » » unsigned int maxOutputLen, | 80 unsigned int maxOutputLen, |
81 » » » » const unsigned char *input, | 81 const unsigned char *input, |
82 » » » » unsigned int inputLen, | 82 unsigned int inputLen, |
83 » » » » unsigned int blocksize); | 83 unsigned int blocksize); |
84 SECStatus intel_aes_encrypt_cbc_256(AESContext *cx, unsigned char *output, | 84 SECStatus intel_aes_encrypt_cbc_256(AESContext *cx, unsigned char *output, |
85 » » » » unsigned int *outputLen, | 85 unsigned int *outputLen, |
86 » » » » unsigned int maxOutputLen, | 86 unsigned int maxOutputLen, |
87 » » » » const unsigned char *input, | 87 const unsigned char *input, |
88 » » » » unsigned int inputLen, | 88 unsigned int inputLen, |
89 » » » » unsigned int blocksize); | 89 unsigned int blocksize); |
90 SECStatus intel_aes_decrypt_cbc_256(AESContext *cx, unsigned char *output, | 90 SECStatus intel_aes_decrypt_cbc_256(AESContext *cx, unsigned char *output, |
91 » » » » unsigned int *outputLen, | 91 unsigned int *outputLen, |
92 » » » » unsigned int maxOutputLen, | 92 unsigned int maxOutputLen, |
93 » » » » const unsigned char *input, | 93 const unsigned char *input, |
94 » » » » unsigned int inputLen, | 94 unsigned int inputLen, |
95 » » » » unsigned int blocksize); | 95 unsigned int blocksize); |
96 SECStatus intel_aes_encrypt_ctr_256(CTRContext *cx, unsigned char *output, | 96 SECStatus intel_aes_encrypt_ctr_256(CTRContext *cx, unsigned char *output, |
97 » » » » unsigned int *outputLen, | 97 unsigned int *outputLen, |
98 » » » » unsigned int maxOutputLen, | 98 unsigned int maxOutputLen, |
99 » » » » const unsigned char *input, | 99 const unsigned char *input, |
100 » » » » unsigned int inputLen, | 100 unsigned int inputLen, |
101 » » » » unsigned int blocksize); | 101 unsigned int blocksize); |
102 | 102 |
| 103 #define intel_aes_ecb_worker(encrypt, keysize) \ |
| 104 ((encrypt) \ |
| 105 ? ((keysize) == 16 ? intel_aes_encrypt_ecb_128 \ |
| 106 : (keysize) == 24 ? intel_aes_encrypt_ecb_192 \ |
| 107 : intel_aes_encrypt_ecb_256) \ |
| 108 : ((keysize) == 16 ? intel_aes_decrypt_ecb_128 \ |
| 109 : (keysize) == 24 ? intel_aes_decrypt_ecb_192 \ |
| 110 : intel_aes_decrypt_ecb_256)) |
103 | 111 |
104 #define intel_aes_ecb_worker(encrypt, keysize) \ | 112 #define intel_aes_cbc_worker(encrypt, keysize) \ |
105 ((encrypt)» » » » » » \ | 113 ((encrypt) \ |
106 ? ((keysize) == 16 ? intel_aes_encrypt_ecb_128 :» \ | 114 ? ((keysize) == 16 ? intel_aes_encrypt_cbc_128 \ |
107 (keysize) == 24 ? intel_aes_encrypt_ecb_192 :» \ | 115 : (keysize) == 24 ? intel_aes_encrypt_cbc_192 \ |
108 intel_aes_encrypt_ecb_256)» » » \ | 116 : intel_aes_encrypt_cbc_256) \ |
109 : ((keysize) == 16 ? intel_aes_decrypt_ecb_128 :» \ | 117 : ((keysize) == 16 ? intel_aes_decrypt_cbc_128 \ |
110 (keysize) == 24 ? intel_aes_decrypt_ecb_192 :» \ | 118 : (keysize) == 24 ? intel_aes_decrypt_cbc_192 \ |
111 intel_aes_decrypt_ecb_256)) | 119 : intel_aes_decrypt_cbc_256)) |
112 | 120 |
| 121 #define intel_aes_ctr_worker(nr) \ |
| 122 ((nr) == 10 ? intel_aes_encrypt_ctr_128 : (nr) == 12 \ |
| 123 ? intel_aes_encrypt_ctr_192 \ |
| 124 : intel_aes_encrypt_ctr_256) |
113 | 125 |
114 #define intel_aes_cbc_worker(encrypt, keysize) \ | 126 #define intel_aes_init(encrypt, keysize) \ |
115 ((encrypt)» » » » » » \ | 127 do { \ |
116 ? ((keysize) == 16 ? intel_aes_encrypt_cbc_128 :» \ | 128 if (encrypt) { \ |
117 (keysize) == 24 ? intel_aes_encrypt_cbc_192 :» \ | 129 if (keysize == 16) \ |
118 intel_aes_encrypt_cbc_256)» » » \ | 130 intel_aes_encrypt_init_128(key, cx->expandedKey); \ |
119 : ((keysize) == 16 ? intel_aes_decrypt_cbc_128 :» \ | 131 else if (keysize == 24) \ |
120 (keysize) == 24 ? intel_aes_decrypt_cbc_192 :» \ | 132 intel_aes_encrypt_init_192(key, cx->expandedKey); \ |
121 intel_aes_decrypt_cbc_256)) | 133 else \ |
122 | 134 intel_aes_encrypt_init_256(key, cx->expandedKey); \ |
123 #define intel_aes_ctr_worker(nr) \ | 135 } else { \ |
124 ((nr) == 10 ? intel_aes_encrypt_ctr_128 :» \ | 136 if (keysize == 16) \ |
125 (nr) == 12 ? intel_aes_encrypt_ctr_192 :» \ | 137 intel_aes_decrypt_init_128(key, cx->expandedKey); \ |
126 intel_aes_encrypt_ctr_256) | 138 else if (keysize == 24) \ |
127 | 139 intel_aes_decrypt_init_192(key, cx->expandedKey); \ |
128 | 140 else \ |
129 #define intel_aes_init(encrypt, keysize) \ | 141 intel_aes_decrypt_init_256(key, cx->expandedKey); \ |
130 do {» » » » » » » » \ | 142 } \ |
131 if (encrypt) {» » » » » » \ | |
132 » if (keysize == 16)» » » » » \ | |
133 » intel_aes_encrypt_init_128(key, cx->expandedKey);»\ | |
134 » else if (keysize == 24)» » » » \ | |
135 » intel_aes_encrypt_init_192(key, cx->expandedKey);»\ | |
136 » else» » » » » » » \ | |
137 » intel_aes_encrypt_init_256(key, cx->expandedKey);»\ | |
138 } else {» » » » » » » \ | |
139 » if (keysize == 16)» » » » » \ | |
140 » intel_aes_decrypt_init_128(key, cx->expandedKey);»\ | |
141 » else if (keysize == 24)» » » » \ | |
142 » intel_aes_decrypt_init_192(key, cx->expandedKey);»\ | |
143 » else» » » » » » » \ | |
144 » intel_aes_decrypt_init_256(key, cx->expandedKey);»\ | |
145 }»» » » » » » » \ | |
146 } while (0) | 143 } while (0) |
OLD | NEW |