74 static abs_eap_am_tools_c * g_tools; |
95 static abs_eap_am_tools_c * g_tools; |
75 |
96 |
76 /** |
97 /** |
77 * Destructor does nothing special. |
98 * Destructor does nothing special. |
78 */ |
99 */ |
79 EAP_FUNC_IMPORT virtual ~eap_am_crypto_openssl_c(); |
100 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H virtual ~eap_am_crypto_openssl_c(); |
80 |
101 |
81 /** |
102 /** |
82 * Constructor initializes the member attributes. |
103 * Constructor initializes the member attributes. |
83 */ |
104 */ |
84 EAP_FUNC_IMPORT eap_am_crypto_openssl_c(abs_eap_am_tools_c * const tools); |
105 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_am_crypto_openssl_c(abs_eap_am_tools_c * const tools); |
85 |
106 |
86 /** |
107 /** |
87 * The configure() function is called after the constructor of the |
108 * The configure() function is called after the constructor of the |
88 * object is successfully executed. During the function call the object |
109 * object is successfully executed. During the function call the object |
89 * could query the configuration. Each derived class must define this |
110 * could query the configuration. Each derived class must define this |
90 * function. Needed configuration depends on the implementation. |
111 * function. Needed configuration depends on the implementation. |
91 */ |
112 */ |
92 EAP_FUNC_IMPORT eap_status_e configure(); |
113 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e configure(); |
93 |
114 |
94 // - - - - - - - - - - - - - - - - - - - - - - - - |
115 // - - - - - - - - - - - - - - - - - - - - - - - - |
95 |
116 |
96 EAP_FUNC_IMPORT bool get_is_valid() const |
117 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H bool get_is_valid() const |
97 { |
118 { |
98 return m_is_valid; |
119 return m_is_valid; |
99 } |
120 } |
100 EAP_FUNC_IMPORT void set_is_valid() |
121 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H void set_is_valid() |
101 { |
122 { |
102 m_is_valid = true; |
123 m_is_valid = true; |
103 } |
124 } |
104 |
125 |
105 /** |
126 /** |
106 * This function activates random generator for test use. |
127 * This function activates random generator for test use. |
107 * It does generate predictive pseudorandom data. |
128 * It does generate predictive pseudorandom data. |
108 */ |
129 */ |
109 EAP_FUNC_IMPORT void use_test_random( |
130 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H void use_test_random( |
110 const u8_t * const seed, |
131 const u8_t * const seed, |
111 const u32_t seed_length, |
132 const u32_t seed_length, |
112 const bool does_continuous_seeding_when_true); |
133 const bool does_continuous_seeding_when_true); |
113 |
134 |
114 /** |
135 /** |
115 * The get_rand_bytes() function fills count random bytes to buffer. |
136 * The get_rand_bytes() function fills count random bytes to buffer. |
116 */ |
137 */ |
117 EAP_FUNC_IMPORT eap_status_e get_rand_bytes( |
138 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e get_rand_bytes( |
118 u8_t * const buffer, |
139 u8_t * const buffer, |
119 const u32_t count); |
140 const u32_t count); |
120 |
141 |
121 /** |
142 /** |
122 * The add_rand_seed() function seeds count bytes from buffer to the |
143 * The add_rand_seed() function seeds count bytes from buffer to the |
123 * random data pool. The seed bytes could be any data that increases |
144 * random data pool. The seed bytes could be any data that increases |
124 * entropy of the random data pool. For example time stamps of send |
145 * entropy of the random data pool. For example time stamps of send |
125 * and received messages, likewise addresses, cookies and nonces |
146 * and received messages, likewise addresses, cookies and nonces |
126 * included in messages. |
147 * included in messages. |
127 */ |
148 */ |
128 EAP_FUNC_IMPORT eap_status_e add_rand_seed( |
149 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e add_rand_seed( |
129 const u8_t * const buffer, |
150 const u8_t * const buffer, |
130 const u32_t count); |
151 const u32_t count); |
131 |
152 |
132 /** |
153 /** |
133 * The add_rand_seed_hw_ticks() function adds hardware ticks read with |
154 * The add_rand_seed_hw_ticks() function adds hardware ticks read with |
134 * the abs_eap_am_tools::get_hardware_ticks() function. This could be |
155 * the abs_eap_am_tools::get_hardware_ticks() function. This could be |
135 * used to seed the random data pool with time stamps. |
156 * used to seed the random data pool with time stamps. |
136 */ |
157 */ |
137 EAP_FUNC_IMPORT eap_status_e add_rand_seed_hw_ticks(); |
158 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e add_rand_seed_hw_ticks(); |
138 |
159 |
139 // - - - - - - - - - - - - - - - - - - - - - - - - |
160 // - - - - - - - - - - - - - - - - - - - - - - - - |
140 |
161 |
141 /** |
162 /** |
142 * The generate_diffie_hellman_keys() function generates private and |
163 * The generate_diffie_hellman_keys() function generates private and |
143 * public Diffie-Hellman keys. |
164 * public Diffie-Hellman keys. |
144 * @param dh_context Saves context here. It is private key in OpenSSL |
165 * @param dh_context Saves context here. It is private key in OpenSSL |
145 * and CDHKey in Symbian. |
166 * and CDHKey in Symbian. |
146 */ |
167 */ |
147 EAP_FUNC_IMPORT eap_status_e generate_diffie_hellman_keys( |
168 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e generate_diffie_hellman_keys( |
148 eap_variable_data_c * const dh_context, |
169 eap_variable_data_c * const dh_context, |
149 eap_variable_data_c * const own_public_dh_key, |
170 eap_variable_data_c * const own_public_dh_key, |
150 const u8_t * const prime, |
171 const u8_t * const prime, |
151 const u32_t prime_length, |
172 const u32_t prime_length, |
152 const u8_t * const group_generator, |
173 const u8_t * const group_generator, |
169 |
190 |
170 /** |
191 /** |
171 * This functions cleans up the diffie-hellman context. |
192 * This functions cleans up the diffie-hellman context. |
172 */ |
193 */ |
173 |
194 |
174 EAP_FUNC_IMPORT eap_status_e dh_cleanup( |
195 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e dh_cleanup( |
175 const eap_variable_data_c * const dh_context); |
196 const eap_variable_data_c * const dh_context); |
176 |
197 |
177 // - - - - - - - - - - - - - - - - - - - - - - - - |
198 // - - - - - - - - - - - - - - - - - - - - - - - - |
178 |
199 |
179 /** |
200 /** |
180 * This function returns the size of message digest of SHA1-algorithm. |
201 * This function returns the size of message digest of SHA1-algorithm. |
181 */ |
202 */ |
182 EAP_FUNC_IMPORT u32_t get_sha_256_digest_length( |
203 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_sha_256_digest_length( |
183 eap_variable_data_c * const sha_256_context); |
204 eap_variable_data_c * const sha_256_context); |
184 |
205 |
185 /** |
206 /** |
186 * This function returns the block size of SHA1-algorithm. |
207 * This function returns the block size of SHA1-algorithm. |
187 */ |
208 */ |
188 EAP_FUNC_IMPORT u32_t get_sha_256_block_size( |
209 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_sha_256_block_size( |
189 eap_variable_data_c * const sha_256_context); |
210 eap_variable_data_c * const sha_256_context); |
190 |
211 |
191 /** |
212 /** |
192 * The sha_256_init() function initializes SHA1. |
213 * The sha_256_init() function initializes SHA1. |
193 * Internal context of SHA1 is stored to sha_256_context. |
214 * Internal context of SHA1 is stored to sha_256_context. |
194 */ |
215 */ |
195 EAP_FUNC_IMPORT eap_status_e sha_256_init( |
216 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha_256_init( |
196 eap_variable_data_c * const sha_256_context); |
217 eap_variable_data_c * const sha_256_context); |
197 |
218 |
198 /** |
219 /** |
199 * The sha_256_update() function updates the context of |
220 * The sha_256_update() function updates the context of |
200 * sha_256_context with data_length bytes of data. |
221 * sha_256_context with data_length bytes of data. |
201 */ |
222 */ |
202 EAP_FUNC_IMPORT eap_status_e sha_256_update( |
223 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha_256_update( |
203 eap_variable_data_c * const sha_256_context, |
224 eap_variable_data_c * const sha_256_context, |
204 const u8_t * const data, |
225 const u8_t * const data, |
205 const u32_t data_length); |
226 const u32_t data_length); |
206 |
227 |
207 /** |
228 /** |
208 * The sha_256_final() function writes the message authentication code |
229 * The sha_256_final() function writes the message authentication code |
209 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
230 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
210 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
231 * to buffer pointed by md_length_or_null, If md_length_or_null is non NULL. |
211 */ |
232 */ |
212 EAP_FUNC_IMPORT eap_status_e sha_256_final( |
233 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha_256_final( |
213 eap_variable_data_c * const sha_256_context, |
234 eap_variable_data_c * const sha_256_context, |
214 u8_t * const message_digest, |
235 u8_t * const message_digest, |
215 u32_t *md_length_or_null); |
236 u32_t *md_length_or_null); |
216 |
237 |
217 /** |
238 /** |
218 * The hmac_sha_256_cleanup() cleanups the SHA1 context. |
239 * The hmac_sha_256_cleanup() cleanups the SHA1 context. |
219 */ |
240 */ |
220 EAP_FUNC_IMPORT eap_status_e sha_256_cleanup( |
241 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha_256_cleanup( |
221 eap_variable_data_c * const sha_256_context); |
242 eap_variable_data_c * const sha_256_context); |
222 |
243 |
223 /** |
244 /** |
224 * The sha_256_copy_context() copies the SHA1 context. |
245 * The sha_256_copy_context() copies the SHA1 context. |
225 */ |
246 */ |
226 EAP_FUNC_IMPORT eap_status_e sha_256_copy_context( |
247 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha_256_copy_context( |
227 eap_variable_data_c * const copied_sha_256_context, |
248 eap_variable_data_c * const copied_sha_256_context, |
228 const eap_variable_data_c * const original_sha_256_context); |
249 const eap_variable_data_c * const original_sha_256_context); |
229 |
250 |
230 // - - - - - - - - - - - - - - - - - - - - - - - - |
251 // - - - - - - - - - - - - - - - - - - - - - - - - |
231 |
252 |
232 /** |
253 /** |
233 * This function returns the size of message digest of SHA1-algorithm. |
254 * This function returns the size of message digest of SHA1-algorithm. |
234 */ |
255 */ |
235 EAP_FUNC_IMPORT u32_t get_sha1_digest_length( |
256 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_sha1_digest_length( |
236 eap_variable_data_c * const sha1_context); |
257 eap_variable_data_c * const sha1_context); |
237 |
258 |
238 /** |
259 /** |
239 * This function returns the block size of SHA1-algorithm. |
260 * This function returns the block size of SHA1-algorithm. |
240 */ |
261 */ |
241 EAP_FUNC_IMPORT u32_t get_sha1_block_size( |
262 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_sha1_block_size( |
242 eap_variable_data_c * const sha1_context); |
263 eap_variable_data_c * const sha1_context); |
243 |
264 |
244 /** |
265 /** |
245 * The sha1_init() function initializes SHA1. |
266 * The sha1_init() function initializes SHA1. |
246 * Internal context of SHA1 is stored to sha1_context. |
267 * Internal context of SHA1 is stored to sha1_context. |
247 */ |
268 */ |
248 EAP_FUNC_IMPORT eap_status_e sha1_init( |
269 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha1_init( |
249 eap_variable_data_c * const sha1_context); |
270 eap_variable_data_c * const sha1_context); |
250 |
271 |
251 /** |
272 /** |
252 * The sha1_update() function updates the context of |
273 * The sha1_update() function updates the context of |
253 * sha1_context with data_length bytes of data. |
274 * sha1_context with data_length bytes of data. |
254 */ |
275 */ |
255 EAP_FUNC_IMPORT eap_status_e sha1_update( |
276 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha1_update( |
256 eap_variable_data_c * const sha1_context, |
277 eap_variable_data_c * const sha1_context, |
257 const u8_t * const data, |
278 const u8_t * const data, |
258 const u32_t data_length); |
279 const u32_t data_length); |
259 |
280 |
260 /** |
281 /** |
261 * The sha1_final() function writes the message authentication code |
282 * The sha1_final() function writes the message authentication code |
262 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
283 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
263 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
284 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
264 * NULL. |
285 * NULL. |
265 */ |
286 */ |
266 EAP_FUNC_IMPORT eap_status_e sha1_final( |
287 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha1_final( |
267 eap_variable_data_c * const sha1_context, |
288 eap_variable_data_c * const sha1_context, |
268 u8_t * const message_digest, |
289 u8_t * const message_digest, |
269 u32_t *md_length_or_null); |
290 u32_t *md_length_or_null); |
270 |
291 |
271 /** |
292 /** |
272 * The hmac_sha1_cleanup() cleanups the SHA1 context. |
293 * The hmac_sha1_cleanup() cleanups the SHA1 context. |
273 */ |
294 */ |
274 EAP_FUNC_IMPORT eap_status_e sha1_cleanup( |
295 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha1_cleanup( |
275 eap_variable_data_c * const sha1_context); |
296 eap_variable_data_c * const sha1_context); |
276 |
297 |
277 /** |
298 /** |
278 * The sha1_copy_context() copies the SHA1 context. |
299 * The sha1_copy_context() copies the SHA1 context. |
279 */ |
300 */ |
280 EAP_FUNC_IMPORT eap_status_e sha1_copy_context( |
301 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e sha1_copy_context( |
281 eap_variable_data_c * const copied_sha1_context, |
302 eap_variable_data_c * const copied_sha1_context, |
282 const eap_variable_data_c * const original_sha1_context); |
303 const eap_variable_data_c * const original_sha1_context); |
283 |
304 |
284 // - - - - - - - - - - - - - - - - - - - - - - - - |
305 // - - - - - - - - - - - - - - - - - - - - - - - - |
285 |
306 |
286 /** |
307 /** |
287 * The aes_key_length() function returns the length of key AES-algorithm. |
308 * The aes_key_length() function returns the length of key AES-algorithm. |
288 * This will be constant 16 bytes (128 bits). Still it is better use |
309 * This will be constant 16 bytes (128 bits). Still it is better use |
289 * function to help changes if the length of key is changed in future. |
310 * function to help changes if the length of key is changed in future. |
290 */ |
311 */ |
291 EAP_FUNC_IMPORT u32_t aes_key_length(); |
312 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t aes_key_length(); |
292 |
313 |
293 /** |
314 /** |
294 * The aes_block_size() function returns the block size of AES-algorithm. |
315 * The aes_block_size() function returns the block size of AES-algorithm. |
295 * This will be constant 16 bytes (128 bits). Still it is better use |
316 * This will be constant 16 bytes (128 bits). Still it is better use |
296 * function to help changes if the size is changed in future. |
317 * function to help changes if the size is changed in future. |
297 */ |
318 */ |
298 EAP_FUNC_IMPORT u32_t aes_block_size(); |
319 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t aes_block_size(); |
299 |
320 |
300 |
321 |
301 /** |
322 /** |
302 * The aes_set_encryption_key() function initializes the encryption |
323 * The aes_set_encryption_key() function initializes the encryption |
303 * context of AES-algorithm to the aes_context using key_length bytes |
324 * context of AES-algorithm to the aes_context using key_length bytes |
304 * from buffer key. |
325 * from buffer key. |
305 */ |
326 */ |
306 EAP_FUNC_IMPORT eap_status_e aes_set_encryption_key( |
327 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e aes_set_encryption_key( |
307 eap_variable_data_c * const aes_context, |
328 eap_variable_data_c * const aes_context, |
308 const u8_t * const key, |
329 const u8_t * const key, |
309 const u32_t key_length); |
330 const u32_t key_length); |
310 |
331 |
311 /** |
332 /** |
312 * The aes_set_decryption_key() function initializes the decryption |
333 * The aes_set_decryption_key() function initializes the decryption |
313 * context of |
334 * context of |
314 * AES-algorithm to the aes_context using key_length bytes from buffer key. |
335 * AES-algorithm to the aes_context using key_length bytes from buffer key. |
315 */ |
336 */ |
316 EAP_FUNC_IMPORT eap_status_e aes_set_decryption_key( |
337 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e aes_set_decryption_key( |
317 eap_variable_data_c * const aes_context, |
338 eap_variable_data_c * const aes_context, |
318 const u8_t * const key, |
339 const u8_t * const key, |
319 const u32_t key_length); |
340 const u32_t key_length); |
320 |
341 |
321 EAP_FUNC_IMPORT eap_status_e aes_cleanup( |
342 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e aes_cleanup( |
322 eap_variable_data_c * const aes_context); |
343 eap_variable_data_c * const aes_context); |
323 |
344 |
324 /** |
345 /** |
325 * The aes_encrypt_block() function encrypts data of data_length bytes |
346 * The aes_encrypt_block() function encrypts data of data_length bytes |
326 * using encryption_IV initialization vector. NOTE the length of data must |
347 * using encryption_IV initialization vector. NOTE the length of data must |
327 * be aligned to block size of AES-algorithm. |
348 * be aligned to block size of AES-algorithm. |
328 * This version takes pointers to input and output buffers as a parameter. |
349 * This version takes pointers to input and output buffers as a parameter. |
329 * Those buffers must be fully separated. Some optimizations are used |
350 * Those buffers must be fully separated. Some optimizations are used |
330 * taking advance from separate buffers. |
351 * taking advance from separate buffers. |
331 */ |
352 */ |
332 EAP_FUNC_IMPORT eap_status_e aes_encrypt_block( |
353 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e aes_encrypt_block( |
333 eap_variable_data_c * const aes_context, |
354 eap_variable_data_c * const aes_context, |
334 const u8_t * const data_in, |
355 const u8_t * const data_in, |
335 u8_t * const data_out, |
356 u8_t * const data_out, |
336 const u32_t data_length); |
357 const u32_t data_length); |
337 |
358 |
354 /** |
375 /** |
355 * The key_length() function returns the length of key 3DES-EDE-algorithm. |
376 * The key_length() function returns the length of key 3DES-EDE-algorithm. |
356 * This will be constant 16 bytes (128 bits). Still it is better use |
377 * This will be constant 16 bytes (128 bits). Still it is better use |
357 * function to help changes if the length of key is changed in future. |
378 * function to help changes if the length of key is changed in future. |
358 */ |
379 */ |
359 EAP_FUNC_IMPORT u32_t key_length_3des_ede(); |
380 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t key_length_3des_ede(); |
360 |
381 |
361 /** |
382 /** |
362 * The block_size() function returns the block size of 3DES-EDE-algorithm. |
383 * The block_size() function returns the block size of 3DES-EDE-algorithm. |
363 * This will be constant 16 bytes (128 bits). Still it is better use |
384 * This will be constant 16 bytes (128 bits). Still it is better use |
364 * function to help changes if the size is changed in future. |
385 * function to help changes if the size is changed in future. |
365 */ |
386 */ |
366 EAP_FUNC_IMPORT u32_t block_size_3des_ede(); |
387 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t block_size_3des_ede(); |
367 |
388 |
368 |
389 |
369 /** |
390 /** |
370 * The cbc_set_encryption_key() function initializes the encryption |
391 * The cbc_set_encryption_key() function initializes the encryption |
371 * context of 3DES-EDE-algorithm to the context using key_length bytes |
392 * context of 3DES-EDE-algorithm to the context using key_length bytes |
372 * from buffer key. |
393 * from buffer key. |
373 */ |
394 */ |
374 EAP_FUNC_IMPORT eap_status_e set_encryption_key_3des_ede( |
395 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e set_encryption_key_3des_ede( |
375 eap_variable_data_c * const context, |
396 eap_variable_data_c * const context, |
376 const u8_t * const key, |
397 const u8_t * const key, |
377 const u32_t key_length); |
398 const u32_t key_length); |
378 |
399 |
379 /** |
400 /** |
380 * The cbc_set_decryption_key() function initializes the decryption |
401 * The cbc_set_decryption_key() function initializes the decryption |
381 * context of 3DES-EDE-algorithm to the context using key_length bytes |
402 * context of 3DES-EDE-algorithm to the context using key_length bytes |
382 * from buffer key. |
403 * from buffer key. |
383 */ |
404 */ |
384 EAP_FUNC_IMPORT eap_status_e set_decryption_key_3des_ede( |
405 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e set_decryption_key_3des_ede( |
385 eap_variable_data_c * const context, |
406 eap_variable_data_c * const context, |
386 const u8_t * const key, |
407 const u8_t * const key, |
387 const u32_t key_length); |
408 const u32_t key_length); |
388 |
409 |
389 EAP_FUNC_IMPORT eap_status_e cleanup_3des_ede( |
410 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e cleanup_3des_ede( |
390 eap_variable_data_c * const context); |
411 eap_variable_data_c * const context); |
391 |
412 |
392 /** |
413 /** |
393 * The cbc_encrypt_data() function encrypts data of data_length bytes |
414 * The cbc_encrypt_data() function encrypts data of data_length bytes |
394 * using encryption_IV initialization vector. NOTE the length of data must |
415 * using encryption_IV initialization vector. NOTE the length of data must |
395 * be aligned to block size of 3DES-EDE-algorithm. |
416 * be aligned to block size of 3DES-EDE-algorithm. |
396 * This version takes pointers to input and output buffers as a parameter. |
417 * This version takes pointers to input and output buffers as a parameter. |
397 * Those buffers must be fully separated. Some optimizations are used |
418 * Those buffers must be fully separated. Some optimizations are used |
398 * taking advance from separate buffers. |
419 * taking advance from separate buffers. |
399 */ |
420 */ |
400 EAP_FUNC_IMPORT eap_status_e encrypt_block_3des_ede( |
421 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e encrypt_block_3des_ede( |
401 eap_variable_data_c * const context, |
422 eap_variable_data_c * const context, |
402 const u8_t * const data_in, |
423 const u8_t * const data_in, |
403 u8_t * const data_out, |
424 u8_t * const data_out, |
404 const u32_t data_length); |
425 const u32_t data_length); |
405 |
426 |
444 * Step 3. For j = 0 to m - 1 do |
465 * Step 3. For j = 0 to m - 1 do |
445 * c. xj = G(t,XKEY). |
466 * c. xj = G(t,XKEY). |
446 * d. XKEY = (1 + XKEY + xj) mod 2^b. |
467 * d. XKEY = (1 + XKEY + xj) mod 2^b. |
447 * @endcode |
468 * @endcode |
448 */ |
469 */ |
449 EAP_FUNC_IMPORT eap_status_e dss_pseudo_random( |
470 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e dss_pseudo_random( |
450 u8_t *out, |
471 u8_t *out, |
451 u32_t out_length, |
472 u32_t out_length, |
452 u8_t *xkey, |
473 u8_t *xkey, |
453 u32_t xkey_length); |
474 u32_t xkey_length); |
454 |
475 |
455 // - - - - - - - - - - - - - - - - - - - - - - - - |
476 // - - - - - - - - - - - - - - - - - - - - - - - - |
456 |
477 |
457 /** |
478 /** |
458 * This function returns the size of message digest of MD5-algorithm. |
479 * This function returns the size of message digest of MD5-algorithm. |
459 */ |
480 */ |
460 EAP_FUNC_IMPORT u32_t get_md5_digest_length( |
481 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_md5_digest_length( |
461 eap_variable_data_c * const md5_context); |
482 eap_variable_data_c * const md5_context); |
462 |
483 |
463 /** |
484 /** |
464 * This function returns the block size of MD5-algorithm. |
485 * This function returns the block size of MD5-algorithm. |
465 */ |
486 */ |
466 EAP_FUNC_IMPORT u32_t get_md5_block_size( |
487 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_md5_block_size( |
467 eap_variable_data_c * const md5_context); |
488 eap_variable_data_c * const md5_context); |
468 |
489 |
469 /** |
490 /** |
470 * The sha1_init() function initializes MD5. |
491 * The sha1_init() function initializes MD5. |
471 * Internal context of MD5 is stored to sha1_context. |
492 * Internal context of MD5 is stored to sha1_context. |
472 */ |
493 */ |
473 EAP_FUNC_IMPORT eap_status_e md5_init( |
494 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md5_init( |
474 eap_variable_data_c * const md5_context); |
495 eap_variable_data_c * const md5_context); |
475 |
496 |
476 /** |
497 /** |
477 * The md5_update() function updates the context of |
498 * The md5_update() function updates the context of |
478 * md5_context with data_length bytes of data. |
499 * md5_context with data_length bytes of data. |
479 */ |
500 */ |
480 EAP_FUNC_IMPORT eap_status_e md5_update( |
501 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md5_update( |
481 eap_variable_data_c * const md5_context, |
502 eap_variable_data_c * const md5_context, |
482 const u8_t * const data, |
503 const u8_t * const data, |
483 const u32_t data_length); |
504 const u32_t data_length); |
484 |
505 |
485 /** |
506 /** |
486 * The md5_final() function writes the message authentication code |
507 * The md5_final() function writes the message authentication code |
487 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
508 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
488 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
509 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
489 * NULL. |
510 * NULL. |
490 */ |
511 */ |
491 EAP_FUNC_IMPORT eap_status_e md5_final( |
512 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md5_final( |
492 eap_variable_data_c * const md5_context, |
513 eap_variable_data_c * const md5_context, |
493 u8_t * const message_digest, |
514 u8_t * const message_digest, |
494 u32_t *md_length_or_null); |
515 u32_t *md_length_or_null); |
495 |
516 |
496 /** |
517 /** |
497 * The hmac_md5_cleanup() cleanups the MD5 context. |
518 * The hmac_md5_cleanup() cleanups the MD5 context. |
498 */ |
519 */ |
499 EAP_FUNC_IMPORT eap_status_e md5_cleanup( |
520 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md5_cleanup( |
500 eap_variable_data_c * const md5_context); |
521 eap_variable_data_c * const md5_context); |
501 |
522 |
502 /** |
523 /** |
503 * The md5_copy_context() copies the MD5 context. |
524 * The md5_copy_context() copies the MD5 context. |
504 */ |
525 */ |
505 EAP_FUNC_IMPORT eap_status_e md5_copy_context( |
526 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md5_copy_context( |
506 eap_variable_data_c * const copied_md5_context, |
527 eap_variable_data_c * const copied_md5_context, |
507 const eap_variable_data_c * const original_md5_context); |
528 const eap_variable_data_c * const original_md5_context); |
508 |
529 |
509 // - - - - - - - - - - - - - - - - - - - - - - - - |
530 // - - - - - - - - - - - - - - - - - - - - - - - - |
510 |
531 |
511 /** |
532 /** |
512 * This function returns the size of message digest of MD4-algorithm. |
533 * This function returns the size of message digest of MD4-algorithm. |
513 */ |
534 */ |
514 EAP_FUNC_IMPORT u32_t get_md4_digest_length( |
535 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_md4_digest_length( |
515 eap_variable_data_c * const md4_context); |
536 eap_variable_data_c * const md4_context); |
516 |
537 |
517 /** |
538 /** |
518 * This function returns the block size of MD4-algorithm. |
539 * This function returns the block size of MD4-algorithm. |
519 */ |
540 */ |
520 EAP_FUNC_IMPORT u32_t get_md4_block_size( |
541 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H u32_t get_md4_block_size( |
521 eap_variable_data_c * const md4_context); |
542 eap_variable_data_c * const md4_context); |
522 |
543 |
523 /** |
544 /** |
524 * The sha1_init() function initializes MD4. |
545 * The sha1_init() function initializes MD4. |
525 * Internal context of MD4 is stored to sha1_context. |
546 * Internal context of MD4 is stored to sha1_context. |
526 */ |
547 */ |
527 EAP_FUNC_IMPORT eap_status_e md4_init( |
548 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md4_init( |
528 eap_variable_data_c * const md4_context); |
549 eap_variable_data_c * const md4_context); |
529 |
550 |
530 /** |
551 /** |
531 * The md4_update() function updates the context of |
552 * The md4_update() function updates the context of |
532 * md5_context with data_length bytes of data. |
553 * md5_context with data_length bytes of data. |
533 */ |
554 */ |
534 EAP_FUNC_IMPORT eap_status_e md4_update( |
555 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md4_update( |
535 eap_variable_data_c * const md4_context, |
556 eap_variable_data_c * const md4_context, |
536 const u8_t * const data, |
557 const u8_t * const data, |
537 const u32_t data_length); |
558 const u32_t data_length); |
538 |
559 |
539 /** |
560 /** |
540 * The md4_final() function writes the message authentication code |
561 * The md4_final() function writes the message authentication code |
541 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
562 * (MAC) to buffer pointed by message_digest. The length of MAC is stored |
542 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
563 * to buffer pointed by md_length_or_null, If md_length_or_null is non |
543 * NULL. |
564 * NULL. |
544 */ |
565 */ |
545 EAP_FUNC_IMPORT eap_status_e md4_final( |
566 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md4_final( |
546 eap_variable_data_c * const md4_context, |
567 eap_variable_data_c * const md4_context, |
547 u8_t * const message_digest, |
568 u8_t * const message_digest, |
548 u32_t *md_length_or_null); |
569 u32_t *md_length_or_null); |
549 |
570 |
550 /** |
571 /** |
551 * The hmac_md5_cleanup() cleanups the MD4 context. |
572 * The hmac_md5_cleanup() cleanups the MD4 context. |
552 */ |
573 */ |
553 EAP_FUNC_IMPORT eap_status_e md4_cleanup( |
574 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md4_cleanup( |
554 eap_variable_data_c * const md4_context); |
575 eap_variable_data_c * const md4_context); |
555 |
576 |
556 /** |
577 /** |
557 * The md4_copy_context() copies the MD4 context. |
578 * The md4_copy_context() copies the MD4 context. |
558 */ |
579 */ |
559 EAP_FUNC_IMPORT eap_status_e md4_copy_context( |
580 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e md4_copy_context( |
560 eap_variable_data_c * const copied_md4_context, |
581 eap_variable_data_c * const copied_md4_context, |
561 const eap_variable_data_c * const original_md4_context); |
582 const eap_variable_data_c * const original_md4_context); |
562 |
583 |
563 // - - - - - - - - - - - - - - - - - - - - - - - - |
584 // - - - - - - - - - - - - - - - - - - - - - - - - |
564 |
585 |
565 /** |
586 /** |
566 * Used to set the RC4 key. |
587 * Used to set the RC4 key. |
567 */ |
588 */ |
568 EAP_FUNC_IMPORT eap_status_e rc4_set_key( |
589 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_set_key( |
569 eap_variable_data_c * const rc4_context, |
590 eap_variable_data_c * const rc4_context, |
570 const eap_variable_data_c * const key); |
591 const eap_variable_data_c * const key); |
571 |
592 |
572 /** |
593 /** |
573 * Used to clean up the RC4 context. |
594 * Used to clean up the RC4 context. |
574 */ |
595 */ |
575 EAP_FUNC_IMPORT eap_status_e rc4_cleanup( |
596 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_cleanup( |
576 eap_variable_data_c * const rc4_context); |
597 eap_variable_data_c * const rc4_context); |
577 |
598 |
578 /** |
599 /** |
579 * Encrypts RC4 data. |
600 * Encrypts RC4 data. |
580 */ |
601 */ |
581 EAP_FUNC_IMPORT eap_status_e rc4_encrypt( |
602 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_encrypt( |
582 const eap_variable_data_c * const rc4_context, |
603 const eap_variable_data_c * const rc4_context, |
583 void * const data_in_out, |
604 void * const data_in_out, |
584 const u32_t data_length); |
605 const u32_t data_length); |
585 |
606 |
586 /** |
607 /** |
587 * Encrypts RC4 data. |
608 * Encrypts RC4 data. |
588 */ |
609 */ |
589 EAP_FUNC_IMPORT eap_status_e rc4_encrypt( |
610 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_encrypt( |
590 const eap_variable_data_c * const rc4_context, |
611 const eap_variable_data_c * const rc4_context, |
591 const void * const data_in, |
612 const void * const data_in, |
592 void * const data_out, |
613 void * const data_out, |
593 const u32_t data_length); |
614 const u32_t data_length); |
594 |
615 |
595 /** |
616 /** |
596 * Decrypts RC4 data. |
617 * Decrypts RC4 data. |
597 */ |
618 */ |
598 EAP_FUNC_IMPORT eap_status_e rc4_decrypt( |
619 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_decrypt( |
599 const eap_variable_data_c * const rc4_context, |
620 const eap_variable_data_c * const rc4_context, |
600 void * const data_in_out, |
621 void * const data_in_out, |
601 const u32_t data_length); |
622 const u32_t data_length); |
602 |
623 |
603 /** |
624 /** |
604 * Decrypts RC4 data. |
625 * Decrypts RC4 data. |
605 */ |
626 */ |
606 EAP_FUNC_IMPORT eap_status_e rc4_decrypt( |
627 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rc4_decrypt( |
607 const eap_variable_data_c * const rc4_context, |
628 const eap_variable_data_c * const rc4_context, |
608 const void * const data_in, |
629 const void * const data_in, |
609 void * const data_out, |
630 void * const data_out, |
610 const u32_t data_length); |
631 const u32_t data_length); |
611 |
632 |
613 |
634 |
614 /** |
635 /** |
615 * The rsa_init() function initializes context of RSA. |
636 * The rsa_init() function initializes context of RSA. |
616 * Internal context of RSA is stored to rsa_context. |
637 * Internal context of RSA is stored to rsa_context. |
617 */ |
638 */ |
618 EAP_FUNC_IMPORT eap_status_e rsa_init( |
639 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_init( |
619 eap_variable_data_c * const rsa_context); |
640 eap_variable_data_c * const rsa_context); |
620 |
641 |
621 EAP_FUNC_IMPORT eap_status_e rsa_encrypt_with_public_key( |
642 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_encrypt_with_public_key( |
622 eap_variable_data_c * const rsa_context, |
643 eap_variable_data_c * const rsa_context, |
623 const eap_variable_data_c * const public_rsa_key, |
644 const eap_variable_data_c * const public_rsa_key, |
624 const eap_variable_data_c * const input_data, |
645 const eap_variable_data_c * const input_data, |
625 eap_variable_data_c * const output_data); |
646 eap_variable_data_c * const output_data); |
626 |
647 |
627 EAP_FUNC_IMPORT eap_status_e rsa_decrypt_with_public_key( |
648 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_decrypt_with_public_key( |
628 eap_variable_data_c * const rsa_context, |
649 eap_variable_data_c * const rsa_context, |
629 const eap_variable_data_c * const public_rsa_key, |
650 const eap_variable_data_c * const public_rsa_key, |
630 const eap_variable_data_c * const input_data, |
651 const eap_variable_data_c * const input_data, |
631 eap_variable_data_c * const output_data); |
652 eap_variable_data_c * const output_data); |
632 |
653 |
633 EAP_FUNC_IMPORT eap_status_e rsa_encrypt_with_private_key( |
654 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_encrypt_with_private_key( |
634 eap_variable_data_c * const rsa_context, |
655 eap_variable_data_c * const rsa_context, |
635 const eap_variable_data_c * const private_rsa_key, |
656 const eap_variable_data_c * const private_rsa_key, |
636 const eap_variable_data_c * const input_data, |
657 const eap_variable_data_c * const input_data, |
637 eap_variable_data_c * const output_data); |
658 eap_variable_data_c * const output_data); |
638 |
659 |
639 EAP_FUNC_IMPORT eap_status_e rsa_decrypt_with_private_key( |
660 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_decrypt_with_private_key( |
640 eap_variable_data_c * const rsa_context, |
661 eap_variable_data_c * const rsa_context, |
641 const eap_variable_data_c * const private_rsa_key, |
662 const eap_variable_data_c * const private_rsa_key, |
642 const eap_variable_data_c * const input_data, |
663 const eap_variable_data_c * const input_data, |
643 eap_variable_data_c * const output_data); |
664 eap_variable_data_c * const output_data); |
644 |
665 |
645 EAP_FUNC_IMPORT eap_status_e rsa_sign( |
666 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_sign( |
646 eap_variable_data_c * const rsa_context, |
667 eap_variable_data_c * const rsa_context, |
647 const eap_variable_data_c * const private_rsa_key, |
668 const eap_variable_data_c * const private_rsa_key, |
648 const eap_variable_data_c * const hash, |
669 const eap_variable_data_c * const hash, |
649 eap_variable_data_c * const signed_hash); |
670 eap_variable_data_c * const signed_hash); |
650 |
671 |
651 EAP_FUNC_IMPORT eap_status_e rsa_verify( |
672 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_verify( |
652 eap_variable_data_c * const rsa_context, |
673 eap_variable_data_c * const rsa_context, |
653 const eap_variable_data_c * const public_rsa_key, |
674 const eap_variable_data_c * const public_rsa_key, |
654 const eap_variable_data_c * const hash, |
675 const eap_variable_data_c * const hash, |
655 const eap_variable_data_c * const signed_hash); |
676 const eap_variable_data_c * const signed_hash); |
656 |
677 |
657 /** |
678 /** |
658 * The rsa_cleanup() function cleans up context of RSA. |
679 * The rsa_cleanup() function cleans up context of RSA. |
659 * Internal context of RSA is stored to rsa_context. |
680 * Internal context of RSA is stored to rsa_context. |
660 */ |
681 */ |
661 EAP_FUNC_IMPORT eap_status_e rsa_cleanup( |
682 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e rsa_cleanup( |
662 eap_variable_data_c * const rsa_context); |
683 eap_variable_data_c * const rsa_context); |
663 |
684 |
664 // - - - - - - - - - - - - - - - - - - - - - - - - |
685 // - - - - - - - - - - - - - - - - - - - - - - - - |
665 |
686 |
666 /** |
687 /** |
667 * The dsa_init() function initializes context of DSA. |
688 * The dsa_init() function initializes context of DSA. |
668 * Internal context of DSA is stored to dsa_context. |
689 * Internal context of DSA is stored to dsa_context. |
669 */ |
690 */ |
670 EAP_FUNC_IMPORT eap_status_e dsa_init( |
691 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e dsa_init( |
671 eap_variable_data_c * const dsa_context); |
692 eap_variable_data_c * const dsa_context); |
672 |
693 |
673 EAP_FUNC_IMPORT eap_status_e dsa_sign( |
694 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e dsa_sign( |
674 eap_variable_data_c * const dsa_context, |
695 eap_variable_data_c * const dsa_context, |
675 const eap_variable_data_c * const private_dsa_key, |
696 const eap_variable_data_c * const private_dsa_key, |
676 const eap_variable_data_c * const hash, |
697 const eap_variable_data_c * const hash, |
677 eap_variable_data_c * const signed_hash); |
698 eap_variable_data_c * const signed_hash); |
678 |
699 |
679 EAP_FUNC_IMPORT eap_status_e dsa_verify( |
700 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_OPENSSL_H eap_status_e dsa_verify( |
680 eap_variable_data_c * const dsa_context, |
701 eap_variable_data_c * const dsa_context, |
681 const eap_variable_data_c * const public_dsa_key, |
702 const eap_variable_data_c * const public_dsa_key, |
682 const eap_variable_data_c * const dsa_param_p, |
703 const eap_variable_data_c * const dsa_param_p, |
683 const eap_variable_data_c * const dsa_param_q, |
704 const eap_variable_data_c * const dsa_param_q, |
684 const eap_variable_data_c * const dsa_param_g, |
705 const eap_variable_data_c * const dsa_param_g, |