| 229 | } |
| 230 | |
| 231 | srtp_err_status_t srtp_crypto_kernel_shutdown(void) |
| 232 | { |
| 233 | /* |
| 234 | * free dynamic memory used in crypto_kernel at present |
| 235 | */ |
| 236 | |
| 237 | /* walk down cipher type list, freeing memory */ |
| 238 | while (crypto_kernel.cipher_type_list != NULL) { |
| 239 | srtp_kernel_cipher_type_t *ctype = crypto_kernel.cipher_type_list; |
| 240 | crypto_kernel.cipher_type_list = ctype->next; |
| 241 | debug_print(srtp_mod_crypto_kernel, "freeing memory for cipher %s", |
| 242 | ctype->cipher_type->description); |
| 243 | srtp_crypto_free(ctype); |
| 244 | } |
| 245 | |
| 246 | /* walk down authetication module list, freeing memory */ |
| 247 | while (crypto_kernel.auth_type_list != NULL) { |
| 248 | srtp_kernel_auth_type_t *atype = crypto_kernel.auth_type_list; |
| 249 | crypto_kernel.auth_type_list = atype->next; |
| 250 | debug_print(srtp_mod_crypto_kernel, |
| 251 | "freeing memory for authentication %s", |
| 252 | atype->auth_type->description); |
| 253 | srtp_crypto_free(atype); |
| 254 | } |
| 255 | |
| 256 | /* walk down debug module list, freeing memory */ |
| 257 | while (crypto_kernel.debug_module_list != NULL) { |
| 258 | srtp_kernel_debug_module_t *kdm = crypto_kernel.debug_module_list; |
| 259 | crypto_kernel.debug_module_list = kdm->next; |
| 260 | debug_print(srtp_mod_crypto_kernel, |
| 261 | "freeing memory for debug module %s", kdm->mod->name); |
| 262 | srtp_crypto_free(kdm); |
| 263 | } |
| 264 | |
| 265 | /* return to insecure state */ |
| 266 | crypto_kernel.state = srtp_crypto_kernel_state_insecure; |
| 267 | |
| 268 | return srtp_err_status_ok; |
| 269 | } |
| 270 | |
| 271 | static inline srtp_err_status_t srtp_crypto_kernel_do_load_cipher_type( |
| 272 | const srtp_cipher_type_t *new_ct, |