| 70 | #define MAX_RNG_TRIALS 25 |
| 71 | |
| 72 | srtp_err_status_t srtp_crypto_kernel_init(void) |
| 73 | { |
| 74 | srtp_err_status_t status; |
| 75 | |
| 76 | /* check the security state */ |
| 77 | if (crypto_kernel.state == srtp_crypto_kernel_state_secure) { |
| 78 | /* |
| 79 | * we're already in the secure state, but we've been asked to |
| 80 | * re-initialize, so we just re-run the self-tests and then return |
| 81 | */ |
| 82 | return srtp_crypto_kernel_status(); |
| 83 | } |
| 84 | |
| 85 | /* initialize error reporting system */ |
| 86 | status = srtp_err_reporting_init(); |
| 87 | if (status) { |
| 88 | return status; |
| 89 | } |
| 90 | |
| 91 | /* load debug modules */ |
| 92 | status = srtp_crypto_kernel_load_debug_module(&srtp_mod_crypto_kernel); |
| 93 | if (status) { |
| 94 | return status; |
| 95 | } |
| 96 | status = srtp_crypto_kernel_load_debug_module(&srtp_mod_auth); |
| 97 | if (status) { |
| 98 | return status; |
| 99 | } |
| 100 | status = srtp_crypto_kernel_load_debug_module(&srtp_mod_cipher); |
| 101 | if (status) { |
| 102 | return status; |
| 103 | } |
| 104 | status = srtp_crypto_kernel_load_debug_module(&srtp_mod_alloc); |
| 105 | if (status) { |
| 106 | return status; |
| 107 | } |
| 108 | |
| 109 | /* load cipher types */ |
| 110 | status = srtp_crypto_kernel_load_cipher_type(&srtp_null_cipher, |
| 111 | SRTP_NULL_CIPHER); |
| 112 | if (status) { |
| 113 | return status; |
| 114 | } |
| 115 | status = srtp_crypto_kernel_load_cipher_type(&srtp_aes_icm_128, |
| 116 | SRTP_AES_ICM_128); |
| 117 | if (status) { |
| 118 | return status; |
| 119 | } |
| 120 | status = srtp_crypto_kernel_load_cipher_type(&srtp_aes_icm_256, |
| 121 | SRTP_AES_ICM_256); |
| 122 | if (status) { |
| 123 | return status; |
| 124 | } |
| 125 | status = srtp_crypto_kernel_load_debug_module(&srtp_mod_aes_icm); |
| 126 | if (status) { |
| 127 | return status; |
| 128 | } |
| 129 | #ifdef GCM |