michael@0: /* michael@0: * aes_icm.c michael@0: * michael@0: * AES Integer Counter Mode michael@0: * michael@0: * David A. McGrew michael@0: * Cisco Systems, Inc. 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: #define ALIGN_32 0 michael@0: michael@0: #include "aes_icm.h" michael@0: #include "alloc.h" michael@0: michael@0: michael@0: debug_module_t mod_aes_icm = { michael@0: 0, /* debugging is off by default */ michael@0: "aes icm" /* printable module name */ michael@0: }; michael@0: michael@0: /* michael@0: * integer counter mode works as follows: michael@0: * michael@0: * 16 bits michael@0: * <-----> michael@0: * +------+------+------+------+------+------+------+------+ michael@0: * | nonce | pakcet index | ctr |---+ michael@0: * +------+------+------+------+------+------+------+------+ | michael@0: * | michael@0: * +------+------+------+------+------+------+------+------+ v michael@0: * | salt |000000|->(+) michael@0: * +------+------+------+------+------+------+------+------+ | michael@0: * | michael@0: * +---------+ michael@0: * | encrypt | michael@0: * +---------+ michael@0: * | michael@0: * +------+------+------+------+------+------+------+------+ | michael@0: * | keystream block |<--+ michael@0: * +------+------+------+------+------+------+------+------+ michael@0: * michael@0: * All fields are big-endian michael@0: * michael@0: * ctr is the block counter, which increments from zero for michael@0: * each packet (16 bits wide) michael@0: * michael@0: * packet index is distinct for each packet (48 bits wide) michael@0: * michael@0: * nonce can be distinct across many uses of the same key, or michael@0: * can be a fixed value per key, or can be per-packet randomness michael@0: * (64 bits) michael@0: * michael@0: */ michael@0: michael@0: err_status_t michael@0: aes_icm_alloc_ismacryp(cipher_t **c, int key_len, int forIsmacryp) { michael@0: extern cipher_type_t aes_icm; michael@0: uint8_t *pointer; michael@0: int tmp; michael@0: michael@0: debug_print(mod_aes_icm, michael@0: "allocating cipher with key length %d", key_len); michael@0: michael@0: /* michael@0: * Ismacryp, for example, uses 16 byte key + 8 byte michael@0: * salt so this function is called with key_len = 24. michael@0: * The check for key_len = 30/38/46 does not apply. Our usage michael@0: * of aes functions with key_len = values other than 30 michael@0: * has not broken anything. Don't know what would be the michael@0: * effect of skipping this check for srtp in general. michael@0: */ michael@0: if (!(forIsmacryp && key_len > 16 && key_len < 30) && michael@0: key_len != 30 && key_len != 38 && key_len != 46) michael@0: return err_status_bad_param; michael@0: michael@0: /* allocate memory a cipher of type aes_icm */ michael@0: tmp = (sizeof(aes_icm_ctx_t) + sizeof(cipher_t)); michael@0: pointer = (uint8_t*)crypto_alloc(tmp); michael@0: if (pointer == NULL) michael@0: return err_status_alloc_fail; michael@0: michael@0: /* set pointers */ michael@0: *c = (cipher_t *)pointer; michael@0: (*c)->type = &aes_icm; michael@0: (*c)->state = pointer + sizeof(cipher_t); michael@0: michael@0: /* increment ref_count */ michael@0: aes_icm.ref_count++; michael@0: michael@0: /* set key size */ michael@0: (*c)->key_len = key_len; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t aes_icm_alloc(cipher_t **c, int key_len, int forIsmacryp) { michael@0: return aes_icm_alloc_ismacryp(c, key_len, 0); michael@0: } michael@0: michael@0: err_status_t michael@0: aes_icm_dealloc(cipher_t *c) { michael@0: extern cipher_type_t aes_icm; michael@0: michael@0: /* zeroize entire state*/ michael@0: octet_string_set_to_zero((uint8_t *)c, michael@0: sizeof(aes_icm_ctx_t) + sizeof(cipher_t)); michael@0: michael@0: /* free memory */ michael@0: crypto_free(c); michael@0: michael@0: /* decrement ref_count */ michael@0: aes_icm.ref_count--; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: michael@0: /* michael@0: * aes_icm_context_init(...) initializes the aes_icm_context michael@0: * using the value in key[]. michael@0: * michael@0: * the key is the secret key michael@0: * michael@0: * the salt is unpredictable (but not necessarily secret) data which michael@0: * randomizes the starting point in the keystream michael@0: */ michael@0: michael@0: err_status_t michael@0: aes_icm_context_init(aes_icm_ctx_t *c, const uint8_t *key, int key_len) { michael@0: err_status_t status; michael@0: int base_key_len, copy_len; michael@0: michael@0: if (key_len > 16 && key_len < 30) /* Ismacryp */ michael@0: base_key_len = 16; michael@0: else if (key_len == 30 || key_len == 38 || key_len == 46) michael@0: base_key_len = key_len - 14; michael@0: else michael@0: return err_status_bad_param; michael@0: michael@0: /* michael@0: * set counter and initial values to 'offset' value, being careful not to michael@0: * go past the end of the key buffer michael@0: */ michael@0: v128_set_to_zero(&c->counter); michael@0: v128_set_to_zero(&c->offset); michael@0: michael@0: copy_len = key_len - base_key_len; michael@0: /* force last two octets of the offset to be left zero (for srtp compatibility) */ michael@0: if (copy_len > 14) michael@0: copy_len = 14; michael@0: michael@0: memcpy(&c->counter, key + base_key_len, copy_len); michael@0: memcpy(&c->offset, key + base_key_len, copy_len); michael@0: michael@0: debug_print(mod_aes_icm, michael@0: "key: %s", octet_string_hex_string(key, base_key_len)); michael@0: debug_print(mod_aes_icm, michael@0: "offset: %s", v128_hex_string(&c->offset)); michael@0: michael@0: /* expand key */ michael@0: status = aes_expand_encryption_key(key, base_key_len, &c->expanded_key); michael@0: if (status) { michael@0: v128_set_to_zero(&c->counter); michael@0: v128_set_to_zero(&c->offset); michael@0: return status; michael@0: } michael@0: michael@0: /* indicate that the keystream_buffer is empty */ michael@0: c->bytes_in_buffer = 0; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: /* michael@0: * aes_icm_set_octet(c, i) sets the counter of the context which it is michael@0: * passed so that the next octet of keystream that will be generated michael@0: * is the ith octet michael@0: */ michael@0: michael@0: err_status_t michael@0: aes_icm_set_octet(aes_icm_ctx_t *c, michael@0: uint64_t octet_num) { michael@0: michael@0: #ifdef NO_64BIT_MATH michael@0: int tail_num = low32(octet_num) & 0x0f; michael@0: /* 64-bit right-shift 4 */ michael@0: uint64_t block_num = make64(high32(octet_num) >> 4, michael@0: ((high32(octet_num) & 0x0f)<<(32-4)) | michael@0: (low32(octet_num) >> 4)); michael@0: #else michael@0: int tail_num = (int)(octet_num % 16); michael@0: uint64_t block_num = octet_num / 16; michael@0: #endif michael@0: michael@0: michael@0: /* set counter value */ michael@0: /* FIX - There's no way this is correct */ michael@0: c->counter.v64[0] = c->offset.v64[0]; michael@0: #ifdef NO_64BIT_MATH michael@0: c->counter.v64[0] = make64(high32(c->offset.v64[0]) ^ high32(block_num), michael@0: low32(c->offset.v64[0]) ^ low32(block_num)); michael@0: #else michael@0: c->counter.v64[0] = c->offset.v64[0] ^ block_num; michael@0: #endif michael@0: michael@0: debug_print(mod_aes_icm, michael@0: "set_octet: %s", v128_hex_string(&c->counter)); michael@0: michael@0: /* fill keystream buffer, if needed */ michael@0: if (tail_num) { michael@0: v128_copy(&c->keystream_buffer, &c->counter); michael@0: aes_encrypt(&c->keystream_buffer, &c->expanded_key); michael@0: c->bytes_in_buffer = sizeof(v128_t); michael@0: michael@0: debug_print(mod_aes_icm, "counter: %s", michael@0: v128_hex_string(&c->counter)); michael@0: debug_print(mod_aes_icm, "ciphertext: %s", michael@0: v128_hex_string(&c->keystream_buffer)); michael@0: michael@0: /* indicate number of bytes in keystream_buffer */ michael@0: c->bytes_in_buffer = sizeof(v128_t) - tail_num; michael@0: michael@0: } else { michael@0: michael@0: /* indicate that keystream_buffer is empty */ michael@0: c->bytes_in_buffer = 0; michael@0: } michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: /* michael@0: * aes_icm_set_iv(c, iv) sets the counter value to the exor of iv with michael@0: * the offset michael@0: */ michael@0: michael@0: err_status_t michael@0: aes_icm_set_iv(aes_icm_ctx_t *c, void *iv) { michael@0: v128_t *nonce = (v128_t *) iv; michael@0: michael@0: debug_print(mod_aes_icm, michael@0: "setting iv: %s", v128_hex_string(nonce)); michael@0: michael@0: v128_xor(&c->counter, &c->offset, nonce); michael@0: michael@0: debug_print(mod_aes_icm, michael@0: "set_counter: %s", v128_hex_string(&c->counter)); michael@0: michael@0: /* indicate that the keystream_buffer is empty */ michael@0: c->bytes_in_buffer = 0; michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: michael@0: michael@0: /* michael@0: * aes_icm_advance(...) refills the keystream_buffer and michael@0: * advances the block index of the sicm_context forward by one michael@0: * michael@0: * this is an internal, hopefully inlined function michael@0: */ michael@0: michael@0: static inline void michael@0: aes_icm_advance_ismacryp(aes_icm_ctx_t *c, uint8_t forIsmacryp) { michael@0: /* fill buffer with new keystream */ michael@0: v128_copy(&c->keystream_buffer, &c->counter); michael@0: aes_encrypt(&c->keystream_buffer, &c->expanded_key); michael@0: c->bytes_in_buffer = sizeof(v128_t); michael@0: michael@0: debug_print(mod_aes_icm, "counter: %s", michael@0: v128_hex_string(&c->counter)); michael@0: debug_print(mod_aes_icm, "ciphertext: %s", michael@0: v128_hex_string(&c->keystream_buffer)); michael@0: michael@0: /* clock counter forward */ michael@0: michael@0: if (forIsmacryp) { michael@0: uint32_t temp; michael@0: //alex's clock counter forward michael@0: temp = ntohl(c->counter.v32[3]); michael@0: c->counter.v32[3] = htonl(++temp); michael@0: } else { michael@0: if (!++(c->counter.v8[15])) michael@0: ++(c->counter.v8[14]); michael@0: } michael@0: } michael@0: michael@0: static inline void aes_icm_advance(aes_icm_ctx_t *c) { michael@0: aes_icm_advance_ismacryp(c, 0); michael@0: } michael@0: michael@0: michael@0: /*e michael@0: * icm_encrypt deals with the following cases: michael@0: * michael@0: * bytes_to_encr < bytes_in_buffer michael@0: * - add keystream into data michael@0: * michael@0: * bytes_to_encr > bytes_in_buffer michael@0: * - add keystream into data until keystream_buffer is depleted michael@0: * - loop over blocks, filling keystream_buffer and then michael@0: * adding keystream into data michael@0: * - fill buffer then add in remaining (< 16) bytes of keystream michael@0: */ michael@0: michael@0: err_status_t michael@0: aes_icm_encrypt_ismacryp(aes_icm_ctx_t *c, michael@0: unsigned char *buf, unsigned int *enc_len, michael@0: int forIsmacryp) { michael@0: unsigned int bytes_to_encr = *enc_len; michael@0: unsigned int i; michael@0: uint32_t *b; michael@0: michael@0: /* check that there's enough segment left but not for ismacryp*/ michael@0: if (!forIsmacryp && (bytes_to_encr + htons(c->counter.v16[7])) > 0xffff) michael@0: return err_status_terminus; michael@0: michael@0: debug_print(mod_aes_icm, "block index: %d", michael@0: htons(c->counter.v16[7])); michael@0: if (bytes_to_encr <= (unsigned int)c->bytes_in_buffer) { michael@0: michael@0: /* deal with odd case of small bytes_to_encr */ michael@0: for (i = (sizeof(v128_t) - c->bytes_in_buffer); michael@0: i < (sizeof(v128_t) - c->bytes_in_buffer + bytes_to_encr); i++) michael@0: { michael@0: *buf++ ^= c->keystream_buffer.v8[i]; michael@0: } michael@0: michael@0: c->bytes_in_buffer -= bytes_to_encr; michael@0: michael@0: /* return now to avoid the main loop */ michael@0: return err_status_ok; michael@0: michael@0: } else { michael@0: michael@0: /* encrypt bytes until the remaining data is 16-byte aligned */ michael@0: for (i=(sizeof(v128_t) - c->bytes_in_buffer); i < sizeof(v128_t); i++) michael@0: *buf++ ^= c->keystream_buffer.v8[i]; michael@0: michael@0: bytes_to_encr -= c->bytes_in_buffer; michael@0: c->bytes_in_buffer = 0; michael@0: michael@0: } michael@0: michael@0: /* now loop over entire 16-byte blocks of keystream */ michael@0: for (i=0; i < (bytes_to_encr/sizeof(v128_t)); i++) { michael@0: michael@0: /* fill buffer with new keystream */ michael@0: aes_icm_advance_ismacryp(c, forIsmacryp); michael@0: michael@0: /* michael@0: * add keystream into the data buffer (this would be a lot faster michael@0: * if we could assume 32-bit alignment!) michael@0: */ michael@0: michael@0: #if ALIGN_32 michael@0: b = (uint32_t *)buf; michael@0: *b++ ^= c->keystream_buffer.v32[0]; michael@0: *b++ ^= c->keystream_buffer.v32[1]; michael@0: *b++ ^= c->keystream_buffer.v32[2]; michael@0: *b++ ^= c->keystream_buffer.v32[3]; michael@0: buf = (uint8_t *)b; michael@0: #else michael@0: if ((((unsigned long) buf) & 0x03) != 0) { michael@0: *buf++ ^= c->keystream_buffer.v8[0]; michael@0: *buf++ ^= c->keystream_buffer.v8[1]; michael@0: *buf++ ^= c->keystream_buffer.v8[2]; michael@0: *buf++ ^= c->keystream_buffer.v8[3]; michael@0: *buf++ ^= c->keystream_buffer.v8[4]; michael@0: *buf++ ^= c->keystream_buffer.v8[5]; michael@0: *buf++ ^= c->keystream_buffer.v8[6]; michael@0: *buf++ ^= c->keystream_buffer.v8[7]; michael@0: *buf++ ^= c->keystream_buffer.v8[8]; michael@0: *buf++ ^= c->keystream_buffer.v8[9]; michael@0: *buf++ ^= c->keystream_buffer.v8[10]; michael@0: *buf++ ^= c->keystream_buffer.v8[11]; michael@0: *buf++ ^= c->keystream_buffer.v8[12]; michael@0: *buf++ ^= c->keystream_buffer.v8[13]; michael@0: *buf++ ^= c->keystream_buffer.v8[14]; michael@0: *buf++ ^= c->keystream_buffer.v8[15]; michael@0: } else { michael@0: b = (uint32_t *)buf; michael@0: *b++ ^= c->keystream_buffer.v32[0]; michael@0: *b++ ^= c->keystream_buffer.v32[1]; michael@0: *b++ ^= c->keystream_buffer.v32[2]; michael@0: *b++ ^= c->keystream_buffer.v32[3]; michael@0: buf = (uint8_t *)b; michael@0: } michael@0: #endif /* #if ALIGN_32 */ michael@0: michael@0: } michael@0: michael@0: /* if there is a tail end of the data, process it */ michael@0: if ((bytes_to_encr & 0xf) != 0) { michael@0: michael@0: /* fill buffer with new keystream */ michael@0: aes_icm_advance_ismacryp(c, forIsmacryp); michael@0: michael@0: for (i=0; i < (bytes_to_encr & 0xf); i++) michael@0: *buf++ ^= c->keystream_buffer.v8[i]; michael@0: michael@0: /* reset the keystream buffer size to right value */ michael@0: c->bytes_in_buffer = sizeof(v128_t) - i; michael@0: } else { michael@0: michael@0: /* no tail, so just reset the keystream buffer size to zero */ michael@0: c->bytes_in_buffer = 0; michael@0: michael@0: } michael@0: michael@0: return err_status_ok; michael@0: } michael@0: michael@0: err_status_t michael@0: aes_icm_encrypt(aes_icm_ctx_t *c, unsigned char *buf, unsigned int *enc_len) { michael@0: return aes_icm_encrypt_ismacryp(c, buf, enc_len, 0); michael@0: } michael@0: michael@0: err_status_t michael@0: aes_icm_output(aes_icm_ctx_t *c, uint8_t *buffer, int num_octets_to_output) { michael@0: unsigned int len = num_octets_to_output; michael@0: michael@0: /* zeroize the buffer */ michael@0: octet_string_set_to_zero(buffer, num_octets_to_output); michael@0: michael@0: /* exor keystream into buffer */ michael@0: return aes_icm_encrypt(c, buffer, &len); michael@0: } michael@0: michael@0: michael@0: char michael@0: aes_icm_description[] = "aes integer counter mode"; michael@0: michael@0: uint8_t aes_icm_test_case_0_key[30] = { michael@0: 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, michael@0: 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, michael@0: 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, michael@0: 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_0_nonce[16] = { michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_0_plaintext[32] = { michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_0_ciphertext[32] = { michael@0: 0xe0, 0x3e, 0xad, 0x09, 0x35, 0xc9, 0x5e, 0x80, michael@0: 0xe1, 0x66, 0xb1, 0x6d, 0xd9, 0x2b, 0x4e, 0xb4, michael@0: 0xd2, 0x35, 0x13, 0x16, 0x2b, 0x02, 0xd0, 0xf7, michael@0: 0x2a, 0x43, 0xa2, 0xfe, 0x4a, 0x5f, 0x97, 0xab michael@0: }; michael@0: michael@0: cipher_test_case_t aes_icm_test_case_0 = { michael@0: 30, /* octets in key */ michael@0: aes_icm_test_case_0_key, /* key */ michael@0: aes_icm_test_case_0_nonce, /* packet index */ michael@0: 32, /* octets in plaintext */ michael@0: aes_icm_test_case_0_plaintext, /* plaintext */ michael@0: 32, /* octets in ciphertext */ michael@0: aes_icm_test_case_0_ciphertext, /* ciphertext */ michael@0: NULL /* pointer to next testcase */ michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_1_key[46] = { michael@0: 0x57, 0xf8, 0x2f, 0xe3, 0x61, 0x3f, 0xd1, 0x70, michael@0: 0xa8, 0x5e, 0xc9, 0x3c, 0x40, 0xb1, 0xf0, 0x92, michael@0: 0x2e, 0xc4, 0xcb, 0x0d, 0xc0, 0x25, 0xb5, 0x82, michael@0: 0x72, 0x14, 0x7c, 0xc4, 0x38, 0x94, 0x4a, 0x98, michael@0: 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, michael@0: 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_1_nonce[16] = { michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_1_plaintext[32] = { michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, michael@0: }; michael@0: michael@0: uint8_t aes_icm_test_case_1_ciphertext[32] = { michael@0: 0x92, 0xbd, 0xd2, 0x8a, 0x93, 0xc3, 0xf5, 0x25, michael@0: 0x11, 0xc6, 0x77, 0xd0, 0x8b, 0x55, 0x15, 0xa4, michael@0: 0x9d, 0xa7, 0x1b, 0x23, 0x78, 0xa8, 0x54, 0xf6, michael@0: 0x70, 0x50, 0x75, 0x6d, 0xed, 0x16, 0x5b, 0xac michael@0: }; michael@0: michael@0: cipher_test_case_t aes_icm_test_case_1 = { michael@0: 46, /* octets in key */ michael@0: aes_icm_test_case_1_key, /* key */ michael@0: aes_icm_test_case_1_nonce, /* packet index */ michael@0: 32, /* octets in plaintext */ michael@0: aes_icm_test_case_1_plaintext, /* plaintext */ michael@0: 32, /* octets in ciphertext */ michael@0: aes_icm_test_case_1_ciphertext, /* ciphertext */ michael@0: &aes_icm_test_case_0 /* pointer to next testcase */ michael@0: }; michael@0: michael@0: michael@0: michael@0: /* michael@0: * note: the encrypt function is identical to the decrypt function michael@0: */ michael@0: michael@0: cipher_type_t aes_icm = { michael@0: (cipher_alloc_func_t) aes_icm_alloc, michael@0: (cipher_dealloc_func_t) aes_icm_dealloc, michael@0: (cipher_init_func_t) aes_icm_context_init, michael@0: (cipher_encrypt_func_t) aes_icm_encrypt, michael@0: (cipher_decrypt_func_t) aes_icm_encrypt, michael@0: (cipher_set_iv_func_t) aes_icm_set_iv, michael@0: (char *) aes_icm_description, michael@0: (int) 0, /* instance count */ michael@0: (cipher_test_case_t *) &aes_icm_test_case_1, michael@0: (debug_module_t *) &mod_aes_icm, michael@0: (cipher_type_id_t) AES_ICM michael@0: }; michael@0: