webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
crypto_kernel.h
Go to the documentation of this file.
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 {
69 
70 /*
71  * linked list of cipher types
72  */
73 typedef struct srtp_kernel_cipher_type {
78 
79 /*
80  * linked list of auth types
81  */
82 typedef struct srtp_kernel_auth_type {
87 
88 /*
89  * linked list of debug modules
90  */
91 typedef struct srtp_kernel_debug_module {
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 types */
107  srtp_kernel_debug_module_t *debug_module_list; /* list of all debug modules */
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  */
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  */
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  */
152 
153 
154 /*
155  * srtp_crypto_kernel_list_debug_modules() outputs a list of debugging modules
156  *
157  */
159 
160 /*
161  * srtp_crypto_kernel_load_cipher_type()
162  *
163  */
165 
167 
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  */
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  */
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  */
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* CRYPTO_KERNEL */
srtp_err_status_t srtp_crypto_kernel_alloc_auth(srtp_auth_type_id_t id, srtp_auth_pointer_t *ap, int key_len, int tag_len)
Definition: crypto_kernel.c:514
srtp_err_status_t srtp_crypto_kernel_list_debug_modules(void)
Definition: crypto_kernel.c:256
srtp_kernel_cipher_type_t * cipher_type_list
Definition: crypto_kernel.h:105
uint32_t srtp_auth_type_id_t
An srtp_auth_type_id_t is an identifier for a particular authentication function. ...
Definition: srtp.h:235
Definition: crypto_kernel.h:103
srtp_kernel_debug_module_t * debug_module_list
Definition: crypto_kernel.h:107
Definition: cipher.h:142
struct srtp_kernel_debug_module srtp_kernel_debug_module_t
srtp_err_status_t srtp_crypto_kernel_status(void)
Definition: crypto_kernel.c:208
struct srtp_kernel_debug_module * next
Definition: crypto_kernel.h:93
srtp_auth_type_id_t id
Definition: crypto_kernel.h:83
Definition: crypto_kernel.h:82
const srtp_cipher_type_t * cipher_type
Definition: crypto_kernel.h:75
const srtp_auth_type_t * auth_type
Definition: crypto_kernel.h:84
struct srtp_kernel_auth_type * next
Definition: crypto_kernel.h:85
srtp_debug_module_t * mod
Definition: crypto_kernel.h:92
srtp_err_status_t srtp_crypto_kernel_load_debug_module(srtp_debug_module_t *new_dm)
Definition: crypto_kernel.c:534
Definition: auth.h:118
srtp_err_status_t srtp_crypto_kernel_set_debug_module(char *mod_name, int v)
Definition: crypto_kernel.c:569
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)
Definition: crypto_kernel.c:475
Definition: cipher.h:160
struct srtp_kernel_auth_type srtp_kernel_auth_type_t
Definition: err.h:110
Definition: crypto_kernel.h:67
srtp_crypto_kernel_state_t state
Definition: crypto_kernel.h:104
struct srtp_kernel_cipher_type srtp_kernel_cipher_type_t
srtp_err_status_t srtp_crypto_kernel_load_cipher_type(const srtp_cipher_type_t *ct, srtp_cipher_type_id_t id)
Definition: crypto_kernel.c:376
Definition: crypto_kernel.h:66
srtp_cipher_type_id_t id
Definition: crypto_kernel.h:74
const GLfloat * v
Definition: gl2.h:514
uint32_t srtp_cipher_type_id_t
A srtp_cipher_type_id_t is an identifier for a particular cipher type.
Definition: srtp.h:221
srtp_err_status_t srtp_crypto_kernel_init(void)
Definition: crypto_kernel.c:110
srtp_err_status_t
Definition: srtp.h:245
Definition: crypto_kernel.h:91
struct srtp_kernel_cipher_type * next
Definition: crypto_kernel.h:76
srtp_kernel_auth_type_t * auth_type_list
Definition: crypto_kernel.h:106
srtp_err_status_t srtp_crypto_kernel_shutdown(void)
Definition: crypto_kernel.c:275
srtp_crypto_kernel_state_t
Definition: crypto_kernel.h:65
Definition: crypto_kernel.h:73
srtp_err_status_t srtp_crypto_kernel_load_auth_type(const srtp_auth_type_t *ct, srtp_auth_type_id_t id)
Definition: crypto_kernel.c:446
Definition: auth.h:130