OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * crypto_kernel.h |
| 3 * |
| 4 * header for the cryptographic kernel |
| 5 * |
| 6 * David A. McGrew |
| 7 * Cisco Systems, Inc. |
| 8 */ |
| 9 /* |
| 10 * |
| 11 * Copyright(c) 2001-2006 Cisco Systems, Inc. |
| 12 * All rights reserved. |
| 13 * |
| 14 * Redistribution and use in source and binary forms, with or without |
| 15 * modification, are permitted provided that the following conditions |
| 16 * are met: |
| 17 * |
| 18 * Redistributions of source code must retain the above copyright |
| 19 * notice, this list of conditions and the following disclaimer. |
| 20 * |
| 21 * Redistributions in binary form must reproduce the above |
| 22 * copyright notice, this list of conditions and the following |
| 23 * disclaimer in the documentation and/or other materials provided |
| 24 * with the distribution. |
| 25 * |
| 26 * Neither the name of the Cisco Systems, Inc. nor the names of its |
| 27 * contributors may be used to endorse or promote products derived |
| 28 * from this software without specific prior written permission. |
| 29 * |
| 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 33 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 34 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 35 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 41 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 42 * |
| 43 */ |
| 44 |
| 45 |
| 46 #ifndef CRYPTO_KERNEL |
| 47 #define CRYPTO_KERNEL |
| 48 |
| 49 #include "cipher.h" |
| 50 #include "auth.h" |
| 51 #include "err.h" |
| 52 #include "crypto_types.h" |
| 53 #include "key.h" |
| 54 |
| 55 #ifdef __cplusplus |
| 56 extern "C" { |
| 57 #endif |
| 58 |
| 59 /* |
| 60 * crypto_kernel_state_t defines the possible states: |
| 61 * |
| 62 * insecure - not yet initialized |
| 63 * secure - initialized and passed self-tests |
| 64 */ |
| 65 typedef enum { |
| 66 srtp_crypto_kernel_state_insecure, |
| 67 srtp_crypto_kernel_state_secure |
| 68 } srtp_crypto_kernel_state_t; |
| 69 |
| 70 /* |
| 71 * linked list of cipher types |
| 72 */ |
| 73 typedef struct srtp_kernel_cipher_type { |
| 74 srtp_cipher_type_id_t id; |
| 75 const srtp_cipher_type_t *cipher_type; |
| 76 struct srtp_kernel_cipher_type *next; |
| 77 } srtp_kernel_cipher_type_t; |
| 78 |
| 79 /* |
| 80 * linked list of auth types |
| 81 */ |
| 82 typedef struct srtp_kernel_auth_type { |
| 83 srtp_auth_type_id_t id; |
| 84 const srtp_auth_type_t *auth_type; |
| 85 struct srtp_kernel_auth_type *next; |
| 86 } srtp_kernel_auth_type_t; |
| 87 |
| 88 /* |
| 89 * linked list of debug modules |
| 90 */ |
| 91 typedef struct srtp_kernel_debug_module { |
| 92 srtp_debug_module_t *mod; |
| 93 struct srtp_kernel_debug_module *next; |
| 94 } srtp_kernel_debug_module_t; |
| 95 |
| 96 |
| 97 /* |
| 98 * crypto_kernel_t is the data structure for the crypto kernel |
| 99 * |
| 100 * note that there is *exactly one* instance of this data type, |
| 101 * a global variable defined in crypto_kernel.c |
| 102 */ |
| 103 typedef struct { |
| 104 srtp_crypto_kernel_state_t state; /* current state of kernel
*/ |
| 105 srtp_kernel_cipher_type_t *cipher_type_list; /* list of all cipher types
*/ |
| 106 srtp_kernel_auth_type_t *auth_type_list; /* list of all auth func type
s */ |
| 107 srtp_kernel_debug_module_t *debug_module_list; /* list of all debug modules
*/ |
| 108 } srtp_crypto_kernel_t; |
| 109 |
| 110 |
| 111 /* |
| 112 * srtp_crypto_kernel_t external api |
| 113 */ |
| 114 |
| 115 |
| 116 /* |
| 117 * The function srtp_crypto_kernel_init() initialized the crypto kernel and |
| 118 * runs the self-test operations on the random number generators and |
| 119 * crypto algorithms. Possible return values are: |
| 120 * |
| 121 * srtp_err_status_ok initialization successful |
| 122 * <other> init failure |
| 123 * |
| 124 * If any value other than srtp_err_status_ok is returned, the |
| 125 * crypto_kernel MUST NOT be used. |
| 126 */ |
| 127 srtp_err_status_t srtp_crypto_kernel_init(void); |
| 128 |
| 129 |
| 130 /* |
| 131 * The function srtp_crypto_kernel_shutdown() de-initializes the |
| 132 * crypto_kernel, zeroizes keys and other cryptographic material, and |
| 133 * deallocates any dynamically allocated memory. Possible return |
| 134 * values are: |
| 135 * |
| 136 * srtp_err_status_ok shutdown successful |
| 137 * <other> shutdown failure |
| 138 * |
| 139 */ |
| 140 srtp_err_status_t srtp_crypto_kernel_shutdown(void); |
| 141 |
| 142 /* |
| 143 * The function srtp_crypto_kernel_stats() checks the the crypto_kernel, |
| 144 * running tests on the ciphers, auth funcs, and rng, and prints out a |
| 145 * status report. Possible return values are: |
| 146 * |
| 147 * srtp_err_status_ok all tests were passed |
| 148 * <other> a test failed |
| 149 * |
| 150 */ |
| 151 srtp_err_status_t srtp_crypto_kernel_status(void); |
| 152 |
| 153 |
| 154 /* |
| 155 * srtp_crypto_kernel_list_debug_modules() outputs a list of debugging modules |
| 156 * |
| 157 */ |
| 158 srtp_err_status_t srtp_crypto_kernel_list_debug_modules(void); |
| 159 |
| 160 /* |
| 161 * srtp_crypto_kernel_load_cipher_type() |
| 162 * |
| 163 */ |
| 164 srtp_err_status_t srtp_crypto_kernel_load_cipher_type(const srtp_cipher_type_t *
ct, srtp_cipher_type_id_t id); |
| 165 |
| 166 srtp_err_status_t srtp_crypto_kernel_load_auth_type(const srtp_auth_type_t *ct,
srtp_auth_type_id_t id); |
| 167 |
| 168 srtp_err_status_t srtp_crypto_kernel_load_debug_module(srtp_debug_module_t *new_
dm); |
| 169 |
| 170 /* |
| 171 * srtp_crypto_kernel_alloc_cipher(id, cp, key_len); |
| 172 * |
| 173 * allocates a cipher of type id at location *cp, with key length |
| 174 * key_len octets. Return values are: |
| 175 * |
| 176 * srtp_err_status_ok no problems |
| 177 * srtp_err_status_alloc_fail an allocation failure occured |
| 178 * srtp_err_status_fail couldn't find cipher with identifier 'id' |
| 179 */ |
| 180 srtp_err_status_t srtp_crypto_kernel_alloc_cipher(srtp_cipher_type_id_t id, srtp
_cipher_pointer_t *cp, int key_len, int tag_len); |
| 181 |
| 182 /* |
| 183 * srtp_crypto_kernel_alloc_auth(id, ap, key_len, tag_len); |
| 184 * |
| 185 * allocates an auth function of type id at location *ap, with key |
| 186 * length key_len octets and output tag length of tag_len. Return |
| 187 * values are: |
| 188 * |
| 189 * srtp_err_status_ok no problems |
| 190 * srtp_err_status_alloc_fail an allocation failure occured |
| 191 * srtp_err_status_fail couldn't find auth with identifier 'id' |
| 192 */ |
| 193 srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id, srtp_aut
h_pointer_t *ap, int key_len, int tag_len); |
| 194 |
| 195 |
| 196 /* |
| 197 * srtp_crypto_kernel_set_debug_module(mod_name, v) |
| 198 * |
| 199 * sets dynamic debugging to the value v (0 for off, 1 for on) for the |
| 200 * debug module with the name mod_name |
| 201 * |
| 202 * returns srtp_err_status_ok on success, srtp_err_status_fail otherwise |
| 203 */ |
| 204 srtp_err_status_t srtp_crypto_kernel_set_debug_module(char *mod_name, int v); |
| 205 |
| 206 #ifdef __cplusplus |
| 207 } |
| 208 #endif |
| 209 |
| 210 #endif /* CRYPTO_KERNEL */ |
OLD | NEW |