| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * null_auth.c | |
| 3 * | |
| 4 * implements the do-nothing auth algorithm | |
| 5 * | |
| 6 * David A. McGrew | |
| 7 * Cisco Systems, Inc. | |
| 8 * | |
| 9 */ | |
| 10 | |
| 11 /* | |
| 12 * | |
| 13 * Copyright (c) 2001-2006, Cisco Systems, Inc. | |
| 14 * All rights reserved. | |
| 15 * | |
| 16 * Redistribution and use in source and binary forms, with or without | |
| 17 * modification, are permitted provided that the following conditions | |
| 18 * are met: | |
| 19 * | |
| 20 * Redistributions of source code must retain the above copyright | |
| 21 * notice, this list of conditions and the following disclaimer. | |
| 22 * | |
| 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. | |
| 27 * | |
| 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. | |
| 31 * | |
| 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. | |
| 44 * | |
| 45 */ | |
| 46 | |
| 47 #ifdef HAVE_CONFIG_H | |
| 48 #include <config.h> | |
| 49 #endif | |
| 50 | |
| 51 #include "null_auth.h" | |
| 52 #include "alloc.h" | |
| 53 | |
| 54 /* null_auth uses the auth debug module */ | |
| 55 | |
| 56 extern debug_module_t mod_auth; | |
| 57 | |
| 58 err_status_t | |
| 59 null_auth_alloc(auth_t **a, int key_len, int out_len) { | |
| 60 extern auth_type_t null_auth; | |
| 61 uint8_t *pointer; | |
| 62 | |
| 63 debug_print(mod_auth, "allocating auth func with key length %d", key_len); | |
| 64 debug_print(mod_auth, " tag length %d", out_len); | |
| 65 | |
| 66 /* allocate memory for auth and null_auth_ctx_t structures */ | |
| 67 pointer = (uint8_t*)crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(auth_t)); | |
| 68 if (pointer == NULL) | |
| 69 return err_status_alloc_fail; | |
| 70 | |
| 71 /* set pointers */ | |
| 72 *a = (auth_t *)pointer; | |
| 73 (*a)->type = &null_auth; | |
| 74 (*a)->state = pointer + sizeof (auth_t); | |
| 75 (*a)->out_len = out_len; | |
| 76 (*a)->prefix_len = out_len; | |
| 77 (*a)->key_len = key_len; | |
| 78 | |
| 79 /* increment global count of all null_auth uses */ | |
| 80 null_auth.ref_count++; | |
| 81 | |
| 82 return err_status_ok; | |
| 83 } | |
| 84 | |
| 85 err_status_t | |
| 86 null_auth_dealloc(auth_t *a) { | |
| 87 extern auth_type_t null_auth; | |
| 88 | |
| 89 /* zeroize entire state*/ | |
| 90 octet_string_set_to_zero((uint8_t *)a, | |
| 91 sizeof(null_auth_ctx_t) + sizeof(auth_t)); | |
| 92 | |
| 93 /* free memory */ | |
| 94 crypto_free(a); | |
| 95 | |
| 96 /* decrement global count of all null_auth uses */ | |
| 97 null_auth.ref_count--; | |
| 98 | |
| 99 return err_status_ok; | |
| 100 } | |
| 101 | |
| 102 err_status_t | |
| 103 null_auth_init(null_auth_ctx_t *state, const uint8_t *key, int key_len) { | |
| 104 | |
| 105 /* accept any length of key, and do nothing */ | |
| 106 | |
| 107 return err_status_ok; | |
| 108 } | |
| 109 | |
| 110 err_status_t | |
| 111 null_auth_compute(null_auth_ctx_t *state, uint8_t *message, | |
| 112 int msg_octets, int tag_len, uint8_t *result) { | |
| 113 | |
| 114 return err_status_ok; | |
| 115 } | |
| 116 | |
| 117 err_status_t | |
| 118 null_auth_update(null_auth_ctx_t *state, uint8_t *message, | |
| 119 int msg_octets) { | |
| 120 | |
| 121 return err_status_ok; | |
| 122 } | |
| 123 | |
| 124 err_status_t | |
| 125 null_auth_start(null_auth_ctx_t *state) { | |
| 126 return err_status_ok; | |
| 127 } | |
| 128 | |
| 129 /* | |
| 130 * auth_type_t - defines description, test case, and null_auth | |
| 131 * metaobject | |
| 132 */ | |
| 133 | |
| 134 /* begin test case 0 */ | |
| 135 | |
| 136 auth_test_case_t | |
| 137 null_auth_test_case_0 = { | |
| 138 0, /* octets in key */ | |
| 139 NULL, /* key */ | |
| 140 0, /* octets in data */ | |
| 141 NULL, /* data */ | |
| 142 0, /* octets in tag */ | |
| 143 NULL, /* tag */ | |
| 144 NULL /* pointer to next testcase */ | |
| 145 }; | |
| 146 | |
| 147 /* end test case 0 */ | |
| 148 | |
| 149 char null_auth_description[] = "null authentication function"; | |
| 150 | |
| 151 auth_type_t | |
| 152 null_auth = { | |
| 153 (auth_alloc_func) null_auth_alloc, | |
| 154 (auth_dealloc_func) null_auth_dealloc, | |
| 155 (auth_init_func) null_auth_init, | |
| 156 (auth_compute_func) null_auth_compute, | |
| 157 (auth_update_func) null_auth_update, | |
| 158 (auth_start_func) null_auth_start, | |
| 159 (char *) null_auth_description, | |
| 160 (int) 0, /* instance count */ | |
| 161 (auth_test_case_t *) &null_auth_test_case_0, | |
| 162 (debug_module_t *) NULL, | |
| 163 (auth_type_id_t) NULL_AUTH | |
| 164 }; | |
| 165 | |
| OLD | NEW |