|
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 |
|
5 /* Prototypes of the functions defined in the assembler file. */ |
|
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); |
|
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); |
|
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); |
|
12 SECStatus intel_aes_encrypt_ecb_128(AESContext *cx, unsigned char *output, |
|
13 unsigned int *outputLen, |
|
14 unsigned int maxOutputLen, |
|
15 const unsigned char *input, |
|
16 unsigned int inputLen, |
|
17 unsigned int blocksize); |
|
18 SECStatus intel_aes_decrypt_ecb_128(AESContext *cx, unsigned char *output, |
|
19 unsigned int *outputLen, |
|
20 unsigned int maxOutputLen, |
|
21 const unsigned char *input, |
|
22 unsigned int inputLen, |
|
23 unsigned int blocksize); |
|
24 SECStatus intel_aes_encrypt_cbc_128(AESContext *cx, unsigned char *output, |
|
25 unsigned int *outputLen, |
|
26 unsigned int maxOutputLen, |
|
27 const unsigned char *input, |
|
28 unsigned int inputLen, |
|
29 unsigned int blocksize); |
|
30 SECStatus intel_aes_decrypt_cbc_128(AESContext *cx, unsigned char *output, |
|
31 unsigned int *outputLen, |
|
32 unsigned int maxOutputLen, |
|
33 const unsigned char *input, |
|
34 unsigned int inputLen, |
|
35 unsigned int blocksize); |
|
36 SECStatus intel_aes_encrypt_ctr_128(CTRContext *cx, unsigned char *output, |
|
37 unsigned int *outputLen, |
|
38 unsigned int maxOutputLen, |
|
39 const unsigned char *input, |
|
40 unsigned int inputLen, |
|
41 unsigned int blocksize); |
|
42 SECStatus intel_aes_encrypt_ecb_192(AESContext *cx, unsigned char *output, |
|
43 unsigned int *outputLen, |
|
44 unsigned int maxOutputLen, |
|
45 const unsigned char *input, |
|
46 unsigned int inputLen, |
|
47 unsigned int blocksize); |
|
48 SECStatus intel_aes_decrypt_ecb_192(AESContext *cx, unsigned char *output, |
|
49 unsigned int *outputLen, |
|
50 unsigned int maxOutputLen, |
|
51 const unsigned char *input, |
|
52 unsigned int inputLen, |
|
53 unsigned int blocksize); |
|
54 SECStatus intel_aes_encrypt_cbc_192(AESContext *cx, unsigned char *output, |
|
55 unsigned int *outputLen, |
|
56 unsigned int maxOutputLen, |
|
57 const unsigned char *input, |
|
58 unsigned int inputLen, |
|
59 unsigned int blocksize); |
|
60 SECStatus intel_aes_decrypt_cbc_192(AESContext *cx, unsigned char *output, |
|
61 unsigned int *outputLen, |
|
62 unsigned int maxOutputLen, |
|
63 const unsigned char *input, |
|
64 unsigned int inputLen, |
|
65 unsigned int blocksize); |
|
66 SECStatus intel_aes_encrypt_ctr_192(CTRContext *cx, unsigned char *output, |
|
67 unsigned int *outputLen, |
|
68 unsigned int maxOutputLen, |
|
69 const unsigned char *input, |
|
70 unsigned int inputLen, |
|
71 unsigned int blocksize); |
|
72 SECStatus intel_aes_encrypt_ecb_256(AESContext *cx, unsigned char *output, |
|
73 unsigned int *outputLen, |
|
74 unsigned int maxOutputLen, |
|
75 const unsigned char *input, |
|
76 unsigned int inputLen, |
|
77 unsigned int blocksize); |
|
78 SECStatus intel_aes_decrypt_ecb_256(AESContext *cx, unsigned char *output, |
|
79 unsigned int *outputLen, |
|
80 unsigned int maxOutputLen, |
|
81 const unsigned char *input, |
|
82 unsigned int inputLen, |
|
83 unsigned int blocksize); |
|
84 SECStatus intel_aes_encrypt_cbc_256(AESContext *cx, unsigned char *output, |
|
85 unsigned int *outputLen, |
|
86 unsigned int maxOutputLen, |
|
87 const unsigned char *input, |
|
88 unsigned int inputLen, |
|
89 unsigned int blocksize); |
|
90 SECStatus intel_aes_decrypt_cbc_256(AESContext *cx, unsigned char *output, |
|
91 unsigned int *outputLen, |
|
92 unsigned int maxOutputLen, |
|
93 const unsigned char *input, |
|
94 unsigned int inputLen, |
|
95 unsigned int blocksize); |
|
96 SECStatus intel_aes_encrypt_ctr_256(CTRContext *cx, unsigned char *output, |
|
97 unsigned int *outputLen, |
|
98 unsigned int maxOutputLen, |
|
99 const unsigned char *input, |
|
100 unsigned int inputLen, |
|
101 unsigned int blocksize); |
|
102 |
|
103 |
|
104 #define intel_aes_ecb_worker(encrypt, keysize) \ |
|
105 ((encrypt) \ |
|
106 ? ((keysize) == 16 ? intel_aes_encrypt_ecb_128 : \ |
|
107 (keysize) == 24 ? intel_aes_encrypt_ecb_192 : \ |
|
108 intel_aes_encrypt_ecb_256) \ |
|
109 : ((keysize) == 16 ? intel_aes_decrypt_ecb_128 : \ |
|
110 (keysize) == 24 ? intel_aes_decrypt_ecb_192 : \ |
|
111 intel_aes_decrypt_ecb_256)) |
|
112 |
|
113 |
|
114 #define intel_aes_cbc_worker(encrypt, keysize) \ |
|
115 ((encrypt) \ |
|
116 ? ((keysize) == 16 ? intel_aes_encrypt_cbc_128 : \ |
|
117 (keysize) == 24 ? intel_aes_encrypt_cbc_192 : \ |
|
118 intel_aes_encrypt_cbc_256) \ |
|
119 : ((keysize) == 16 ? intel_aes_decrypt_cbc_128 : \ |
|
120 (keysize) == 24 ? intel_aes_decrypt_cbc_192 : \ |
|
121 intel_aes_decrypt_cbc_256)) |
|
122 |
|
123 #define intel_aes_ctr_worker(nr) \ |
|
124 ((nr) == 10 ? intel_aes_encrypt_ctr_128 : \ |
|
125 (nr) == 12 ? intel_aes_encrypt_ctr_192 : \ |
|
126 intel_aes_encrypt_ctr_256) |
|
127 |
|
128 |
|
129 #define intel_aes_init(encrypt, keysize) \ |
|
130 do { \ |
|
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) |