|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #if !defined( _ABS_EAP_AM_CRYPTO_H_ ) |
|
22 #define _ABS_EAP_AM_CRYPTO_H_ |
|
23 |
|
24 #include "eap_am_types.h" |
|
25 #include "eap_variable_data.h" |
|
26 #include "eap_am_export.h" |
|
27 #include "eap_am_tools.h" |
|
28 #include "eap_array.h" |
|
29 |
|
30 #if 0 |
|
31 const u32_t TRACE_FLAGS_EAP_AM_CRYPTO = |
|
32 eap_am_tools_c::eap_trace_mask_crypto |
|
33 | eap_am_tools_c::eap_trace_mask_debug; |
|
34 #else |
|
35 const u32_t TRACE_FLAGS_EAP_AM_CRYPTO = |
|
36 eap_am_tools_c::eap_trace_mask_crypto; |
|
37 #endif |
|
38 |
|
39 const u32_t EAP_AES_BLOCK_SIZE = 16u; |
|
40 |
|
41 const u32_t EAP_3DES_EDE_CBC_BLOCK_SIZE = 8ul; |
|
42 |
|
43 |
|
44 class abs_eap_am_tools_c; |
|
45 class eap_variable_data_c; |
|
46 |
|
47 /// Class eap_am_crypto offers services to authenticate data, encrypt data, |
|
48 /// decrypt data, generate keys and generate cryptographically strong random data. |
|
49 class EAP_EXPORT abs_eap_am_crypto_c |
|
50 { |
|
51 private: |
|
52 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
53 |
|
54 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
55 public: |
|
56 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
57 /** |
|
58 * Destructor does nothing special. |
|
59 */ |
|
60 virtual ~abs_eap_am_crypto_c() |
|
61 { |
|
62 } |
|
63 |
|
64 /** |
|
65 * The configure() function is called after the constructor of the |
|
66 * object is successfully executed. During the function call the object |
|
67 * could query the configuration. Each derived class must define this function. |
|
68 * Needed configuration depends on the implementation. |
|
69 */ |
|
70 virtual eap_status_e configure() = 0; |
|
71 |
|
72 /** |
|
73 * The get_is_valid() function returns the status of the eap_core object. |
|
74 * True indicates the object is initialized succesfully. |
|
75 */ |
|
76 virtual bool get_is_valid() const = 0 ; |
|
77 |
|
78 virtual void set_is_valid() = 0; |
|
79 |
|
80 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
81 |
|
82 /** |
|
83 * This function activates random generator for test use. |
|
84 * It does generate predictive pseudorandom data. |
|
85 */ |
|
86 virtual void use_test_random( |
|
87 const u8_t * const seed, |
|
88 const u32_t seed_length, |
|
89 const bool does_continuous_seeding_when_true) = 0; |
|
90 |
|
91 /** |
|
92 * The get_rand_bytes() function fills count random bytes to buffer. |
|
93 */ |
|
94 virtual eap_status_e get_rand_bytes( |
|
95 u8_t * const buffer, |
|
96 const u32_t count) = 0; |
|
97 |
|
98 /** |
|
99 * The add_rand_seed() function seeds count bytes from buffer to the random data pool. |
|
100 * The seed bytes could be any data that increases entropy of the random data pool. |
|
101 * For example time stamps of send and received messages, likewise addresses, |
|
102 * cookies and nonces included in messages. |
|
103 */ |
|
104 virtual eap_status_e add_rand_seed( |
|
105 const u8_t * const buffer, |
|
106 const u32_t count) = 0; |
|
107 |
|
108 /** |
|
109 * The add_rand_seed_hw_ticks() function adds hardware ticks read with |
|
110 * the abs_eap_am_tools::get_hardware_ticks() function. This could be used to |
|
111 * seed the random data pool with time stamps. |
|
112 */ |
|
113 virtual eap_status_e add_rand_seed_hw_ticks() = 0; |
|
114 |
|
115 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
116 |
|
117 /** |
|
118 * The generate_diffie_hellman_keys() function generates private and public |
|
119 * Diffie-Hellman keys. The key_length parameter is not fully supported. |
|
120 * It is used only for sanity checks. Only one well-known group is supported. |
|
121 * @param dh_context Saves context here. Is private key in OpenSSL and CDHKey in Symbian. |
|
122 */ |
|
123 virtual eap_status_e generate_diffie_hellman_keys( |
|
124 eap_variable_data_c * const dh_context, |
|
125 eap_variable_data_c * const own_public_dh_key, |
|
126 const u8_t * const prime, |
|
127 const u32_t prime_length, |
|
128 const u8_t * const group_generator, |
|
129 const u32_t group_generator_length) = 0; |
|
130 |
|
131 /** |
|
132 * The generate_g_power_to_xy() function generates shared secret |
|
133 * Diffie-Hellman key from own_private_dh_key and peer_public_dh_key. |
|
134 * The key_length parameter is not fully supported. It is used only for sanity checks. |
|
135 * Only one well-known group is supported. |
|
136 * @param dh_context Gets context. Is private key in OpenSSL and CDHKey in Symbian. |
|
137 */ |
|
138 virtual eap_status_e generate_g_power_to_xy( |
|
139 const eap_variable_data_c * const dh_context, |
|
140 const eap_variable_data_c * const peer_public_dh_key, |
|
141 eap_variable_data_c * const shared_dh_key, |
|
142 const u8_t * const prime, |
|
143 const u32_t prime_length, |
|
144 const u8_t * const group_generator, |
|
145 const u32_t group_generator_length) = 0; |
|
146 |
|
147 /** |
|
148 * This functions cleans up the diffie-hellman context. |
|
149 */ |
|
150 virtual eap_status_e dh_cleanup( |
|
151 const eap_variable_data_c * const dh_context) = 0; |
|
152 |
|
153 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
154 |
|
155 /** |
|
156 * This function returns the size of message digest of SHA1-algorithm. |
|
157 */ |
|
158 virtual u32_t get_sha_256_digest_length( |
|
159 eap_variable_data_c * const sha_256_context) = 0; |
|
160 |
|
161 /** |
|
162 * This function returns the block size of SHA1-algorithm. |
|
163 */ |
|
164 virtual u32_t get_sha_256_block_size( |
|
165 eap_variable_data_c * const sha_256_context) = 0; |
|
166 |
|
167 /** |
|
168 * The sha_256_init() function initializes SHA1. |
|
169 * Internal context of SHA1 is stored to sha_256_context. |
|
170 */ |
|
171 virtual eap_status_e sha_256_init( |
|
172 eap_variable_data_c * const sha_256_context) = 0; |
|
173 |
|
174 /** |
|
175 * The sha_256_update() function updates the context of |
|
176 * sha_256_context with data_length bytes of data. |
|
177 */ |
|
178 virtual eap_status_e sha_256_update( |
|
179 eap_variable_data_c * const sha_256_context, |
|
180 const u8_t * const data, |
|
181 const u32_t data_length) = 0; |
|
182 |
|
183 /** |
|
184 * The sha_256_final() function writes the message authentication code |
|
185 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
|
186 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
|
187 */ |
|
188 virtual eap_status_e sha_256_final( |
|
189 eap_variable_data_c * const sha_256_context, |
|
190 u8_t * const message_digest, |
|
191 u32_t *md_length_or_null) = 0; |
|
192 |
|
193 /** |
|
194 * The hmac_sha_256_cleanup() cleanups the SHA1 context. |
|
195 */ |
|
196 virtual eap_status_e sha_256_cleanup( |
|
197 eap_variable_data_c * const sha_256_context) = 0; |
|
198 |
|
199 /** |
|
200 * The sha_256_copy_context() copies the SHA1 context. |
|
201 */ |
|
202 virtual eap_status_e sha_256_copy_context( |
|
203 eap_variable_data_c * const copied_sha_256_context, |
|
204 const eap_variable_data_c * const original_sha_256_context) = 0; |
|
205 |
|
206 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
207 |
|
208 /** |
|
209 * This function returns the size of message digest of SHA1-algorithm. |
|
210 */ |
|
211 virtual u32_t get_sha1_digest_length( |
|
212 eap_variable_data_c * const sha1_context) = 0; |
|
213 |
|
214 /** |
|
215 * This function returns the block size of SHA1-algorithm. |
|
216 */ |
|
217 virtual u32_t get_sha1_block_size( |
|
218 eap_variable_data_c * const sha1_context) = 0; |
|
219 |
|
220 /** |
|
221 * The sha1_init() function initializes SHA1. |
|
222 * Internal context of SHA1 is stored to sha1_context. |
|
223 */ |
|
224 virtual eap_status_e sha1_init( |
|
225 eap_variable_data_c * const sha1_context) = 0; |
|
226 |
|
227 /** |
|
228 * The sha1_update() function updates the context of |
|
229 * sha1_context with data_length bytes of data. |
|
230 */ |
|
231 virtual eap_status_e sha1_update( |
|
232 eap_variable_data_c * const sha1_context, |
|
233 const u8_t * const data, |
|
234 const u32_t data_length) = 0; |
|
235 |
|
236 /** |
|
237 * The sha1_final() function writes the message authentication code |
|
238 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
|
239 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
|
240 */ |
|
241 virtual eap_status_e sha1_final( |
|
242 eap_variable_data_c * const sha1_context, |
|
243 u8_t * const message_digest, |
|
244 u32_t *md_length_or_null) = 0; |
|
245 |
|
246 /** |
|
247 * The hmac_sha1_cleanup() cleanups the SHA1 context. |
|
248 */ |
|
249 virtual eap_status_e sha1_cleanup( |
|
250 eap_variable_data_c * const sha1_context) = 0; |
|
251 |
|
252 /** |
|
253 * The sha1_copy_context() copies the SHA1 context. |
|
254 */ |
|
255 virtual eap_status_e sha1_copy_context( |
|
256 eap_variable_data_c * const copied_sha1_context, |
|
257 const eap_variable_data_c * const original_sha1_context) = 0; |
|
258 |
|
259 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
260 |
|
261 /** |
|
262 * The aes_key_length() function returns the length of key AES-algorithm. |
|
263 * This will be constant 16 bytes (128 bits). Still it is better use function |
|
264 * to help changes if the length of key is changed in future. |
|
265 */ |
|
266 virtual u32_t aes_key_length() = 0; |
|
267 |
|
268 /** |
|
269 * The aes_block_size() function returns the block size of AES-algorithm. |
|
270 * This will be constant 16 bytes (128 bits). Still it is better use function |
|
271 * to help changes if the size is changed in future. |
|
272 */ |
|
273 virtual u32_t aes_block_size() = 0; |
|
274 |
|
275 |
|
276 /** |
|
277 * The aes_set_encryption_key() function initializes the encryption |
|
278 * context of AES-algorithm to the aes_context using key_length bytes from buffer key. |
|
279 */ |
|
280 virtual eap_status_e aes_set_encryption_key( |
|
281 eap_variable_data_c * const aes_context, |
|
282 const u8_t * const key, |
|
283 const u32_t key_length) = 0; |
|
284 |
|
285 /** |
|
286 * The aes_set_decryption_key() function initializes the decryption context of |
|
287 * AES-algorithm to the aes_context using key_length bytes from buffer key. |
|
288 */ |
|
289 virtual eap_status_e aes_set_decryption_key( |
|
290 eap_variable_data_c * const aes_context, |
|
291 const u8_t * const key, |
|
292 const u32_t key_length) = 0; |
|
293 |
|
294 virtual eap_status_e aes_cleanup( |
|
295 eap_variable_data_c * const aes_context) = 0; |
|
296 |
|
297 /** |
|
298 * The aes_encrypt_block() function encrypts data of data_length bytes |
|
299 * using encryption_IV initialization vector. NOTE the length of data must |
|
300 * be aligned to block size of AES-algorithm. |
|
301 * This version takes pointers to input and output buffers as a parameter. |
|
302 * Those buffers must be fully separated. Some optimizations are used taking |
|
303 * advance from separate buffers. |
|
304 */ |
|
305 virtual eap_status_e aes_encrypt_block( |
|
306 eap_variable_data_c * const aes_context, |
|
307 const u8_t * const data_in, |
|
308 u8_t * const data_out, |
|
309 const u32_t data_length) = 0; |
|
310 |
|
311 /** |
|
312 * The aes_decrypt_block() function decrypts data of data_length bytes |
|
313 * using decryption_IV initialization vector. NOTE the length of data must |
|
314 * be aligned to block size of AES-algorithm. |
|
315 * This version takes pointers to input and output buffers as a parameter. |
|
316 * Those buffers must be fully separated. Some optimizations are used |
|
317 * taking advance from separate buffers. |
|
318 */ |
|
319 virtual eap_status_e aes_decrypt_block( |
|
320 eap_variable_data_c * const aes_context, |
|
321 const u8_t * const data_in, |
|
322 u8_t * const data_out, |
|
323 const u32_t data_length) = 0; |
|
324 |
|
325 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
326 |
|
327 /** |
|
328 * The key_length() function returns the length of key 3DES-EDE-algorithm. |
|
329 * This will be constant 16 bytes (128 bits). Still it is better use function |
|
330 * to help changes if the length of key is changed in future. |
|
331 */ |
|
332 virtual u32_t key_length_3des_ede() = 0; |
|
333 |
|
334 /** |
|
335 * The block_size() function returns the block size of 3DES-EDE-algorithm. |
|
336 * This will be constant 16 bytes (128 bits). Still it is better use function |
|
337 * to help changes if the size is changed in future. |
|
338 */ |
|
339 virtual u32_t block_size_3des_ede() = 0; |
|
340 |
|
341 |
|
342 /** |
|
343 * The cbc_set_encryption_key() function initializes the encryption |
|
344 * context of 3DES-EDE-algorithm to the context using key_length bytes from buffer key. |
|
345 */ |
|
346 virtual eap_status_e set_encryption_key_3des_ede( |
|
347 eap_variable_data_c * const context, |
|
348 const u8_t * const key, |
|
349 const u32_t key_length) = 0; |
|
350 |
|
351 /** |
|
352 * The cbc_set_decryption_key() function initializes the decryption context of |
|
353 * 3DES-EDE-algorithm to the context using key_length bytes from buffer key. |
|
354 */ |
|
355 virtual eap_status_e set_decryption_key_3des_ede( |
|
356 eap_variable_data_c * const context, |
|
357 const u8_t * const key, |
|
358 const u32_t key_length) = 0; |
|
359 |
|
360 virtual eap_status_e cleanup_3des_ede( |
|
361 eap_variable_data_c * const context) = 0; |
|
362 |
|
363 /** |
|
364 * The cbc_encrypt_data() function encrypts data of data_length bytes |
|
365 * using encryption_IV initialization vector. NOTE the length of data must |
|
366 * be aligned to block size of 3DES-EDE-algorithm. |
|
367 * This version takes pointers to input and output buffers as a parameter. |
|
368 * Those buffers must be fully separated. Some optimizations are used taking |
|
369 * advance from separate buffers. |
|
370 */ |
|
371 virtual eap_status_e encrypt_block_3des_ede( |
|
372 eap_variable_data_c * const context, |
|
373 const u8_t * const data_in, |
|
374 u8_t * const data_out, |
|
375 const u32_t data_length) = 0; |
|
376 |
|
377 /** |
|
378 * The cbc_decrypt_data() function decrypts data of data_length bytes |
|
379 * using decryption_IV initialization vector. NOTE the length of data must |
|
380 * be aligned to block size of 3DES-EDE-algorithm. |
|
381 * This version takes pointers to input and output buffers as a parameter. |
|
382 * Those buffers must be fully separated. Some optimizations are used |
|
383 * taking advance from separate buffers. |
|
384 */ |
|
385 virtual eap_status_e decrypt_block_3des_ede( |
|
386 eap_variable_data_c * const context, |
|
387 const u8_t * const data_in, |
|
388 u8_t * const data_out, |
|
389 const u32_t data_length) = 0; |
|
390 |
|
391 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
392 |
|
393 /** |
|
394 * Key derivation is based on the random number generation specified in |
|
395 * NIST Federal Information Processing Standards (FIPS) Publication |
|
396 * 186-2 [9]. The random number generator is specified in the change |
|
397 * notice 1 (2001 October 5) of [9] (Algorithm 1). As specified in the |
|
398 * change notice (page 74), when Algorithm 1 is used as a general- |
|
399 * purpose random number generator, the "mod q" term in step 3.3 is |
|
400 * omitted. The function G used in the algorithm is constructed via |
|
401 * Secure Hash Standard as specified in Appendix 3.3 of the standard. |
|
402 |
|
403 * 160-bit XKEY and XVAL values are used, so b = 160. The initial |
|
404 * secret seed value XKEY is computed from the n GSM Kc keys and the |
|
405 * NONCE_MT with the following formula: |
|
406 * @code |
|
407 * XKEY = SHA1(n*Kc| NONCE_MT) |
|
408 * |
|
409 * Random generator becomes as follows: |
|
410 * Step 1. Choose a new, secret value for the seed-key, XKEY. |
|
411 * Step 2. In hexadecimal notation let |
|
412 * t = 67452301 EFCDAB89 98BADCFE 10325476 C3D2E1F0. |
|
413 * This is the initial value for H0 || H1 || H2 || H3 || H4 in the SHS. |
|
414 * Step 3. For j = 0 to m - 1 do |
|
415 * c. xj = G(t,XKEY). |
|
416 * d. XKEY = (1 + XKEY + xj) mod 2^b. |
|
417 * @endcode |
|
418 */ |
|
419 virtual eap_status_e dss_pseudo_random( |
|
420 u8_t *out, |
|
421 u32_t out_length, |
|
422 u8_t *xkey, |
|
423 u32_t xkey_length) = 0; |
|
424 |
|
425 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
426 |
|
427 /** |
|
428 * This function returns the size of message digest of MD5-algorithm. |
|
429 */ |
|
430 virtual u32_t get_md5_digest_length( |
|
431 eap_variable_data_c * const md5_context) = 0; |
|
432 |
|
433 /** |
|
434 * This function returns the block size of MD5-algorithm. |
|
435 */ |
|
436 virtual u32_t get_md5_block_size( |
|
437 eap_variable_data_c * const md5_context) = 0; |
|
438 |
|
439 /** |
|
440 * The sha1_init() function initializes MD5. |
|
441 * Internal context of MD5 is stored to sha1_context. |
|
442 */ |
|
443 virtual eap_status_e md5_init( |
|
444 eap_variable_data_c * const md5_context) = 0; |
|
445 |
|
446 /** |
|
447 * The md5_update() function updates the context of |
|
448 * md5_context with data_length bytes of data. |
|
449 */ |
|
450 virtual eap_status_e md5_update( |
|
451 eap_variable_data_c * const md5_context, |
|
452 const u8_t * const data, |
|
453 const u32_t data_length) = 0; |
|
454 |
|
455 /** |
|
456 * The md5_final() function writes the message authentication code |
|
457 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
|
458 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
|
459 */ |
|
460 virtual eap_status_e md5_final( |
|
461 eap_variable_data_c * const md5_context, |
|
462 u8_t * const message_digest, |
|
463 u32_t *md_length_or_null) = 0; |
|
464 |
|
465 /** |
|
466 * The hmac_md5_cleanup() cleanups the MD5 context. |
|
467 */ |
|
468 virtual eap_status_e md5_cleanup( |
|
469 eap_variable_data_c * const md5_context) = 0; |
|
470 |
|
471 /** |
|
472 * The md5_copy_context() copies the MD5 context. |
|
473 */ |
|
474 virtual eap_status_e md5_copy_context( |
|
475 eap_variable_data_c * const copied_md5_context, |
|
476 const eap_variable_data_c * const original_md5_context) = 0; |
|
477 |
|
478 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
479 |
|
480 /** |
|
481 * This function returns the size of message digest of MD4-algorithm. |
|
482 */ |
|
483 virtual u32_t get_md4_digest_length( |
|
484 eap_variable_data_c * const md4_context) = 0; |
|
485 |
|
486 /** |
|
487 * This function returns the block size of MD4-algorithm. |
|
488 */ |
|
489 virtual u32_t get_md4_block_size( |
|
490 eap_variable_data_c * const md4_context) = 0; |
|
491 |
|
492 /** |
|
493 * The sha1_init() function initializes MD4. |
|
494 * Internal context of MD4 is stored to sha1_context. |
|
495 */ |
|
496 virtual eap_status_e md4_init( |
|
497 eap_variable_data_c * const md4_context) = 0; |
|
498 |
|
499 /** |
|
500 * The md4_update() function updates the context of |
|
501 * md4_context with data_length bytes of data. |
|
502 */ |
|
503 virtual eap_status_e md4_update( |
|
504 eap_variable_data_c * const md4_context, |
|
505 const u8_t * const data, |
|
506 const u32_t data_length) = 0; |
|
507 |
|
508 /** |
|
509 * The md4_final() function writes the message authentication code |
|
510 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
|
511 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
|
512 */ |
|
513 virtual eap_status_e md4_final( |
|
514 eap_variable_data_c * const md4_context, |
|
515 u8_t * const message_digest, |
|
516 u32_t *md_length_or_null) = 0; |
|
517 |
|
518 /** |
|
519 * The hmac_md4_cleanup() cleanups the MD4 context. |
|
520 */ |
|
521 virtual eap_status_e md4_cleanup( |
|
522 eap_variable_data_c * const md4_context) = 0; |
|
523 |
|
524 /** |
|
525 * The md4_copy_context() copies the MD4 context. |
|
526 */ |
|
527 virtual eap_status_e md4_copy_context( |
|
528 eap_variable_data_c * const copied_md4_context, |
|
529 const eap_variable_data_c * const original_md4_context) = 0; |
|
530 |
|
531 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
532 |
|
533 /** |
|
534 * Used to set the RC4 key. |
|
535 */ |
|
536 virtual eap_status_e rc4_set_key( |
|
537 eap_variable_data_c * const rc4_context, |
|
538 const eap_variable_data_c * const key) = 0; |
|
539 |
|
540 /** |
|
541 * Used to clean up the RC4 context. |
|
542 */ |
|
543 virtual eap_status_e rc4_cleanup( |
|
544 eap_variable_data_c * const rc4_context) = 0; |
|
545 |
|
546 /** |
|
547 * Encrypts RC4 data. |
|
548 */ |
|
549 virtual eap_status_e rc4_encrypt( |
|
550 const eap_variable_data_c * const rc4_context, |
|
551 void * const data_in_out, |
|
552 const u32_t data_length) = 0; |
|
553 |
|
554 /** |
|
555 * Encrypts RC4 data. |
|
556 */ |
|
557 virtual eap_status_e rc4_encrypt( |
|
558 const eap_variable_data_c * const rc4_context, |
|
559 const void * const data_in, |
|
560 void * const data_out, |
|
561 const u32_t data_length) = 0; |
|
562 |
|
563 /** |
|
564 * Decrypts RC4 data. |
|
565 */ |
|
566 virtual eap_status_e rc4_decrypt( |
|
567 const eap_variable_data_c * const rc4_context, |
|
568 void * const data_in_out, |
|
569 const u32_t data_length) = 0; |
|
570 |
|
571 /** |
|
572 * Decrypts RC4 data. |
|
573 */ |
|
574 virtual eap_status_e rc4_decrypt( |
|
575 const eap_variable_data_c * const rc4_context, |
|
576 const void * const data_in, |
|
577 void * const data_out, |
|
578 const u32_t data_length) = 0; |
|
579 |
|
580 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
581 |
|
582 /** |
|
583 * The rsa_init() function initializes context of RSA. |
|
584 * Internal context of RSA is stored to rsa_context. |
|
585 */ |
|
586 virtual eap_status_e rsa_init( |
|
587 eap_variable_data_c * const rsa_context) = 0; |
|
588 |
|
589 virtual eap_status_e rsa_encrypt_with_public_key( |
|
590 eap_variable_data_c * const rsa_context, |
|
591 const eap_variable_data_c * const public_rsa_key, |
|
592 const eap_variable_data_c * const input_data, |
|
593 eap_variable_data_c * const output_data) = 0; |
|
594 |
|
595 virtual eap_status_e rsa_decrypt_with_public_key( |
|
596 eap_variable_data_c * const rsa_context, |
|
597 const eap_variable_data_c * const public_rsa_key, |
|
598 const eap_variable_data_c * const input_data, |
|
599 eap_variable_data_c * const output_data) = 0; |
|
600 |
|
601 virtual eap_status_e rsa_encrypt_with_private_key( |
|
602 eap_variable_data_c * const rsa_context, |
|
603 const eap_variable_data_c * const private_rsa_key, |
|
604 const eap_variable_data_c * const input_data, |
|
605 eap_variable_data_c * const output_data) = 0; |
|
606 |
|
607 virtual eap_status_e rsa_decrypt_with_private_key( |
|
608 eap_variable_data_c * const rsa_context, |
|
609 const eap_variable_data_c * const private_rsa_key, |
|
610 const eap_variable_data_c * const input_data, |
|
611 eap_variable_data_c * const output_data) = 0; |
|
612 |
|
613 virtual eap_status_e rsa_sign( |
|
614 eap_variable_data_c * const rsa_context, |
|
615 const eap_variable_data_c * const private_rsa_key, |
|
616 const eap_variable_data_c * const hash, |
|
617 eap_variable_data_c * const signed_hash) = 0; |
|
618 |
|
619 virtual eap_status_e rsa_verify( |
|
620 eap_variable_data_c * const rsa_context, |
|
621 const eap_variable_data_c * const public_rsa_key, |
|
622 const eap_variable_data_c * const hash, |
|
623 const eap_variable_data_c * const signed_hash) = 0; |
|
624 |
|
625 /** |
|
626 * The rsa_cleanup() function cleans up context of RSA. |
|
627 * Internal context of RSA is stored to rsa_context. |
|
628 */ |
|
629 virtual eap_status_e rsa_cleanup( |
|
630 eap_variable_data_c * const rsa_context) = 0; |
|
631 |
|
632 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
633 |
|
634 /** |
|
635 * The dsa_init() function initializes context of DSA. |
|
636 * Internal context of DSA is stored to dsa_context. |
|
637 */ |
|
638 virtual eap_status_e dsa_init( |
|
639 eap_variable_data_c * const dsa_context) = 0; |
|
640 |
|
641 virtual eap_status_e dsa_sign( |
|
642 eap_variable_data_c * const dsa_context, |
|
643 const eap_variable_data_c * const private_dsa_key, |
|
644 const eap_variable_data_c * const hash, |
|
645 eap_variable_data_c * const signed_hash) = 0; |
|
646 |
|
647 virtual eap_status_e dsa_verify( |
|
648 eap_variable_data_c * const dsa_context, |
|
649 const eap_variable_data_c * const public_dsa_key, |
|
650 const eap_variable_data_c * const dsa_param_p, |
|
651 const eap_variable_data_c * const dsa_param_q, |
|
652 const eap_variable_data_c * const dsa_param_g, |
|
653 const eap_variable_data_c * const hash, |
|
654 const eap_variable_data_c * const signed_hash) = 0; |
|
655 |
|
656 /** |
|
657 * The dsa_cleanup() function cleans up context of DSA. |
|
658 * Internal context of DSA is stored to dsa_context. |
|
659 */ |
|
660 virtual eap_status_e dsa_cleanup( |
|
661 eap_variable_data_c * const dsa_context) = 0; |
|
662 |
|
663 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
664 |
|
665 }; |
|
666 |
|
667 #endif //#if !defined( _ABS_EAP_AM_CRYPTO_H ) |
|
668 |
|
669 |
|
670 |
|
671 // End. |