4
* implements the do-nothing auth algorithm
13
* Copyright (c) 2001-2006, Cisco Systems, Inc.
14
* All rights reserved.
16
* Redistribution and use in source and binary forms, with or without
17
* modification, are permitted provided that the following conditions
20
* Redistributions of source code must retain the above copyright
21
* notice, this list of conditions and the following disclaimer.
23
* Redistributions in binary form must reproduce the above
24
* copyright notice, this list of conditions and the following
25
* disclaimer in the documentation and/or other materials provided
26
* with the distribution.
28
* Neither the name of the Cisco Systems, Inc. nor the names of its
29
* contributors may be used to endorse or promote products derived
30
* from this software without specific prior written permission.
32
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
36
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
37
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
39
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
43
* OF THE POSSIBILITY OF SUCH DAMAGE.
48
#include "null_auth.h"
51
/* null_auth uses the auth debug module */
53
extern debug_module_t mod_auth;
56
null_auth_alloc(auth_t **a, int key_len, int out_len) {
57
extern auth_type_t null_auth;
60
debug_print(mod_auth, "allocating auth func with key length %d", key_len);
61
debug_print(mod_auth, " tag length %d", out_len);
63
/* allocate memory for auth and null_auth_ctx_t structures */
64
pointer = (uint8_t*)crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(auth_t));
66
return err_status_alloc_fail;
69
*a = (auth_t *)pointer;
70
(*a)->type = &null_auth;
71
(*a)->state = pointer + sizeof (auth_t);
72
(*a)->out_len = out_len;
73
(*a)->prefix_len = out_len;
74
(*a)->key_len = key_len;
76
/* increment global count of all null_auth uses */
77
null_auth.ref_count++;
83
null_auth_dealloc(auth_t *a) {
84
extern auth_type_t null_auth;
86
/* zeroize entire state*/
87
octet_string_set_to_zero((uint8_t *)a,
88
sizeof(null_auth_ctx_t) + sizeof(auth_t));
93
/* decrement global count of all null_auth uses */
94
null_auth.ref_count--;
100
null_auth_init(null_auth_ctx_t *state, const uint8_t *key, int key_len) {
102
/* accept any length of key, and do nothing */
104
return err_status_ok;
108
null_auth_compute(null_auth_ctx_t *state, uint8_t *message,
109
int msg_octets, int tag_len, uint8_t *result) {
111
return err_status_ok;
115
null_auth_update(null_auth_ctx_t *state, uint8_t *message,
118
return err_status_ok;
122
null_auth_start(null_auth_ctx_t *state) {
123
return err_status_ok;
127
* auth_type_t - defines description, test case, and null_auth
131
/* begin test case 0 */
134
null_auth_test_case_0 = {
135
0, /* octets in key */
137
0, /* octets in data */
139
0, /* octets in tag */
141
NULL /* pointer to next testcase */
144
/* end test case 0 */
146
char null_auth_description[] = "null authentication function";
150
(auth_alloc_func) null_auth_alloc,
151
(auth_dealloc_func) null_auth_dealloc,
152
(auth_init_func) null_auth_init,
153
(auth_compute_func) null_auth_compute,
154
(auth_update_func) null_auth_update,
155
(auth_start_func) null_auth_start,
156
(char *) null_auth_description,
157
(int) 0, /* instance count */
158
(auth_test_case_t *) &null_auth_test_case_0