webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
auth.h
Go to the documentation of this file.
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 
58 
60  (srtp_auth_pointer_t *ap, int key_len, int out_len);
61 
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 
68  (void *state, const uint8_t *buffer, int octets_to_auth,
69  int tag_len, uint8_t *tag);
70 
72  (void *state, const uint8_t *buffer, int octets_to_auth);
73 
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 testcase */
116 
117 /* srtp_auth_type_t */
118 typedef struct srtp_auth_type_t {
125  const char *description;
129 
130 typedef struct srtp_auth_t {
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  */
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  */
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  */
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* AUTH_H */
srtp_err_status_t(* srtp_auth_dealloc_func)(srtp_auth_pointer_t ap)
Definition: auth.h:65
srtp_err_status_t(* srtp_auth_update_func)(void *state, const uint8_t *buffer, int octets_to_auth)
Definition: auth.h:72
const struct srtp_auth_type_t * srtp_auth_type_pointer
Definition: auth.h:56
int key_length_octets
Definition: auth.h:108
srtp_err_status_t(* srtp_auth_start_func)(void *state)
Definition: auth.h:74
Definition: auth.h:107
const uint8_t * tag
Definition: auth.h:113
srtp_auth_type_id_t id
Definition: auth.h:127
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
srtp_err_status_t srtp_auth_type_self_test(const srtp_auth_type_t *at)
Definition: auth.c:186
srtp_auth_dealloc_func dealloc
Definition: auth.h:120
srtp_auth_alloc_func alloc
Definition: auth.h:119
srtp_auth_init_func init
Definition: auth.h:121
int srtp_auth_get_prefix_length(const struct srtp_auth_t *a)
int prefix_len
Definition: auth.h:135
typename detail::at_dispatch< Seq, K, detail::has_at_method< Seq >::value >::type at
Definition: Brigand.h:300
DOMString tag
Definition: Notification.idl:66
Definition: auth.h:118
srtp_auth_start_func start
Definition: auth.h:124
int out_len
Definition: auth.h:133
const char * description
Definition: auth.h:125
srtp_err_status_t(* srtp_auth_init_func)(void *state, const uint8_t *key, int key_len)
Definition: auth.h:63
int tag_length_octets
Definition: auth.h:112
int srtp_auth_get_key_length(const struct srtp_auth_t *a)
struct srtp_auth_type_t srtp_auth_type_t
unsigned char uint8_t
Definition: ptypes.h:89
struct srtp_auth_test_case_t srtp_auth_test_case_t
int key_len
Definition: auth.h:134
struct srtp_auth_t * srtp_auth_pointer_t
Definition: auth.h:57
srtp_err_status_t(* srtp_auth_compute_func)(void *state, const uint8_t *buffer, int octets_to_auth, int tag_len, uint8_t *tag)
Definition: auth.h:68
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
struct srtp_auth_t srtp_auth_t
int srtp_auth_get_tag_length(const struct srtp_auth_t *a)
srtp_auth_compute_func compute
Definition: auth.h:122
#define buffer
Definition: xmlparse.c:622
const srtp_auth_type_t * type
Definition: auth.h:131
srtp_err_status_t(* srtp_auth_alloc_func)(srtp_auth_pointer_t *ap, int key_len, int out_len)
Definition: auth.h:60
int data_length_octets
Definition: auth.h:110
srtp_err_status_t srtp_replace_auth_type(const srtp_auth_type_t *ct, srtp_auth_type_id_t id)
Definition: crypto_kernel.c:451
const srtp_auth_test_case_t * test_data
Definition: auth.h:126
srtp_err_status_t
Definition: srtp.h:245
const uint8_t * key
Definition: auth.h:109
srtp_auth_update_func update
Definition: auth.h:123
const uint8_t * data
Definition: auth.h:111
CFArrayRef CFTypeRef key
Definition: AVFoundationCFSoftLinking.h:129
srtp_err_status_t srtp_auth_type_test(const srtp_auth_type_t *at, const srtp_auth_test_case_t *test_data)
Definition: auth.c:87
void * state
Definition: auth.h:132
string state
Definition: buildtests.py:34
const struct srtp_auth_test_case_t * next_test_case
Definition: auth.h:114
Definition: auth.h:130