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