Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: crypto/include/auth.h

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crypto/include/alloc.h ('k') | crypto/include/cipher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * auth.h
3 *
4 * common interface to authentication functions
5 *
6 * David A. McGrew
7 * Cisco Systems, Inc.
8 */
9
10 /*
11 *
12 * Copyright (c) 2001-2006, Cisco Systems, Inc.
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * Redistributions in binary form must reproduce the above
23 * copyright notice, this list of conditions and the following
24 * disclaimer in the documentation and/or other materials provided
25 * with the distribution.
26 *
27 * Neither the name of the Cisco Systems, Inc. nor the names of its
28 * contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42 * OF THE POSSIBILITY OF SUCH DAMAGE.
43 *
44 */
45
46 #ifndef AUTH_H
47 #define AUTH_H
48
49 #include "srtp.h"
50 #include "crypto_types.h" /* for values of auth_type_id_t */
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 typedef const struct srtp_auth_type_t *srtp_auth_type_pointer;
57 typedef struct srtp_auth_t *srtp_auth_pointer_t;
58
59 typedef srtp_err_status_t (*srtp_auth_alloc_func)
60 (srtp_auth_pointer_t *ap, int key_len, int out_len);
61
62 typedef srtp_err_status_t (*srtp_auth_init_func)
63 (void *state, const uint8_t *key, int key_len);
64
65 typedef srtp_err_status_t (*srtp_auth_dealloc_func)(srtp_auth_pointer_t ap);
66
67 typedef srtp_err_status_t (*srtp_auth_compute_func)
68 (void *state, const uint8_t *buffer, int octets_to_auth,
69 int tag_len, uint8_t *tag);
70
71 typedef srtp_err_status_t (*srtp_auth_update_func)
72 (void *state, const uint8_t *buffer, int octets_to_auth);
73
74 typedef srtp_err_status_t (*srtp_auth_start_func)(void *state);
75
76 /* some syntactic sugar on these function types */
77 #define srtp_auth_type_alloc(at, a, klen, outlen) \
78 ((at)->alloc((a), (klen), (outlen)))
79
80 #define srtp_auth_init(a, key) \
81 (((a)->type)->init((a)->state, (key), ((a)->key_len)))
82
83 #define srtp_auth_compute(a, buf, len, res) \
84 (((a)->type)->compute((a)->state, (buf), (len), (a)->out_len, (res)))
85
86 #define srtp_auth_update(a, buf, len) \
87 (((a)->type)->update((a)->state, (buf), (len)))
88
89 #define srtp_auth_start(a)(((a)->type)->start((a)->state))
90
91 #define srtp_auth_dealloc(c) (((c)->type)->dealloc(c))
92
93 /* functions to get information about a particular auth_t */
94 int srtp_auth_get_key_length(const struct srtp_auth_t *a);
95
96 int srtp_auth_get_tag_length(const struct srtp_auth_t *a);
97
98 int srtp_auth_get_prefix_length(const struct srtp_auth_t *a);
99
100 /*
101 * srtp_auth_test_case_t is a (list of) key/message/tag values that are
102 * known to be correct for a particular cipher. this data can be used
103 * to test an implementation in an on-the-fly self test of the
104 * correctness of the implementation. (see the srtp_auth_type_self_test()
105 * function below)
106 */
107 typedef struct srtp_auth_test_case_t {
108 int key_length_octets; /* octets in key */
109 const uint8_t *key; /* key */
110 int data_length_octets; /* octets in data */
111 const uint8_t *data; /* data */
112 int tag_length_octets; /* octets in tag */
113 const uint8_t *tag; /* tag */
114 const struct srtp_auth_test_case_t *next_test_case; /* pointer to next testc ase */
115 } srtp_auth_test_case_t;
116
117 /* srtp_auth_type_t */
118 typedef struct srtp_auth_type_t {
119 srtp_auth_alloc_func alloc;
120 srtp_auth_dealloc_func dealloc;
121 srtp_auth_init_func init;
122 srtp_auth_compute_func compute;
123 srtp_auth_update_func update;
124 srtp_auth_start_func start;
125 const char *description;
126 const srtp_auth_test_case_t *test_data;
127 srtp_auth_type_id_t id;
128 } srtp_auth_type_t;
129
130 typedef struct srtp_auth_t {
131 const srtp_auth_type_t *type;
132 void *state;
133 int out_len; /* length of output tag in octets */
134 int key_len; /* length of key in octets */
135 int prefix_len; /* length of keystream prefix */
136 } srtp_auth_t;
137
138 /*
139 * srtp_auth_type_self_test() tests an auth_type against test cases
140 * provided in an array of values of key/message/tag that is known to
141 * be good
142 */
143 srtp_err_status_t srtp_auth_type_self_test(const srtp_auth_type_t *at);
144
145 /*
146 * srtp_auth_type_test() tests an auth_type against external test cases
147 * provided in an array of values of key/message/tag that is known to
148 * be good
149 */
150 srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at,
151 const srtp_auth_test_case_t *test_data);
152
153 /*
154 * srtp_replace_auth_type(ct, id)
155 *
156 * replaces srtp's kernel's auth type implementation for the auth_type id
157 * with a new one passed in externally. The new auth type must pass all the
158 * existing auth_type's self tests as well as its own.
159 */
160 srtp_err_status_t srtp_replace_auth_type(const srtp_auth_type_t *ct, srtp_auth_t ype_id_t id);
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #endif /* AUTH_H */
OLDNEW
« no previous file with comments | « crypto/include/alloc.h ('k') | crypto/include/cipher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698