OLD | NEW |
1 /* | 1 /* |
2 * null-cipher.h | 2 * aes_icm.h |
3 * | 3 * |
4 * header file for the null cipher | 4 * Header for AES Integer Counter Mode. |
5 * | |
6 * | 5 * |
7 * David A. McGrew | 6 * David A. McGrew |
8 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
| 8 * |
9 */ | 9 */ |
10 | |
11 /* | 10 /* |
12 *» | 11 * |
13 * Copyright (c) 2001-2006, Cisco Systems, Inc. | 12 * Copyright (c) 2001-2005,2012, Cisco Systems, Inc. |
14 * All rights reserved. | 13 * All rights reserved. |
15 * | 14 * |
16 * Redistribution and use in source and binary forms, with or without | 15 * Redistribution and use in source and binary forms, with or without |
17 * modification, are permitted provided that the following conditions | 16 * modification, are permitted provided that the following conditions |
18 * are met: | 17 * are met: |
19 * | 18 * |
20 * Redistributions of source code must retain the above copyright | 19 * Redistributions of source code must retain the above copyright |
21 * notice, this list of conditions and the following disclaimer. | 20 * notice, this list of conditions and the following disclaimer. |
22 * | 21 * |
23 * Redistributions in binary form must reproduce the above | 22 * Redistributions in binary form must reproduce the above |
24 * copyright notice, this list of conditions and the following | 23 * copyright notice, this list of conditions and the following |
25 * disclaimer in the documentation and/or other materials provided | 24 * disclaimer in the documentation and/or other materials provided |
26 * with the distribution. | 25 * with the distribution. |
27 * | 26 * |
28 * Neither the name of the Cisco Systems, Inc. nor the names of its | 27 * Neither the name of the Cisco Systems, Inc. nor the names of its |
29 * contributors may be used to endorse or promote products derived | 28 * contributors may be used to endorse or promote products derived |
30 * from this software without specific prior written permission. | 29 * from this software without specific prior written permission. |
31 * | 30 * |
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
35 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
36 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | 35 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
37 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 36 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
39 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
43 * OF THE POSSIBILITY OF SUCH DAMAGE. | 42 * OF THE POSSIBILITY OF SUCH DAMAGE. |
44 * | 43 * |
45 */ | 44 */ |
46 | 45 |
| 46 #ifndef AES_ICM_H |
| 47 #define AES_ICM_H |
47 | 48 |
48 #ifndef NULL_CIPHER_H | 49 #include "cipher.h" |
49 #define NULL_CIPHER_H | 50 #include <openssl/evp.h> |
| 51 #include <openssl/aes.h> |
50 | 52 |
51 #include "datatypes.h" | 53 #define SALT_SIZE 14 |
52 #include "cipher.h" | 54 #define AES_128_KEYSIZE AES_BLOCK_SIZE |
| 55 #define AES_192_KEYSIZE AES_BLOCK_SIZE + AES_BLOCK_SIZE / 2 |
| 56 #define AES_256_KEYSIZE AES_BLOCK_SIZE * 2 |
| 57 #define AES_128_KEYSIZE_WSALT AES_128_KEYSIZE + SALT_SIZE |
| 58 #define AES_192_KEYSIZE_WSALT AES_192_KEYSIZE + SALT_SIZE |
| 59 #define AES_256_KEYSIZE_WSALT AES_256_KEYSIZE + SALT_SIZE |
53 | 60 |
54 typedef struct { | 61 typedef struct { |
55 char foo ;/* empty, for now */ | 62 v128_t counter; /* holds the counter value */ |
56 } null_cipher_ctx_t; | 63 v128_t offset; /* initial offset value */ |
| 64 v256_t key; |
| 65 int key_size; |
| 66 EVP_CIPHER_CTX ctx; |
| 67 } aes_icm_ctx_t; |
| 68 |
| 69 err_status_t aes_icm_openssl_set_iv(aes_icm_ctx_t *c, void *iv, int dir); |
57 | 70 |
58 | 71 |
59 /* | 72 #endif /* AES_ICM_H */ |
60 * none of these functions do anything (though future versions may keep | |
61 * track of bytes encrypted, number of instances, and/or other info). | |
62 */ | |
63 | 73 |
64 err_status_t | |
65 null_cipher_init(null_cipher_ctx_t *c, const uint8_t *key, int key_len); | |
66 | |
67 err_status_t | |
68 null_cipher_set_segment(null_cipher_ctx_t *c, | |
69 unsigned long segment_index); | |
70 | |
71 err_status_t | |
72 null_cipher_encrypt(null_cipher_ctx_t *c, | |
73 unsigned char *buf, unsigned int *bytes_to_encr); | |
74 | |
75 | |
76 err_status_t | |
77 null_cipher_encrypt_aligned(null_cipher_ctx_t *c, | |
78 unsigned char *buf, int bytes_to_encr); | |
79 | |
80 #endif /* NULL_CIPHER_H */ | |
OLD | NEW |