| OLD | NEW |
| 1 /* | 1 /* |
| 2 * null_cipher.c | 2 * null_cipher.c |
| 3 * | 3 * |
| 4 * A null cipher implementation. This cipher leaves the plaintext | 4 * A null cipher implementation. This cipher leaves the plaintext |
| 5 * unchanged. | 5 * unchanged. |
| 6 * | 6 * |
| 7 * David A. McGrew | 7 * David A. McGrew |
| 8 * Cisco Systems, Inc. | 8 * Cisco Systems, Inc. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 /* | 11 /* |
| 12 * | 12 * |
| 13 * Copyright (c) 2001-2006, Cisco Systems, Inc. | 13 * Copyright (c) 2001-2006,2013 Cisco Systems, Inc. |
| 14 * All rights reserved. | 14 * All rights reserved. |
| 15 * | 15 * |
| 16 * Redistribution and use in source and binary forms, with or without | 16 * Redistribution and use in source and binary forms, with or without |
| 17 * modification, are permitted provided that the following conditions | 17 * modification, are permitted provided that the following conditions |
| 18 * are met: | 18 * are met: |
| 19 * | 19 * |
| 20 * Redistributions of source code must retain the above copyright | 20 * Redistributions of source code must retain the above copyright |
| 21 * notice, this list of conditions and the following disclaimer. | 21 * notice, this list of conditions and the following disclaimer. |
| 22 * | 22 * |
| 23 * Redistributions in binary form must reproduce the above | 23 * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 37 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 43 * OF THE POSSIBILITY OF SUCH DAMAGE. | 43 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 44 * | 44 * |
| 45 */ | 45 */ |
| 46 | 46 |
| 47 #ifdef HAVE_CONFIG_H |
| 48 #include <config.h> |
| 49 #endif |
| 50 |
| 47 #include "datatypes.h" | 51 #include "datatypes.h" |
| 48 #include "null_cipher.h" | 52 #include "null_cipher.h" |
| 49 #include "alloc.h" | 53 #include "alloc.h" |
| 50 | 54 |
| 51 /* the null_cipher uses the cipher debug module */ | 55 /* the null_cipher uses the cipher debug module */ |
| 52 | 56 |
| 53 extern debug_module_t mod_cipher; | 57 extern debug_module_t mod_cipher; |
| 54 | 58 |
| 55 err_status_t | 59 err_status_t |
| 56 null_cipher_alloc(cipher_t **c, int key_len) { | 60 null_cipher_alloc(cipher_t **c, int key_len, int tlen) { |
| 57 extern cipher_type_t null_cipher; | 61 extern cipher_type_t null_cipher; |
| 58 uint8_t *pointer; | 62 uint8_t *pointer; |
| 59 | 63 |
| 60 debug_print(mod_cipher, | 64 debug_print(mod_cipher, |
| 61 "allocating cipher with key length %d", key_len); | 65 "allocating cipher with key length %d", key_len); |
| 62 | 66 |
| 63 /* allocate memory a cipher of type null_cipher */ | 67 /* allocate memory a cipher of type null_cipher */ |
| 64 pointer = (uint8_t*)crypto_alloc(sizeof(null_cipher_ctx_t) + sizeof(cipher_t))
; | 68 pointer = (uint8_t*)crypto_alloc(sizeof(null_cipher_ctx_t) + sizeof(cipher_t))
; |
| 65 if (pointer == NULL) | 69 if (pointer == NULL) |
| 66 return err_status_alloc_fail; | 70 return err_status_alloc_fail; |
| 67 | 71 |
| 68 /* set pointers */ | 72 /* set pointers */ |
| 69 *c = (cipher_t *)pointer; | 73 *c = (cipher_t *)pointer; |
| 74 (*c)->algorithm = NULL_CIPHER; |
| 70 (*c)->type = &null_cipher; | 75 (*c)->type = &null_cipher; |
| 71 (*c)->state = pointer + sizeof(cipher_t); | 76 (*c)->state = pointer + sizeof(cipher_t); |
| 72 | 77 |
| 73 /* set key size */ | 78 /* set key size */ |
| 74 (*c)->key_len = key_len; | 79 (*c)->key_len = key_len; |
| 75 | 80 |
| 76 /* increment ref_count */ | 81 /* increment ref_count */ |
| 77 null_cipher.ref_count++; | 82 null_cipher.ref_count++; |
| 78 | 83 |
| 79 return err_status_ok; | 84 return err_status_ok; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 127 |
| 123 cipher_test_case_t | 128 cipher_test_case_t |
| 124 null_cipher_test_0 = { | 129 null_cipher_test_0 = { |
| 125 0, /* octets in key */ | 130 0, /* octets in key */ |
| 126 NULL, /* key */ | 131 NULL, /* key */ |
| 127 0, /* packet index */ | 132 0, /* packet index */ |
| 128 0, /* octets in plaintext */ | 133 0, /* octets in plaintext */ |
| 129 NULL, /* plaintext */ | 134 NULL, /* plaintext */ |
| 130 0, /* octets in plaintext */ | 135 0, /* octets in plaintext */ |
| 131 NULL, /* ciphertext */ | 136 NULL, /* ciphertext */ |
| 137 0, |
| 138 NULL, |
| 139 0, |
| 132 NULL /* pointer to next testcase */ | 140 NULL /* pointer to next testcase */ |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 | 143 |
| 136 /* | 144 /* |
| 137 * note: the decrypt function is idential to the encrypt function | 145 * note: the decrypt function is idential to the encrypt function |
| 138 */ | 146 */ |
| 139 | 147 |
| 140 cipher_type_t null_cipher = { | 148 cipher_type_t null_cipher = { |
| 141 (cipher_alloc_func_t) null_cipher_alloc, | 149 (cipher_alloc_func_t) null_cipher_alloc, |
| 142 (cipher_dealloc_func_t) null_cipher_dealloc, | 150 (cipher_dealloc_func_t) null_cipher_dealloc, |
| 143 (cipher_init_func_t) null_cipher_init, | 151 (cipher_init_func_t) null_cipher_init, |
| 152 (cipher_set_aad_func_t) 0, |
| 144 (cipher_encrypt_func_t) null_cipher_encrypt, | 153 (cipher_encrypt_func_t) null_cipher_encrypt, |
| 145 (cipher_decrypt_func_t) null_cipher_encrypt, | 154 (cipher_decrypt_func_t) null_cipher_encrypt, |
| 146 (cipher_set_iv_func_t) null_cipher_set_iv, | 155 (cipher_set_iv_func_t) null_cipher_set_iv, |
| 156 (cipher_get_tag_func_t) 0, |
| 147 (char *) null_cipher_description, | 157 (char *) null_cipher_description, |
| 148 (int) 0, | 158 (int) 0, |
| 149 (cipher_test_case_t *) &null_cipher_test_0, | 159 (cipher_test_case_t *) &null_cipher_test_0, |
| 150 (debug_module_t *) NULL, | 160 (debug_module_t *) NULL, |
| 151 (cipher_type_id_t) NULL_CIPHER | 161 (cipher_type_id_t) NULL_CIPHER |
| 152 }; | 162 }; |
| 153 | 163 |
| OLD | NEW |