michael@0: /* michael@0: * null_auth.c michael@0: * michael@0: * implements the do-nothing auth algorithm michael@0: * michael@0: * David A. McGrew michael@0: * Cisco Systems, Inc. michael@0: * michael@0: */ michael@0: michael@0: /* michael@0: * michael@0: * Copyright (c) 2001-2006, Cisco Systems, Inc. michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * Redistributions in binary form must reproduce the above michael@0: * copyright notice, this list of conditions and the following michael@0: * disclaimer in the documentation and/or other materials provided michael@0: * with the distribution. michael@0: * michael@0: * Neither the name of the Cisco Systems, Inc. nor the names of its michael@0: * contributors may be used to endorse or promote products derived michael@0: * from this software without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS michael@0: * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE michael@0: * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, michael@0: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES michael@0: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR michael@0: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) michael@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, michael@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) michael@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED michael@0: * OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: * michael@0: */ michael@0: michael@0: michael@0: #include "null_auth.h" michael@0: #include "alloc.h" michael@0: michael@0: /* null_auth uses the auth debug module */ michael@0: michael@0: extern debug_module_t mod_auth; michael@0: michael@0: err_status_t michael@0: null_auth_alloc(auth_t **a, int key_len, int out_len) { michael@0: extern auth_type_t null_auth; michael@0: uint8_t *pointer; michael@0: michael@0: debug_print(mod_auth, "allocating auth func with key length %d", key_len); michael@0: debug_print(mod_auth, " tag length %d", out_len); michael@0: michael@0: /* allocate memory for auth and null_auth_ctx_t structures */ michael@0: pointer = (uint8_t*)crypto_alloc(sizeof(null_auth_ctx_t) + sizeof(auth_t)); michael@0: if (pointer == NULL) michael@0: return err_status_alloc_fail; michael@0: michael@0: /* set pointers */ michael@0: *a = (auth_t *)pointer; michael@0: (*a)->type = &null_auth; michael@0: (*a)->state = pointer + sizeof (auth_t); michael@0: (*a)->out_len = out_len; michael@0: (*a)->prefix_len = out_len; michael@0: (*a)->key_len = key_len; michael@0: michael@0: /* increment global count of all null_auth uses */ michael@0: null_auth.ref_count++; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: null_auth_dealloc(auth_t *a) { michael@0: extern auth_type_t null_auth; michael@0: michael@0: /* zeroize entire state*/ michael@0: octet_string_set_to_zero((uint8_t *)a, michael@0: sizeof(null_auth_ctx_t) + sizeof(auth_t)); michael@0: michael@0: /* free memory */ michael@0: crypto_free(a); michael@0: michael@0: /* decrement global count of all null_auth uses */ michael@0: null_auth.ref_count--; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: null_auth_init(null_auth_ctx_t *state, const uint8_t *key, int key_len) { michael@0: michael@0: /* accept any length of key, and do nothing */ michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: null_auth_compute(null_auth_ctx_t *state, uint8_t *message, michael@0: int msg_octets, int tag_len, uint8_t *result) { michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: null_auth_update(null_auth_ctx_t *state, uint8_t *message, michael@0: int msg_octets) { michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: null_auth_start(null_auth_ctx_t *state) { michael@0: return err_status_ok; michael@0: } michael@0: michael@0: /* michael@0: * auth_type_t - defines description, test case, and null_auth michael@0: * metaobject michael@0: */ michael@0: michael@0: /* begin test case 0 */ michael@0: michael@0: auth_test_case_t michael@0: null_auth_test_case_0 = { michael@0: 0, /* octets in key */ michael@0: NULL, /* key */ michael@0: 0, /* octets in data */ michael@0: NULL, /* data */ michael@0: 0, /* octets in tag */ michael@0: NULL, /* tag */ michael@0: NULL /* pointer to next testcase */ michael@0: }; michael@0: michael@0: /* end test case 0 */ michael@0: michael@0: char null_auth_description[] = "null authentication function"; michael@0: michael@0: auth_type_t michael@0: null_auth = { michael@0: (auth_alloc_func) null_auth_alloc, michael@0: (auth_dealloc_func) null_auth_dealloc, michael@0: (auth_init_func) null_auth_init, michael@0: (auth_compute_func) null_auth_compute, michael@0: (auth_update_func) null_auth_update, michael@0: (auth_start_func) null_auth_start, michael@0: (char *) null_auth_description, michael@0: (int) 0, /* instance count */ michael@0: (auth_test_case_t *) &null_auth_test_case_0, michael@0: (debug_module_t *) NULL, michael@0: (auth_type_id_t) NULL_AUTH michael@0: }; michael@0: