diff options
Diffstat (limited to 'test/validation')
31 files changed, 5461 insertions, 4463 deletions
diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am index c08ff3d6e..ade387152 100644 --- a/test/validation/api/Makefile.am +++ b/test/validation/api/Makefile.am @@ -54,6 +54,7 @@ TESTS = \ init/init_feature_enabled$(EXEEXT) \ init/init_feature_disabled$(EXEEXT) \ init/init_test_param_init$(EXEEXT) \ + init/init_test_term_abnormal$(EXEEXT) \ ipsec/ipsec_sync$(EXEEXT) \ ipsec/ipsec_async$(EXEEXT) \ ipsec/ipsec_inline_in$(EXEEXT) \ diff --git a/test/validation/api/atomic/atomic.c b/test/validation/api/atomic/atomic.c index cbdd219fc..17d9dc82a 100644 --- a/test/validation/api/atomic/atomic.c +++ b/test/validation/api/atomic/atomic.c @@ -974,7 +974,7 @@ static int atomic_init(odp_instance_t *inst) odph_helper_options_t helper_options; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -982,18 +982,18 @@ static int atomic_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } global_shm = odp_shm_reserve(GLOBAL_SHM_NAME, sizeof(global_shared_mem_t), 64, 0); if (ODP_SHM_INVALID == global_shm) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); + ODPH_ERR("Unable to reserve memory for global_shm\n"); return -1; } @@ -1029,17 +1029,17 @@ static int atomic_term(odp_instance_t inst) shm = odp_shm_lookup(GLOBAL_SHM_NAME); if (0 != odp_shm_free(shm)) { - fprintf(stderr, "error: odp_shm_free() failed.\n"); + ODPH_ERR("odp_shm_free() failed\n"); return -1; } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/barrier/barrier.c b/test/validation/api/barrier/barrier.c index e0665b7cf..610b5db70 100644 --- a/test/validation/api/barrier/barrier.c +++ b/test/validation/api/barrier/barrier.c @@ -305,7 +305,7 @@ static int barrier_init(odp_instance_t *inst) odph_helper_options_t helper_options; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -313,18 +313,18 @@ static int barrier_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } global_shm = odp_shm_reserve(GLOBAL_SHM_NAME, sizeof(global_shared_mem_t), 64, 0); if (ODP_SHM_INVALID == global_shm) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); + ODPH_ERR("Unable to reserve memory for global_shm\n"); return -1; } @@ -360,17 +360,17 @@ static int barrier_term(odp_instance_t inst) shm = odp_shm_lookup(GLOBAL_SHM_NAME); if (0 != odp_shm_free(shm)) { - fprintf(stderr, "error: odp_shm_free() failed.\n"); + ODPH_ERR("odp_shm_free() failed\n"); return -1; } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/buffer/buffer.c b/test/validation/api/buffer/buffer.c index 2d9632342..ef26ea6e0 100644 --- a/test/validation/api/buffer/buffer.c +++ b/test/validation/api/buffer/buffer.c @@ -23,7 +23,7 @@ static int buffer_suite_init(void) uint32_t size, num, align; if (odp_pool_capability(&pool_capa)) { - printf("pool capability failed\n"); + ODPH_ERR("Pool capability failed\n"); return -1; } @@ -111,7 +111,7 @@ static void test_pool_alloc_free(const odp_pool_param_t *param) wrong_align = true; if (wrong_type || wrong_subtype || wrong_size || wrong_align) { - printf("Buffer has error\n"); + ODPH_ERR("Buffer has error\n"); odp_buffer_print(buffer[i]); break; } @@ -200,7 +200,7 @@ static void test_pool_alloc_free_multi(const odp_pool_param_t *param) wrong_align = true; if (wrong_type || wrong_subtype || wrong_size || wrong_align) { - printf("Buffer has error\n"); + ODPH_ERR("Buffer has error\n"); odp_buffer_print(buffer[i]); break; } @@ -351,7 +351,7 @@ static void test_pool_max_pools(odp_pool_param_t *param) CU_ASSERT(num_pool == max_pools); if (num_pool != max_pools) - printf("Error: created only %u pools\n", num_pool); + ODPH_ERR("Created only %u pools\n", num_pool); for (i = 0; i < num_pool; i++) { buffer[i] = odp_buffer_alloc(pool[i]); @@ -536,6 +536,8 @@ static void buffer_test_user_area(void) CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); for (i = 0; i < num; i++) { + odp_event_t ev; + buffer[i] = odp_buffer_alloc(pool); if (buffer[i] == ODP_BUFFER_INVALID) @@ -546,6 +548,9 @@ static void buffer_test_user_area(void) CU_ASSERT_FATAL(addr != NULL); CU_ASSERT(prev != addr); + ev = odp_buffer_to_event(buffer[i]); + CU_ASSERT(odp_event_user_area(ev) == addr); + prev = addr; memset(addr, 0, size); } diff --git a/test/validation/api/classification/odp_classification_tests.c b/test/validation/api/classification/odp_classification_tests.c index 002beb2aa..84dfcf562 100644 --- a/test/validation/api/classification/odp_classification_tests.c +++ b/test/validation/api/classification/odp_classification_tests.c @@ -70,7 +70,7 @@ static int classification_suite_common_init(odp_bool_t enable_pktv) ret = odp_pktio_capability(pktio_loop, &pktio_capa); if (ret) { - fprintf(stderr, "unable to get pktio capability.\n"); + ODPH_ERR("Unable to get pktio capability\n"); return -1; } diff --git a/test/validation/api/comp/comp.c b/test/validation/api/comp/comp.c index 88a61da95..cb771c989 100644 --- a/test/validation/api/comp/comp.c +++ b/test/validation/api/comp/comp.c @@ -5,6 +5,8 @@ */ #include <odp_api.h> +#include <odp/helper/odph_api.h> + #include <odp_cunit_common.h> #include "test_vectors.h" @@ -68,7 +70,7 @@ static int check_comp_alg_support(odp_comp_alg_t comp, return ODP_TEST_INACTIVE; break; default: - fprintf(stderr, "Unsupported compression algorithm\n"); + ODPH_ERR("Unsupported compression algorithm\n"); return ODP_TEST_INACTIVE; } @@ -87,7 +89,7 @@ static int check_comp_alg_support(odp_comp_alg_t comp, return ODP_TEST_INACTIVE; break; default: - fprintf(stderr, "Unsupported hash algorithm\n"); + ODPH_ERR("Unsupported hash algorithm\n"); return ODP_TEST_INACTIVE; } @@ -475,17 +477,17 @@ static int comp_init(odp_instance_t *inst) odp_pool_capability_t pool_capa; if (0 != odp_init_global(inst, NULL, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } if (odp_pool_capability(&pool_capa) < 0) { - fprintf(stderr, "error: odp_pool_capability() failed.\n"); + ODPH_ERR("odp_pool_capability() failed\n"); return -1; } @@ -497,20 +499,20 @@ static int comp_init(odp_instance_t *inst) if (pool_capa.pkt.max_seg_len && TEST_PKT_LEN > pool_capa.pkt.max_seg_len) { - fprintf(stderr, "Warning: small packet segment length\n"); + ODPH_ERR("Warning: small packet segment length\n"); params.pkt.seg_len = pool_capa.pkt.max_seg_len; } pool = odp_pool_create(COMP_PACKET_POOL, ¶ms); if (ODP_POOL_INVALID == pool) { - fprintf(stderr, "Packet pool creation failed.\n"); + ODPH_ERR("Packet pool creation failed\n"); return -1; } /* Queue to store compression/decompression events */ out_queue = odp_queue_create(COMP_OUT_QUEUE, NULL); if (ODP_QUEUE_INVALID == out_queue) { - fprintf(stderr, "Comp outq creation failed.\n"); + ODPH_ERR("Comp outq creation failed\n"); return -1; } @@ -525,26 +527,26 @@ static int comp_term(odp_instance_t inst) out_queue = odp_queue_lookup(COMP_OUT_QUEUE); if (ODP_QUEUE_INVALID != out_queue) { if (odp_queue_destroy(out_queue)) - fprintf(stderr, "Comp outq destroy failed.\n"); + ODPH_ERR("Comp outq destroy failed\n"); } else { - fprintf(stderr, "Comp outq not found.\n"); + ODPH_ERR("Comp outq not found\n"); } pool = odp_pool_lookup(COMP_PACKET_POOL); if (ODP_POOL_INVALID != pool) { if (odp_pool_destroy(pool)) - fprintf(stderr, "Packet pool destroy failed.\n"); + ODPH_ERR("Packet pool destroy failed\n"); } else { - fprintf(stderr, "Packet pool not found.\n"); + ODPH_ERR("Packet pool not found\n"); } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/crypto/Makefile.am b/test/validation/api/crypto/Makefile.am index e438ec8ca..ead21a336 100644 --- a/test/validation/api/crypto/Makefile.am +++ b/test/validation/api/crypto/Makefile.am @@ -3,6 +3,12 @@ include ../Makefile.inc test_PROGRAMS = crypto_main crypto_main_SOURCES = \ odp_crypto_test_inp.c \ + crypto_op_test.c \ + crypto_op_test.h \ test_vectors.h \ - test_vectors_len.h + test_vectors_len.h \ + test_vector_defs.h \ + util.h \ + util.c + PRELDADD += $(LIBPACKET_COMMON) diff --git a/test/validation/api/crypto/crypto_op_test.c b/test/validation/api/crypto/crypto_op_test.c new file mode 100644 index 000000000..4ad333488 --- /dev/null +++ b/test/validation/api/crypto/crypto_op_test.c @@ -0,0 +1,571 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <string.h> +#include <stdlib.h> +#include <odp_api.h> +#include <odp_cunit_common.h> +#include <packet_common.h> +#include "crypto_op_test.h" +#include "util.h" + +#define MAX_FAILURE_PRINTS 20 + +#define MAX_IGNORED_RANGES 3 + +/* + * Output packet parts that we ignore since they have undefined values + */ +typedef struct ignore_t { + uint32_t byte_offset; /* offset to a byte which has bits to be ignored */ + uint8_t byte_mask; /* mask of ignored bits in the byte */ + struct { + uint32_t offset; + uint32_t length; + } ranges[MAX_IGNORED_RANGES]; /* byte ranges to be ignored */ + uint32_t num_ranges; +} ignore_t; + +/* Add room for bytes that are not included in ref->length */ +#define MAX_EXP_DATA_LEN (MAX_DATA_LEN + 200) + +/* + * Expected packet data + */ +typedef struct expected_t { + uint8_t data[MAX_EXP_DATA_LEN]; + uint32_t len; + ignore_t ignore; +} expected_t; + +int crypto_op(odp_packet_t pkt_in, + odp_packet_t *pkt_out, + odp_bool_t *ok, + const odp_crypto_packet_op_param_t *op_params, + odp_crypto_op_type_t op_type) +{ + int rc; + odp_event_t event; + odp_crypto_packet_result_t result; + odp_event_subtype_t subtype; + odp_packet_t orig_pkt_out; + + if (op_type == ODP_CRYPTO_OP_TYPE_LEGACY) + *pkt_out = pkt_in; + else if (op_type == ODP_CRYPTO_OP_TYPE_BASIC) + *pkt_out = ODP_PACKET_INVALID; + orig_pkt_out = *pkt_out; + + if (suite_context.op_mode == ODP_CRYPTO_SYNC) { + rc = odp_crypto_op(&pkt_in, pkt_out, op_params, 1); + if (rc <= 0) { + CU_FAIL("Failed odp_crypto_packet_op()"); + goto fail; + } + } else { + odp_packet_t *out_param = pkt_out; + + if (op_type == ODP_CRYPTO_OP_TYPE_BASIC) + out_param = NULL; + + rc = odp_crypto_op_enq(&pkt_in, out_param, op_params, 1); + if (rc <= 0) { + CU_FAIL("Failed odp_crypto_op_enq()"); + goto fail; + } + + /* Get crypto completion event from compl_queue. */ + CU_ASSERT_FATAL(NULL != suite_context.compl_queue_deq); + do { + event = suite_context.compl_queue_deq(); + } while (event == ODP_EVENT_INVALID); + + CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event)); + CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); + + *pkt_out = odp_crypto_packet_from_event(event); + } + + if (op_type != ODP_CRYPTO_OP_TYPE_BASIC) + CU_ASSERT(*pkt_out == orig_pkt_out); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_type(odp_packet_to_event(*pkt_out))); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == + odp_event_subtype(odp_packet_to_event(*pkt_out))); + CU_ASSERT(ODP_EVENT_PACKET == + odp_event_types(odp_packet_to_event(*pkt_out), &subtype)); + CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); + CU_ASSERT(odp_packet_subtype(*pkt_out) == ODP_EVENT_PACKET_CRYPTO); + + rc = odp_crypto_result(&result, *pkt_out); + if (rc < -1) + CU_FAIL("Failed odp_crypto_result()"); + CU_ASSERT(rc == 0 || rc == -1); + + if (op_type == ODP_CRYPTO_OP_TYPE_OOP && + suite_context.op_mode == ODP_CRYPTO_ASYNC) + CU_ASSERT(result.pkt_in == pkt_in); + + *ok = (rc == 0); + +#if ODP_DEPRECATED_API + CU_ASSERT(*ok == result.ok); +#endif + + return 0; +fail: + odp_packet_free(pkt_in); + if (op_type == ODP_CRYPTO_OP_TYPE_OOP) + odp_packet_free(*pkt_out); + return -1; +} + +/* + * Try to adjust packet so that the first segment holds 'first_seg_len' bytes + * of packet data (+ tailroom if first_seg_len is longer than the packet). + * + * If 'first_seg_len' is zero, do not try to add segments but make headroom + * zero. + * + * Packet data bytes are not preserved. + */ +static void adjust_segments(odp_packet_t *pkt, uint32_t first_seg_len) +{ + uint32_t shift; + + shift = odp_packet_headroom(*pkt) + first_seg_len; + + if (odp_packet_extend_head(pkt, shift, NULL, NULL) < 0) { + CU_FAIL("odp_packet_extend_head() failed\n"); + return; + } + if (odp_packet_trunc_tail(pkt, shift, NULL, NULL) < 0) { + CU_FAIL("odp_packet_trunc_tail() failed\n"); + return; + } + /* + * ODP API does not seem to guarantee that we ever have a multi-segment + * packet at this point, but we can print a message about it. + */ + if (first_seg_len == 1 && + first_seg_len != odp_packet_seg_len(*pkt)) + printf("Could not create a segmented packet for testing.\n"); +} + +static void write_header_and_trailer(odp_packet_t pkt, + uint32_t header_len, uint32_t trailer_len) +{ + uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len; + uint32_t max_len = header_len > trailer_len ? header_len : trailer_len; + uint8_t buffer[max_len]; + int rc; + + fill_with_pattern(buffer, sizeof(buffer)); + + rc = odp_packet_copy_from_mem(pkt, 0, header_len, buffer); + CU_ASSERT(rc == 0); + rc = odp_packet_copy_from_mem(pkt, trailer_offset, trailer_len, buffer); + CU_ASSERT(rc == 0); +} + +static void prepare_crypto_ranges(const crypto_op_test_param_t *param, + odp_packet_data_range_t *cipher_range, + odp_packet_data_range_t *auth_range) +{ + odp_packet_data_range_t zero_range = {.offset = 0, .length = 0}; + uint32_t c_scale = param->is_bit_mode_cipher ? 8 : 1; + uint32_t a_scale = param->is_bit_mode_auth ? 8 : 1; + + *cipher_range = param->cipher_range; + *auth_range = param->auth_range; + cipher_range->offset += c_scale * param->header_len; + auth_range->offset += a_scale * param->header_len; + + if (param->ref->cipher == ODP_CIPHER_ALG_NULL) + *cipher_range = zero_range; + if (param->ref->auth == ODP_AUTH_ALG_NULL) + *auth_range = zero_range; +} + +static int prepare_input_packet(const crypto_op_test_param_t *param, + odp_packet_t *pkt_in) +{ + crypto_test_reference_t *ref = param->ref; + uint32_t reflength = ref_length_in_bytes(ref); + odp_packet_t pkt; + uint32_t digest_offset = param->digest_offset; + uint32_t pkt_len; + + pkt_len = param->header_len + reflength + param->trailer_len; + if (param->digest_offset == param->header_len + reflength) + pkt_len += ref->digest_length; + + pkt = odp_packet_alloc(suite_context.pool, pkt_len); + + CU_ASSERT(pkt != ODP_PACKET_INVALID); + if (pkt == ODP_PACKET_INVALID) + return -1; + + if (param->adjust_segmentation) + adjust_segments(&pkt, param->first_seg_len); + + write_header_and_trailer(pkt, param->header_len, param->trailer_len); + + if (param->op == ODP_CRYPTO_OP_ENCODE) { + odp_packet_copy_from_mem(pkt, param->header_len, + reflength, ref->plaintext); + } else { + odp_packet_copy_from_mem(pkt, param->header_len, + reflength, ref->ciphertext); + odp_packet_copy_from_mem(pkt, digest_offset, + ref->digest_length, + ref->digest); + if (param->wrong_digest) { + uint8_t byte = ~ref->digest[0]; + + odp_packet_copy_from_mem(pkt, digest_offset, 1, &byte); + } + } + *pkt_in = pkt; + return 0; +} + +static void prepare_oop_output_packet(const crypto_op_test_param_t *param, + odp_packet_t *pkt_out, + uint32_t pkt_len) +{ + uint32_t reflength = ref_length_in_bytes(param->ref); + const uint32_t oop_extra_len = 5; + uint32_t trl_len; + uint32_t hdr_len; + uint32_t oop_len; + + oop_len = pkt_len + param->oop_shift + oop_extra_len; + *pkt_out = odp_packet_alloc(suite_context.pool, oop_len); + CU_ASSERT_FATAL(*pkt_out != ODP_PACKET_INVALID); + + uint8_t buf[oop_len]; + + memset(buf, 0x55, sizeof(buf)); + odp_packet_copy_from_mem(*pkt_out, 0, sizeof(buf), buf); + + hdr_len = param->header_len + param->oop_shift; + trl_len = oop_len - hdr_len - reflength; + + write_header_and_trailer(*pkt_out, hdr_len, trl_len); + + /* have different metadata than in the input packet */ + memset(odp_packet_user_area(*pkt_out), 0xab, + odp_packet_user_area_size(*pkt_out)); +} + +static int is_packet_data_equal(odp_packet_t pkt_1, odp_packet_t pkt_2) +{ + uint32_t len = odp_packet_len(pkt_1); + uint8_t buf_1[len]; + uint8_t buf_2[len]; + + if (len != odp_packet_len(pkt_2) || + odp_packet_copy_to_mem(pkt_1, 0, len, buf_1) || + odp_packet_copy_to_mem(pkt_2, 0, len, buf_2)) + return 0; + + return !memcmp(buf_1, buf_2, len); +} + +static int is_in_range(uint32_t offs, uint32_t range_offs, uint32_t range_len) +{ + return offs >= range_offs && offs < range_offs + range_len; +} + +static void add_ignored_range(ignore_t *ign, uint32_t offs, uint32_t len) +{ + if (len == 0) + return; + CU_ASSERT_FATAL(ign->num_ranges < MAX_IGNORED_RANGES); + ign->ranges[ign->num_ranges].offset = offs; + ign->ranges[ign->num_ranges].length = len; + ign->num_ranges++; +} + +static void clear_ignored_data(const ignore_t *ign, uint8_t *data, uint32_t data_len) +{ + CU_ASSERT_FATAL(ign->byte_offset < data_len); + data[ign->byte_offset] &= ~ign->byte_mask; + + for (uint32_t n = 0; n < ign->num_ranges; n++) { + uint32_t offset = ign->ranges[n].offset; + uint32_t length = ign->ranges[n].length; + + CU_ASSERT(offset + length <= data_len); + memset(data + offset, 0, length); + } +} + +static void prepare_ignore_info(const crypto_op_test_param_t *param, + uint32_t shift, + uint32_t cipher_offset, + uint32_t cipher_len, + uint32_t auth_offset, + uint32_t auth_len, + ignore_t *ignore) +{ + memset(ignore, 0, sizeof(*ignore)); + + /* + * Leftover bits in the last byte of the cipher range of bit mode + * ciphers have undefined values. + */ + if (param->is_bit_mode_cipher && + param->ref->cipher != ODP_CIPHER_ALG_NULL) { + uint8_t leftover_bits = ref_length_in_bits(param->ref) % 8; + + ignore->byte_offset = cipher_offset + cipher_len - 1 + shift; + if (leftover_bits > 0) + ignore->byte_mask = ~(0xff << (8 - leftover_bits)); + else + ignore->byte_mask = 0; + } + + /* + * In decode sessions the bytes in the hash location have + * undefined values. + */ + if (param->ref->auth != ODP_AUTH_ALG_NULL && + param->op == ODP_CRYPTO_OP_DECODE) { + uint32_t offs = param->digest_offset; + + if (param->op_type != ODP_CRYPTO_OP_TYPE_OOP || + is_in_range(offs, cipher_offset, cipher_len) || + is_in_range(offs, auth_offset, auth_len)) { + add_ignored_range(ignore, + param->digest_offset + shift, + param->ref->digest_length); + } + } + + /* Decrypted bytes are undefined if authentication fails. */ + if (param->op == ODP_CRYPTO_OP_DECODE && + param->wrong_digest) { + add_ignored_range(ignore, cipher_offset + shift, cipher_len); + /* In OOP case, auth range may not get copied */ + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) + add_ignored_range(ignore, auth_offset + shift, auth_len); + } +} + +static void prepare_expected_data(const crypto_op_test_param_t *param, + const odp_packet_data_range_t *cipher_range, + const odp_packet_data_range_t *auth_range, + odp_packet_t pkt_in, + odp_packet_t pkt_out, + expected_t *ex) +{ + uint32_t digest_offset = param->digest_offset; + uint32_t cipher_offset = cipher_range->offset; + uint32_t cipher_len = cipher_range->length; + uint32_t auth_offset = auth_range->offset; + uint32_t auth_len = auth_range->length; + const int32_t shift = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift : 0; + const odp_packet_t base_pkt = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out : pkt_in; + int rc; + uint32_t cipher_offset_in_ref = param->cipher_range.offset; + + if (param->op == ODP_CRYPTO_OP_ENCODE) + digest_offset += shift; + + if (param->is_bit_mode_cipher) { + cipher_offset_in_ref /= 8; + cipher_offset /= 8; + cipher_len = (cipher_len + 7) / 8; + } + if (param->is_bit_mode_auth) { + auth_offset /= 8; + auth_len = (auth_len + 7) / 8; + } + if (param->ref->cipher == ODP_CIPHER_ALG_NULL) + cipher_len = 0; + if (param->ref->auth == ODP_AUTH_ALG_NULL || + param->ref->auth == ODP_AUTH_ALG_AES_GCM || + param->ref->auth == ODP_AUTH_ALG_AES_CCM || + param->ref->auth == ODP_AUTH_ALG_CHACHA20_POLY1305) { + /* auth range is ignored with null and AEAD algorithms */ + auth_len = 0; + } + + /* copy all data from base packet */ + ex->len = odp_packet_len(base_pkt); + CU_ASSERT_FATAL(ex->len <= sizeof(ex->data)); + rc = odp_packet_copy_to_mem(base_pkt, 0, ex->len, ex->data); + CU_ASSERT(rc == 0); + + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) { + /* copy auth range from input packet */ + rc = odp_packet_copy_to_mem(pkt_in, auth_offset, auth_len, + ex->data + auth_offset + shift); + CU_ASSERT(rc == 0); + } + + if (param->op == ODP_CRYPTO_OP_ENCODE) { + /* copy hash first */ + memcpy(ex->data + digest_offset, + param->ref->digest, + param->ref->digest_length); + /* + * Copy ciphertext, possibly overwriting hash. + * The other order (hash overwriting some cipher + * text) does not work in any real use case anyway. + */ + memcpy(ex->data + cipher_offset + shift, + param->ref->ciphertext + cipher_offset_in_ref, + cipher_len); + } else { + memcpy(ex->data + cipher_offset + shift, + param->ref->plaintext + cipher_offset_in_ref, + cipher_len); + } + + prepare_ignore_info(param, shift, + cipher_offset, cipher_len, + auth_offset, auth_len, + &ex->ignore); +} + +static void print_data(const char *title, uint8_t *data, uint32_t len) +{ + static uint64_t limit; + + if (limit++ > MAX_FAILURE_PRINTS) + return; + + printf("%s\n", title); + for (uint32_t n = 0; n < len ; n++) { + printf(" %02x", data[n]); + if ((n + 1) % 16 == 0) + printf("\n"); + } + printf("\n"); +} + +static void check_output_packet_data(odp_packet_t pkt, expected_t *ex) +{ + int rc; + uint8_t pkt_data[ex->len]; + + CU_ASSERT(odp_packet_len(pkt) == ex->len); + rc = odp_packet_copy_to_mem(pkt, 0, ex->len, pkt_data); + CU_ASSERT(rc == 0); + + clear_ignored_data(&ex->ignore, pkt_data, sizeof(pkt_data)); + clear_ignored_data(&ex->ignore, ex->data, sizeof(ex->data)); + + if (memcmp(pkt_data, ex->data, ex->len)) { + CU_FAIL("packet data does not match expected data"); + print_data("packet:", pkt_data, ex->len); + print_data("expected:", ex->data, ex->len); + } +} + +void test_crypto_op(const crypto_op_test_param_t *param) +{ + odp_bool_t ok = false; + odp_packet_t pkt; + odp_packet_t pkt_copy = ODP_PACKET_INVALID; + odp_packet_t pkt_out = ODP_PACKET_INVALID; + test_packet_md_t md_in, md_out, md_out_orig; + expected_t expected; + odp_crypto_packet_op_param_t op_params = { + .session = param->session, + .cipher_iv_ptr = param->ref->cipher_iv, + .auth_iv_ptr = param->ref->auth_iv, + .hash_result_offset = param->digest_offset, + .aad_ptr = param->ref->aad, + .dst_offset_shift = param->oop_shift, + }; + + /* + * Test detection of wrong digest value in input packet + * only when decoding and using non-null auth algorithm. + */ + if (param->wrong_digest && + (param->ref->auth == ODP_AUTH_ALG_NULL || + param->op == ODP_CRYPTO_OP_ENCODE)) + return; + + prepare_crypto_ranges(param, &op_params.cipher_range, &op_params.auth_range); + if (prepare_input_packet(param, &pkt)) + return; + + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { + prepare_oop_output_packet(param, &pkt_out, odp_packet_len(pkt)); + + pkt_copy = odp_packet_copy(pkt, suite_context.pool); + CU_ASSERT_FATAL(pkt_copy != ODP_PACKET_INVALID); + test_packet_get_md(pkt_out, &md_out_orig); + } + + prepare_expected_data(param, &op_params.cipher_range, &op_params.auth_range, + pkt, pkt_out, &expected); + + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && + param->op == ODP_CRYPTO_OP_ENCODE) { + /* + * In this type of sessions digest offset is an offset to the output + * packet, so apply the shift. + */ + op_params.hash_result_offset += param->oop_shift; + } + + test_packet_set_md(pkt); + test_packet_get_md(pkt, &md_in); + + if (crypto_op(pkt, &pkt_out, &ok, &op_params, param->op_type)) + return; + + test_packet_get_md(pkt_out, &md_out); + + if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { + test_packet_md_t md; + + /* check that input packet has not changed */ + CU_ASSERT(is_packet_data_equal(pkt, pkt_copy)); + odp_packet_free(pkt_copy); + test_packet_get_md(pkt, &md); + CU_ASSERT(test_packet_is_md_equal(&md, &md_in)); + odp_packet_free(pkt); + + /* check that metadata of output packet has not changed */ + CU_ASSERT(test_packet_is_md_equal(&md_out, &md_out_orig)); + } else { + CU_ASSERT(test_packet_is_md_equal(&md_out, &md_in)); + } + + if (param->ref->cipher != ODP_CIPHER_ALG_NULL && + param->ref->auth != ODP_AUTH_ALG_NULL && + param->digest_offset >= op_params.cipher_range.offset && + param->digest_offset < op_params.cipher_range.offset + op_params.cipher_range.length) { + /* + * Not all implementations support digest offset in cipher + * range, so allow crypto op failure without further checks + * in this case. + */ + if (!ok) + goto out; + } + + if (param->wrong_digest) { + CU_ASSERT(!ok); + } else { + CU_ASSERT(ok); + } + + check_output_packet_data(pkt_out, &expected); +out: + odp_packet_free(pkt_out); +} diff --git a/test/validation/api/crypto/crypto_op_test.h b/test/validation/api/crypto/crypto_op_test.h new file mode 100644 index 000000000..4b2f66c47 --- /dev/null +++ b/test/validation/api/crypto/crypto_op_test.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef CRYPTO_OP_TEST_H +#define CRYPTO_OP_TEST_H + +#include <odp_api.h> +#include <stdint.h> +#include "test_vectors.h" + +typedef struct crypto_op_test_param_t { + odp_crypto_session_t session; + odp_crypto_op_t op; + odp_crypto_op_type_t op_type; + int32_t oop_shift; + crypto_test_reference_t *ref; + odp_packet_data_range_t cipher_range; + odp_packet_data_range_t auth_range; + uint32_t digest_offset; + odp_bool_t is_bit_mode_cipher; + odp_bool_t is_bit_mode_auth; + odp_bool_t adjust_segmentation; + odp_bool_t wrong_digest; + uint32_t first_seg_len; + uint32_t header_len; + uint32_t trailer_len; +} crypto_op_test_param_t; + +void test_crypto_op(const crypto_op_test_param_t *param); + +int crypto_op(odp_packet_t pkt_in, + odp_packet_t *pkt_out, + odp_bool_t *ok, + const odp_crypto_packet_op_param_t *op_params, + odp_crypto_op_type_t op_type); + +#endif diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index c6a7767cc..d7e2bd16b 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -10,8 +10,10 @@ #include <odp_api.h> #include <odp/helper/odph_api.h> #include <odp_cunit_common.h> -#include <packet_common.h> #include "test_vectors.h" +#include "test_vector_defs.h" +#include "crypto_op_test.h" +#include "util.h" /* * If nonzero, run time consuming tests too. @@ -25,20 +27,6 @@ static int full_test; #define PKT_POOL_LEN 1200 /* enough for a test packet and some headroom */ #define UAREA_SIZE 8 -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -struct suite_context_s { - odp_bool_t packet; - odp_crypto_op_mode_t op_mode; - odp_crypto_op_mode_t pref_mode; - odp_pool_t pool; - odp_queue_t queue; - odp_queue_type_t q_type; - odp_event_t (*compl_queue_deq)(void); -}; - -static struct suite_context_s suite_context; - static void test_defaults(uint8_t fill) { odp_crypto_session_param_t param; @@ -63,733 +51,14 @@ static void test_default_values(void) test_defaults(0xff); } -static const char *auth_alg_name(odp_auth_alg_t auth) -{ - switch (auth) { - case ODP_AUTH_ALG_NULL: - return "ODP_AUTH_ALG_NULL"; - case ODP_AUTH_ALG_MD5_HMAC: - return "ODP_AUTH_ALG_MD5_HMAC"; - case ODP_AUTH_ALG_SHA1_HMAC: - return "ODP_AUTH_ALG_SHA1_HMAC"; - case ODP_AUTH_ALG_SHA224_HMAC: - return "ODP_AUTH_ALG_SHA224_HMAC"; - case ODP_AUTH_ALG_SHA256_HMAC: - return "ODP_AUTH_ALG_SHA256_HMAC"; - case ODP_AUTH_ALG_SHA384_HMAC: - return "ODP_AUTH_ALG_SHA384_HMAC"; - case ODP_AUTH_ALG_SHA512_HMAC: - return "ODP_AUTH_ALG_SHA512_HMAC"; - case ODP_AUTH_ALG_AES_XCBC_MAC: - return "ODP_AUTH_ALG_AES_XCBC_MAC"; - case ODP_AUTH_ALG_AES_GCM: - return "ODP_AUTH_ALG_AES_GCM"; - case ODP_AUTH_ALG_AES_GMAC: - return "ODP_AUTH_ALG_AES_GMAC"; - case ODP_AUTH_ALG_AES_CCM: - return "ODP_AUTH_ALG_AES_CCM"; - case ODP_AUTH_ALG_AES_CMAC: - return "ODP_AUTH_ALG_AES_CMAC"; - case ODP_AUTH_ALG_CHACHA20_POLY1305: - return "ODP_AUTH_ALG_CHACHA20_POLY1305"; - case ODP_AUTH_ALG_KASUMI_F9: - return "ODP_AUTH_ALG_KASUMI_F9"; - case ODP_AUTH_ALG_SNOW3G_UIA2: - return "ODP_AUTH_ALG_SNOW3G_UIA2"; - case ODP_AUTH_ALG_AES_EIA2: - return "ODP_AUTH_ALG_AES_EIA2"; - case ODP_AUTH_ALG_ZUC_EIA3: - return "ODP_AUTH_ALG_ZUC_EIA3"; - case ODP_AUTH_ALG_MD5: - return "ODP_AUTH_ALG_MD5"; - case ODP_AUTH_ALG_SHA1: - return "ODP_AUTH_ALG_SHA1"; - case ODP_AUTH_ALG_SHA224: - return "ODP_AUTH_ALG_SHA224"; - case ODP_AUTH_ALG_SHA256: - return "ODP_AUTH_ALG_SHA256"; - case ODP_AUTH_ALG_SHA384: - return "ODP_AUTH_ALG_SHA384"; - case ODP_AUTH_ALG_SHA512: - return "ODP_AUTH_ALG_SHA512"; - default: - return "Unknown"; - } -} - -static const char *cipher_alg_name(odp_cipher_alg_t cipher) -{ - switch (cipher) { - case ODP_CIPHER_ALG_NULL: - return "ODP_CIPHER_ALG_NULL"; - case ODP_CIPHER_ALG_DES: - return "ODP_CIPHER_ALG_DES"; - case ODP_CIPHER_ALG_3DES_CBC: - return "ODP_CIPHER_ALG_3DES_CBC"; - case ODP_CIPHER_ALG_3DES_ECB: - return "ODP_CIPHER_ALG_3DES_ECB"; - case ODP_CIPHER_ALG_AES_CBC: - return "ODP_CIPHER_ALG_AES_CBC"; - case ODP_CIPHER_ALG_AES_CTR: - return "ODP_CIPHER_ALG_AES_CTR"; - case ODP_CIPHER_ALG_AES_ECB: - return "ODP_CIPHER_ALG_AES_ECB"; - case ODP_CIPHER_ALG_AES_CFB128: - return "ODP_CIPHER_ALG_AES_CFB128"; - case ODP_CIPHER_ALG_AES_XTS: - return "ODP_CIPHER_ALG_AES_XTS"; - case ODP_CIPHER_ALG_AES_GCM: - return "ODP_CIPHER_ALG_AES_GCM"; - case ODP_CIPHER_ALG_AES_CCM: - return "ODP_CIPHER_ALG_AES_CCM"; - case ODP_CIPHER_ALG_CHACHA20_POLY1305: - return "ODP_CIPHER_ALG_CHACHA20_POLY1305"; - case ODP_CIPHER_ALG_KASUMI_F8: - return "ODP_CIPHER_ALG_KASUMI_F8"; - case ODP_CIPHER_ALG_SNOW3G_UEA2: - return "ODP_CIPHER_ALG_SNOW3G_UEA2"; - case ODP_CIPHER_ALG_AES_EEA2: - return "ODP_CIPHER_ALG_AES_EEA2"; - case ODP_CIPHER_ALG_ZUC_EEA3: - return "ODP_CIPHER_ALG_ZUC_EEA3"; - default: - return "Unknown"; - } -} - -static int alg_packet_op(odp_packet_t pkt_in, - odp_packet_t *pkt_out, - odp_bool_t *ok, - odp_crypto_session_t session, - odp_crypto_op_type_t op_type, - int32_t oop_shift, - uint8_t *cipher_iv_ptr, - uint8_t *auth_iv_ptr, - const odp_packet_data_range_t *cipher_range, - const odp_packet_data_range_t *auth_range, - uint8_t *aad, - unsigned int hash_result_offset) -{ - int rc; - odp_event_t event; - odp_crypto_packet_result_t result; - odp_crypto_packet_op_param_t op_params; - odp_event_subtype_t subtype; - odp_packet_t orig_pkt_out; - - if (op_type == ODP_CRYPTO_OP_TYPE_LEGACY) - *pkt_out = pkt_in; - else if (op_type == ODP_CRYPTO_OP_TYPE_BASIC) - *pkt_out = ODP_PACKET_INVALID; - orig_pkt_out = *pkt_out; - - /* Prepare input/output params */ - memset(&op_params, 0, sizeof(op_params)); - op_params.session = session; - - op_params.cipher_range = *cipher_range; - op_params.auth_range = *auth_range; - op_params.dst_offset_shift = oop_shift; - if (cipher_iv_ptr) - op_params.cipher_iv_ptr = cipher_iv_ptr; - if (auth_iv_ptr) - op_params.auth_iv_ptr = auth_iv_ptr; - - op_params.aad_ptr = aad; - - op_params.hash_result_offset = hash_result_offset; - - if (suite_context.op_mode == ODP_CRYPTO_SYNC) { - rc = odp_crypto_op(&pkt_in, pkt_out, &op_params, 1); - if (rc <= 0) { - CU_FAIL("Failed odp_crypto_packet_op()"); - return rc; - } - } else { - odp_packet_t *out_param = pkt_out; - - if (op_type == ODP_CRYPTO_OP_TYPE_BASIC) - out_param = NULL; - - rc = odp_crypto_op_enq(&pkt_in, out_param, &op_params, 1); - if (rc <= 0) { - CU_FAIL("Failed odp_crypto_op_enq()"); - return rc; - } - - /* Get crypto completion event from compl_queue. */ - CU_ASSERT_FATAL(NULL != suite_context.compl_queue_deq); - do { - event = suite_context.compl_queue_deq(); - } while (event == ODP_EVENT_INVALID); - - CU_ASSERT(ODP_EVENT_PACKET == odp_event_type(event)); - CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == odp_event_subtype(event)); - CU_ASSERT(ODP_EVENT_PACKET == odp_event_types(event, &subtype)); - CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); - - *pkt_out = odp_crypto_packet_from_event(event); - } - - if (op_type != ODP_CRYPTO_OP_TYPE_BASIC) - CU_ASSERT(*pkt_out == orig_pkt_out); - CU_ASSERT(ODP_EVENT_PACKET == - odp_event_type(odp_packet_to_event(*pkt_out))); - CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == - odp_event_subtype(odp_packet_to_event(*pkt_out))); - CU_ASSERT(ODP_EVENT_PACKET == - odp_event_types(odp_packet_to_event(*pkt_out), &subtype)); - CU_ASSERT(ODP_EVENT_PACKET_CRYPTO == subtype); - CU_ASSERT(odp_packet_subtype(*pkt_out) == ODP_EVENT_PACKET_CRYPTO); - - rc = odp_crypto_result(&result, *pkt_out); - if (rc < -1) { - CU_FAIL("Failed odp_crypto_packet_result()"); - return rc; - } - CU_ASSERT(rc == 0 || rc == -1); - - if (op_type == ODP_CRYPTO_OP_TYPE_OOP && - suite_context.op_mode == ODP_CRYPTO_ASYNC) - CU_ASSERT(result.pkt_in == pkt_in); - - *ok = (rc == 0); - -#if ODP_DEPRECATED_API - CU_ASSERT(*ok == result.ok); -#endif - - return 0; -} - -static int crypto_op(odp_packet_t pkt_in, - odp_packet_t *pkt_out, - odp_bool_t *ok, - odp_crypto_session_t session, - odp_crypto_op_type_t op_type, - int32_t oop_shift, - uint8_t *cipher_iv, - uint8_t *auth_iv, - const odp_packet_data_range_t *cipher_range, - const odp_packet_data_range_t *auth_range, - uint8_t *aad, - unsigned int hash_result_offset) -{ - int rc; - - rc = alg_packet_op(pkt_in, pkt_out, ok, session, - op_type, oop_shift, - cipher_iv, auth_iv, - cipher_range, auth_range, - aad, hash_result_offset); - - if (rc < 0) - odp_packet_free(pkt_in); - - return rc; -} - -/* - * Try to adjust packet so that the first segment holds 'first_seg_len' bytes - * of packet data (+ tailroom if first_seg_len is longer than the packet). - * - * If 'first_seg_len' is zero, do not try to add segments but make headroom - * zero. - * - * Packet data bytes are not preserved. - */ -static void adjust_segments(odp_packet_t *pkt, uint32_t first_seg_len) -{ - uint32_t shift; - - shift = odp_packet_headroom(*pkt) + first_seg_len; - - if (odp_packet_extend_head(pkt, shift, NULL, NULL) < 0) { - CU_FAIL("odp_packet_extend_head() failed\n"); - return; - } - if (odp_packet_trunc_tail(pkt, shift, NULL, NULL) < 0) { - CU_FAIL("odp_packet_trunc_tail() failed\n"); - return; - } - /* - * ODP API does not seem to guarantee that we ever have a multi-segment - * packet at this point, but we can print a message about it. - */ - if (first_seg_len == 1 && - first_seg_len != odp_packet_seg_len(*pkt)) - printf("Could not create a segmented packet for testing.\n"); -} - -static void fill_with_pattern(uint8_t *buf, uint32_t len) -{ - static uint8_t value; - - for (uint32_t n = 0; n < len; n++) - buf[n] = value++; -} - -static void write_header_and_trailer(odp_packet_t pkt, - uint32_t header_len, uint32_t trailer_len) -{ - uint32_t trailer_offset = odp_packet_len(pkt) - trailer_len; - uint32_t max_len = header_len > trailer_len ? header_len : trailer_len; - uint8_t buffer[max_len]; - int rc; - - fill_with_pattern(buffer, sizeof(buffer)); - - rc = odp_packet_copy_from_mem(pkt, 0, header_len, buffer); - CU_ASSERT(rc == 0); - rc = odp_packet_copy_from_mem(pkt, trailer_offset, trailer_len, buffer); - CU_ASSERT(rc == 0); -} - -typedef struct alg_test_param_t { - odp_crypto_session_t session; - odp_crypto_op_t op; - odp_crypto_op_type_t op_type; - int32_t oop_shift; - odp_cipher_alg_t cipher_alg; - odp_auth_alg_t auth_alg; - crypto_test_reference_t *ref; - odp_packet_data_range_t cipher_range; - odp_packet_data_range_t auth_range; - uint32_t digest_offset; - odp_bool_t is_bit_mode_cipher; - odp_bool_t is_bit_mode_auth; - odp_bool_t adjust_segmentation; - odp_bool_t wrong_digest; - uint32_t first_seg_len; - uint32_t header_len; - uint32_t trailer_len; -} alg_test_param_t; - -static void prepare_crypto_ranges(const alg_test_param_t *param, - odp_packet_data_range_t *cipher_range, - odp_packet_data_range_t *auth_range) -{ - odp_packet_data_range_t zero_range = {.offset = 0, .length = 0}; - uint32_t c_scale = param->is_bit_mode_cipher ? 8 : 1; - uint32_t a_scale = param->is_bit_mode_auth ? 8 : 1; - - *cipher_range = param->cipher_range; - *auth_range = param->auth_range; - cipher_range->offset += c_scale * param->header_len; - auth_range->offset += a_scale * param->header_len; - - if (param->cipher_alg == ODP_CIPHER_ALG_NULL) - *cipher_range = zero_range; - if (param->auth_alg == ODP_AUTH_ALG_NULL) - *auth_range = zero_range; -} - -static int prepare_input_packet(const alg_test_param_t *param, - odp_packet_t *pkt_in) -{ - crypto_test_reference_t *ref = param->ref; - uint32_t reflength = ref_length_in_bytes(ref); - odp_packet_t pkt; - uint32_t digest_offset = param->digest_offset; - uint32_t pkt_len; - - pkt_len = param->header_len + reflength + param->trailer_len; - if (param->digest_offset == param->header_len + reflength) - pkt_len += ref->digest_length; - - pkt = odp_packet_alloc(suite_context.pool, pkt_len); - - CU_ASSERT(pkt != ODP_PACKET_INVALID); - if (pkt == ODP_PACKET_INVALID) - return -1; - - if (param->adjust_segmentation) - adjust_segments(&pkt, param->first_seg_len); - - write_header_and_trailer(pkt, param->header_len, param->trailer_len); - - if (param->op == ODP_CRYPTO_OP_ENCODE) { - odp_packet_copy_from_mem(pkt, param->header_len, - reflength, ref->plaintext); - } else { - odp_packet_copy_from_mem(pkt, param->header_len, - reflength, ref->ciphertext); - odp_packet_copy_from_mem(pkt, digest_offset, - ref->digest_length, - ref->digest); - if (param->wrong_digest) { - uint8_t byte = ~ref->digest[0]; - - odp_packet_copy_from_mem(pkt, digest_offset, 1, &byte); - } - } - *pkt_in = pkt; - return 0; -} - -static void prepare_oop_output_packet(const alg_test_param_t *param, - odp_packet_t *pkt_out, - uint32_t pkt_len) +static void print_alg_test_param(const crypto_op_test_param_t *p) { - uint32_t reflength = ref_length_in_bytes(param->ref); - const uint32_t oop_extra_len = 5; - uint32_t trl_len; - uint32_t hdr_len; - uint32_t oop_len; - - oop_len = pkt_len + param->oop_shift + oop_extra_len; - *pkt_out = odp_packet_alloc(suite_context.pool, oop_len); - CU_ASSERT_FATAL(*pkt_out != ODP_PACKET_INVALID); - - uint8_t buf[oop_len]; - - memset(buf, 0x55, sizeof(buf)); - odp_packet_copy_from_mem(*pkt_out, 0, sizeof(buf), buf); - - hdr_len = param->header_len + param->oop_shift; - trl_len = oop_len - hdr_len - reflength; - - write_header_and_trailer(*pkt_out, hdr_len, trl_len); - - /* have different metadata than in the input packet */ - memset(odp_packet_user_area(*pkt_out), 0xab, - odp_packet_user_area_size(*pkt_out)); -} - -static int is_packet_data_equal(odp_packet_t pkt_1, odp_packet_t pkt_2) -{ - uint32_t len = odp_packet_len(pkt_1); - uint8_t buf_1[len]; - uint8_t buf_2[len]; - - if (len != odp_packet_len(pkt_2) || - odp_packet_copy_to_mem(pkt_1, 0, len, buf_1) || - odp_packet_copy_to_mem(pkt_2, 0, len, buf_2)) - return 0; - - return !memcmp(buf_1, buf_2, len); -} - -static int is_in_range(uint32_t offs, uint32_t range_offs, uint32_t range_len) -{ - return offs >= range_offs && offs < range_offs + range_len; -} - -#define MAX_IGNORED_RANGES 3 - -/* - * Output packet parts that we ignore since they have undefined values - */ -typedef struct ignore_t { - uint32_t byte_offset; /* offset to a byte which has bits to be ignored */ - uint8_t byte_mask; /* mask of ignored bits in the byte */ - struct { - uint32_t offset; - uint32_t length; - } ranges[MAX_IGNORED_RANGES]; /* byte ranges to be ignored */ - uint32_t num_ranges; -} ignore_t; - -static void add_ignored_range(ignore_t *ign, uint32_t offs, uint32_t len) -{ - if (len == 0) - return; - CU_ASSERT_FATAL(ign->num_ranges < MAX_IGNORED_RANGES); - ign->ranges[ign->num_ranges].offset = offs; - ign->ranges[ign->num_ranges].length = len; - ign->num_ranges++; -} - -static void clear_ignored_data(const ignore_t *ign, uint8_t *data, uint32_t data_len) -{ - CU_ASSERT_FATAL(ign->byte_offset < data_len); - data[ign->byte_offset] &= ~ign->byte_mask; - - for (uint32_t n = 0; n < ign->num_ranges; n++) { - uint32_t offset = ign->ranges[n].offset; - uint32_t length = ign->ranges[n].length; - - CU_ASSERT(offset + length <= data_len); - memset(data + offset, 0, length); - } -} - -static void prepare_ignore_info(const alg_test_param_t *param, - uint32_t shift, - uint32_t cipher_offset, - uint32_t cipher_len, - uint32_t auth_offset, - uint32_t auth_len, - ignore_t *ignore) -{ - memset(ignore, 0, sizeof(*ignore)); - - /* - * Leftover bits in the last byte of the cipher range of bit mode - * ciphers have undefined values. - */ - if (param->is_bit_mode_cipher && - param->cipher_alg != ODP_CIPHER_ALG_NULL) { - uint8_t leftover_bits = ref_length_in_bits(param->ref) % 8; - - ignore->byte_offset = cipher_offset + cipher_len - 1 + shift; - if (leftover_bits > 0) - ignore->byte_mask = ~(0xff << (8 - leftover_bits)); - else - ignore->byte_mask = 0; - } - - /* - * In decode sessions the bytes in the hash location have - * undefined values. - */ - if (param->auth_alg != ODP_AUTH_ALG_NULL && - param->op == ODP_CRYPTO_OP_DECODE) { - uint32_t offs = param->digest_offset; - - if (param->op_type != ODP_CRYPTO_OP_TYPE_OOP || - is_in_range(offs, cipher_offset, cipher_len) || - is_in_range(offs, auth_offset, auth_len)) { - add_ignored_range(ignore, - param->digest_offset + shift, - param->ref->digest_length); - } - } - - /* Decrypted bytes are undefined if authentication fails. */ - if (param->op == ODP_CRYPTO_OP_DECODE && - param->wrong_digest) { - add_ignored_range(ignore, cipher_offset + shift, cipher_len); - /* In OOP case, auth range may not get copied */ - if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) - add_ignored_range(ignore, auth_offset + shift, auth_len); - } -} - -/* Add room for bytes that are not included in ref->length */ -#define MAX_EXP_DATA_LEN (MAX_DATA_LEN + 200) - -/* - * Expected packet data - */ -typedef struct expected_t { - uint8_t data[MAX_EXP_DATA_LEN]; - uint32_t len; - ignore_t ignore; -} expected_t; - -static void prepare_expected_data(const alg_test_param_t *param, - const odp_packet_data_range_t *cipher_range, - const odp_packet_data_range_t *auth_range, - odp_packet_t pkt_in, - odp_packet_t pkt_out, - expected_t *ex) -{ - uint32_t digest_offset = param->digest_offset; - uint32_t cipher_offset = cipher_range->offset; - uint32_t cipher_len = cipher_range->length; - uint32_t auth_offset = auth_range->offset; - uint32_t auth_len = auth_range->length; - const int32_t shift = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? param->oop_shift : 0; - const odp_packet_t base_pkt = param->op_type == ODP_CRYPTO_OP_TYPE_OOP ? pkt_out : pkt_in; - int rc; - uint32_t cipher_offset_in_ref = param->cipher_range.offset; - - if (param->op == ODP_CRYPTO_OP_ENCODE) - digest_offset += shift; - - if (param->is_bit_mode_cipher) { - cipher_offset_in_ref /= 8; - cipher_offset /= 8; - cipher_len = (cipher_len + 7) / 8; - } - if (param->is_bit_mode_auth) { - auth_offset /= 8; - auth_len = (auth_len + 7) / 8; - } - if (param->cipher_alg == ODP_CIPHER_ALG_NULL) - cipher_len = 0; - if (param->auth_alg == ODP_AUTH_ALG_NULL || - param->auth_alg == ODP_AUTH_ALG_AES_GCM || - param->auth_alg == ODP_AUTH_ALG_AES_CCM || - param->auth_alg == ODP_AUTH_ALG_CHACHA20_POLY1305) { - /* auth range is ignored with null and AEAD algorithms */ - auth_len = 0; - } - - /* copy all data from base packet */ - ex->len = odp_packet_len(base_pkt); - CU_ASSERT_FATAL(ex->len <= sizeof(ex->data)); - rc = odp_packet_copy_to_mem(base_pkt, 0, ex->len, ex->data); - CU_ASSERT(rc == 0); - - if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && auth_len > 0) { - /* copy auth range from input packet */ - rc = odp_packet_copy_to_mem(pkt_in, auth_offset, auth_len, - ex->data + auth_offset + shift); - CU_ASSERT(rc == 0); - } - - if (param->op == ODP_CRYPTO_OP_ENCODE) { - /* copy hash first */ - memcpy(ex->data + digest_offset, - param->ref->digest, - param->ref->digest_length); - /* - * Copy ciphertext, possibly overwriting hash. - * The other order (hash overwriting some cipher - * text) does not work in any real use case anyway. - */ - memcpy(ex->data + cipher_offset + shift, - param->ref->ciphertext + cipher_offset_in_ref, - cipher_len); - } else { - memcpy(ex->data + cipher_offset + shift, - param->ref->plaintext + cipher_offset_in_ref, - cipher_len); - } - - prepare_ignore_info(param, shift, - cipher_offset, cipher_len, - auth_offset, auth_len, - &ex->ignore); -} - -static void print_data(const char *title, uint8_t *data, uint32_t len) -{ - static uint64_t limit; - - if (limit++ > MAX_FAILURE_PRINTS) - return; - - printf("%s\n", title); - for (uint32_t n = 0; n < len ; n++) { - printf(" %02x", data[n]); - if ((n + 1) % 16 == 0) - printf("\n"); - } - printf("\n"); -} - -static void check_output_packet_data(odp_packet_t pkt, expected_t *ex) -{ - int rc; - uint8_t pkt_data[ex->len]; - - CU_ASSERT(odp_packet_len(pkt) == ex->len); - rc = odp_packet_copy_to_mem(pkt, 0, ex->len, pkt_data); - CU_ASSERT(rc == 0); - - clear_ignored_data(&ex->ignore, pkt_data, sizeof(pkt_data)); - clear_ignored_data(&ex->ignore, ex->data, sizeof(ex->data)); - - if (memcmp(pkt_data, ex->data, ex->len)) { - CU_FAIL("packet data does not match expected data"); - print_data("packet:", pkt_data, ex->len); - print_data("expected:", ex->data, ex->len); - } -} - -static void alg_test_execute(const alg_test_param_t *param) -{ - odp_bool_t ok = false; - odp_packet_data_range_t cipher_range; - odp_packet_data_range_t auth_range; - odp_packet_t pkt; - odp_packet_t pkt_copy = ODP_PACKET_INVALID; - odp_packet_t pkt_out = ODP_PACKET_INVALID; - uint32_t digest_offset = param->digest_offset; - test_packet_md_t md_in, md_out, md_out_orig; - expected_t expected; - - /* - * Test detection of wrong digest value in input packet - * only when decoding and using non-null auth algorithm. - */ - if (param->wrong_digest && - (param->auth_alg == ODP_AUTH_ALG_NULL || - param->op == ODP_CRYPTO_OP_ENCODE)) - return; - - prepare_crypto_ranges(param, &cipher_range, &auth_range); - if (prepare_input_packet(param, &pkt)) - return; - - if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { - prepare_oop_output_packet(param, &pkt_out, odp_packet_len(pkt)); - - pkt_copy = odp_packet_copy(pkt, suite_context.pool); - CU_ASSERT_FATAL(pkt_copy != ODP_PACKET_INVALID); - test_packet_get_md(pkt_out, &md_out_orig); - } - - prepare_expected_data(param, &cipher_range, &auth_range, - pkt, pkt_out, &expected); - - if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP && - param->op == ODP_CRYPTO_OP_ENCODE) { - /* - * In this type of sessions digest offset is an offset to the output - * packet, so apply the shift. - */ - digest_offset += param->oop_shift; - } - - test_packet_set_md(pkt); - test_packet_get_md(pkt, &md_in); - - if (crypto_op(pkt, &pkt_out, &ok, param->session, - param->op_type, param->oop_shift, - param->ref->cipher_iv, - param->ref->auth_iv, - &cipher_range, &auth_range, - param->ref->aad, digest_offset)) - return; - - test_packet_get_md(pkt_out, &md_out); + const char *cipher_mode = p->is_bit_mode_cipher ? "bit" : "byte"; - if (param->op_type == ODP_CRYPTO_OP_TYPE_OOP) { - test_packet_md_t md; - /* check that input packet has not changed */ - CU_ASSERT(is_packet_data_equal(pkt, pkt_copy)); - odp_packet_free(pkt_copy); - test_packet_get_md(pkt, &md); - CU_ASSERT(test_packet_is_md_equal(&md, &md_in)); - odp_packet_free(pkt); - /* check that metadata of output packet has not changed */ - CU_ASSERT(test_packet_is_md_equal(&md_out, &md_out_orig)); - } else { - CU_ASSERT(test_packet_is_md_equal(&md_out, &md_in)); - } - if (param->cipher_alg != ODP_CIPHER_ALG_NULL && - param->auth_alg != ODP_AUTH_ALG_NULL && - param->digest_offset >= cipher_range.offset && - param->digest_offset < cipher_range.offset + cipher_range.length) { - /* - * Not all implementations support digest offset in cipher - * range, so allow crypto op failure without further checks - * in this case. - */ - if (!ok) - goto out; - } - if (param->wrong_digest) { - CU_ASSERT(!ok); - } else { - CU_ASSERT(ok); - } - check_output_packet_data(pkt_out, &expected); -out: - odp_packet_free(pkt_out); -} - -static void print_alg_test_param(const alg_test_param_t *p) -{ - const char *cipher_mode = p->is_bit_mode_cipher ? "bit" : "byte"; const char *auth_mode = p->is_bit_mode_auth ? "bit" : "byte"; switch (p->op_type) { @@ -805,13 +74,13 @@ static void print_alg_test_param(const alg_test_param_t *p) } printf("%s\n", p->op == ODP_CRYPTO_OP_ENCODE ? "encode" : "decode"); - printf("cipher: %s, %s mode\n", cipher_alg_name(p->cipher_alg), cipher_mode); + printf("cipher: %s, %s mode\n", cipher_alg_name(p->ref->cipher), cipher_mode); printf(" key length: %d, iv length: %d\n", p->ref->cipher_key_length, p->ref->cipher_iv_length); printf(" range: offset %d, length %d\n", p->cipher_range.offset, p->cipher_range.length); - printf("auth: %s, %s mode\n", auth_alg_name(p->auth_alg), auth_mode); + printf("auth: %s, %s mode\n", auth_alg_name(p->ref->auth), auth_mode); printf(" key length: %d, iv length: %d\n", p->ref->auth_key_length, p->ref->auth_iv_length); printf(" range: offset %d, length %d; aad length: %d\n", @@ -828,12 +97,12 @@ static void print_alg_test_param(const alg_test_param_t *p) printf("oop_shift: %d\n", p->oop_shift); } -static void alg_test_execute_and_print(alg_test_param_t *param) +static void alg_test_execute_and_print(crypto_op_test_param_t *param) { static int print_limit = MAX_FAILURE_PRINTS; unsigned int num = CU_get_number_of_failures(); - alg_test_execute(param); + test_crypto_op(param); if (CU_get_number_of_failures() > num) { if (print_limit > 0) { @@ -847,7 +116,7 @@ static void alg_test_execute_and_print(alg_test_param_t *param) } } -static void alg_test_op(alg_test_param_t *param) +static void alg_test_op(crypto_op_test_param_t *param) { int32_t oop_shifts[] = {0, 3, 130, -10}; @@ -883,8 +152,6 @@ typedef enum { static odp_crypto_session_t session_create(odp_crypto_op_t op, odp_crypto_op_type_t op_type, - odp_cipher_alg_t cipher_alg, - odp_auth_alg_t auth_alg, alg_order_t order, crypto_test_reference_t *ref, hash_test_mode_t hash_mode) @@ -913,8 +180,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, ses_params.op_type = op_type; ses_params.auth_cipher_text = (order == AUTH_CIPHERTEXT); ses_params.op_mode = suite_context.op_mode; - ses_params.cipher_alg = cipher_alg; - ses_params.auth_alg = auth_alg; + ses_params.cipher_alg = ref->cipher; + ses_params.auth_alg = ref->auth; ses_params.compl_queue = suite_context.queue; ses_params.output_pool = suite_context.pool; ses_params.cipher_key = cipher_key; @@ -930,8 +197,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, if (!combo_warning_shown) { combo_warning_shown = 1; printf("\n Unsupported algorithm combination: %s, %s\n", - cipher_alg_name(cipher_alg), - auth_alg_name(auth_alg)); + cipher_alg_name(ref->cipher), + auth_alg_name(ref->auth)); } return ODP_CRYPTO_SESSION_INVALID; } @@ -944,8 +211,8 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, if (rc < 0 && status == ODP_CRYPTO_SES_ERR_ALG_ORDER && ses_params.op_mode == ODP_CRYPTO_ASYNC) { printf("\n Unsupported algorithm order: %s, %s, auth_cipher_text: %d\n", - cipher_alg_name(cipher_alg), - auth_alg_name(auth_alg), + cipher_alg_name(ref->cipher), + auth_alg_name(ref->auth), ses_params.auth_cipher_text); return ODP_CRYPTO_SESSION_INVALID; } @@ -977,8 +244,6 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, static void alg_test_ses(odp_crypto_op_t op, odp_crypto_op_type_t op_type, - odp_cipher_alg_t cipher_alg, - odp_auth_alg_t auth_alg, alg_order_t order, crypto_test_reference_t *ref, odp_packet_data_range_t cipher_range, @@ -994,13 +259,13 @@ static void alg_test_ses(odp_crypto_op_t op, int rc; uint32_t seg_len; uint32_t max_shift; - alg_test_param_t test_param; + crypto_op_test_param_t test_param; if (digest_offset >= auth_range.offset && digest_offset < auth_range.offset + auth_range.length) hash_mode = HASH_OVERLAP; - session = session_create(op, op_type, cipher_alg, auth_alg, order, ref, hash_mode); + session = session_create(op, op_type, order, ref, hash_mode); if (session == ODP_CRYPTO_SESSION_INVALID) return; @@ -1008,8 +273,6 @@ static void alg_test_ses(odp_crypto_op_t op, test_param.session = session; test_param.op = op; test_param.op_type = op_type; - test_param.cipher_alg = cipher_alg; - test_param.auth_alg = auth_alg; test_param.ref = ref; test_param.cipher_range = cipher_range; test_param.auth_range = auth_range; @@ -1023,8 +286,8 @@ static void alg_test_ses(odp_crypto_op_t op, seg_len = 0; if (!full_test && - cipher_alg != ODP_CIPHER_ALG_NULL && - auth_alg != ODP_AUTH_ALG_NULL) { + ref->cipher != ODP_CIPHER_ALG_NULL && + ref->auth != ODP_AUTH_ALG_NULL) { /* run the loop body just once */ seg_len = max_shift / 2; max_shift = seg_len; @@ -1061,8 +324,6 @@ static void alg_test_ses(odp_crypto_op_t op, } static void alg_test(odp_crypto_op_t op, - odp_cipher_alg_t cipher_alg, - odp_auth_alg_t auth_alg, alg_order_t order, crypto_test_reference_t *ref, odp_packet_data_range_t cipher_range, @@ -1078,13 +339,8 @@ static void alg_test(odp_crypto_op_t op, }; for (unsigned int n = 0; n < ARRAY_SIZE(op_types); n++) { - if (!suite_context.packet && - op_types[n] != ODP_CRYPTO_OP_TYPE_LEGACY) - continue; alg_test_ses(op, op_types[n], - cipher_alg, - auth_alg, order, ref, cipher_range, @@ -1109,12 +365,12 @@ static odp_bool_t aad_len_ok(const odp_crypto_auth_capability_t *capa, uint32_t } static void check_alg(odp_crypto_op_t op, - odp_cipher_alg_t cipher_alg, - odp_auth_alg_t auth_alg, crypto_test_reference_t *ref, size_t count) { int rc, i; + const odp_cipher_alg_t cipher_alg = ref->cipher; + const odp_auth_alg_t auth_alg = ref->auth; int cipher_num = odp_crypto_cipher_capability(cipher_alg, NULL, 0); int auth_num = odp_crypto_auth_capability(auth_alg, NULL, 0); odp_bool_t cipher_ok = false; @@ -1216,10 +472,10 @@ static void check_alg(odp_crypto_op_t op, ref_length_in_bits(&ref[idx]) : ref_length_in_bytes(&ref[idx]); - alg_test(op, cipher_alg, auth_alg, AUTH_PLAINTEXT, &ref[idx], + alg_test(op, AUTH_PLAINTEXT, &ref[idx], cipher_range, auth_range, digest_offs, is_bit_mode_cipher, is_bit_mode_auth); - alg_test(op, cipher_alg, auth_alg, AUTH_CIPHERTEXT, &ref[idx], + alg_test(op, AUTH_CIPHERTEXT, &ref[idx], cipher_range, auth_range, digest_offs, is_bit_mode_cipher, is_bit_mode_auth); @@ -1254,214 +510,6 @@ static void check_alg(odp_crypto_op_t op, CU_ASSERT(auth_ok); } -/** - * Check if given cipher and authentication algorithms are supported - * - * @param cipher Cipher algorithm - * @param auth Authentication algorithm - * - * @retval ODP_TEST_ACTIVE when both algorithms are supported - * @retval ODP_TEST_INACTIVE when either algorithm is not supported - */ -static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) -{ - odp_crypto_capability_t capability; - - memset(&capability, 0, sizeof(odp_crypto_capability_t)); - if (odp_crypto_capability(&capability)) { - fprintf(stderr, "odp_crypto_capability() failed\n"); - return ODP_TEST_INACTIVE; - } - - if (suite_context.queue != ODP_QUEUE_INVALID) { - if (suite_context.q_type == ODP_QUEUE_TYPE_PLAIN && - capability.queue_type_plain == 0) - return ODP_TEST_INACTIVE; - if (suite_context.q_type == ODP_QUEUE_TYPE_SCHED && - capability.queue_type_sched == 0) - return ODP_TEST_INACTIVE; - } - - if (suite_context.op_mode == ODP_CRYPTO_SYNC && - capability.sync_mode == ODP_SUPPORT_NO) - return ODP_TEST_INACTIVE; - if (suite_context.op_mode == ODP_CRYPTO_ASYNC && - capability.async_mode == ODP_SUPPORT_NO) - return ODP_TEST_INACTIVE; - - /* Cipher algorithms */ - switch (cipher) { - case ODP_CIPHER_ALG_NULL: - if (!capability.ciphers.bit.null) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_DES: - if (!capability.ciphers.bit.des) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_3DES_CBC: - if (!capability.ciphers.bit.trides_cbc) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_3DES_ECB: - if (!capability.ciphers.bit.trides_ecb) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_CBC: - if (!capability.ciphers.bit.aes_cbc) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_CTR: - if (!capability.ciphers.bit.aes_ctr) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_ECB: - if (!capability.ciphers.bit.aes_ecb) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_CFB128: - if (!capability.ciphers.bit.aes_cfb128) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_XTS: - if (!capability.ciphers.bit.aes_xts) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_GCM: - if (!capability.ciphers.bit.aes_gcm) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_CCM: - if (!capability.ciphers.bit.aes_ccm) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_CHACHA20_POLY1305: - if (!capability.ciphers.bit.chacha20_poly1305) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_KASUMI_F8: - if (!capability.ciphers.bit.kasumi_f8) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_SNOW3G_UEA2: - if (!capability.ciphers.bit.snow3g_uea2) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_AES_EEA2: - if (!capability.ciphers.bit.aes_eea2) - return ODP_TEST_INACTIVE; - break; - case ODP_CIPHER_ALG_ZUC_EEA3: - if (!capability.ciphers.bit.zuc_eea3) - return ODP_TEST_INACTIVE; - break; - default: - fprintf(stderr, "Unsupported cipher algorithm\n"); - return ODP_TEST_INACTIVE; - } - - /* Authentication algorithms */ - switch (auth) { - case ODP_AUTH_ALG_NULL: - if (!capability.auths.bit.null) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_MD5_HMAC: - if (!capability.auths.bit.md5_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA1_HMAC: - if (!capability.auths.bit.sha1_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA224_HMAC: - if (!capability.auths.bit.sha224_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA256_HMAC: - if (!capability.auths.bit.sha256_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA384_HMAC: - if (!capability.auths.bit.sha384_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA512_HMAC: - if (!capability.auths.bit.sha512_hmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_XCBC_MAC: - if (!capability.auths.bit.aes_xcbc_mac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_GCM: - if (!capability.auths.bit.aes_gcm) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_GMAC: - if (!capability.auths.bit.aes_gmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_CCM: - if (!capability.auths.bit.aes_ccm) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_CMAC: - if (!capability.auths.bit.aes_cmac) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_CHACHA20_POLY1305: - if (!capability.auths.bit.chacha20_poly1305) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_KASUMI_F9: - if (!capability.auths.bit.kasumi_f9) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SNOW3G_UIA2: - if (!capability.auths.bit.snow3g_uia2) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_AES_EIA2: - if (!capability.auths.bit.aes_eia2) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_ZUC_EIA3: - if (!capability.auths.bit.zuc_eia3) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_MD5: - if (!capability.auths.bit.md5) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA1: - if (!capability.auths.bit.sha1) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA224: - if (!capability.auths.bit.sha224) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA256: - if (!capability.auths.bit.sha256) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA384: - if (!capability.auths.bit.sha384) - return ODP_TEST_INACTIVE; - break; - case ODP_AUTH_ALG_SHA512: - if (!capability.auths.bit.sha512) - return ODP_TEST_INACTIVE; - break; - default: - fprintf(stderr, "Unsupported authentication algorithm\n"); - return ODP_TEST_INACTIVE; - } - - return ODP_TEST_ACTIVE; -} - static void test_capability(void) { odp_crypto_capability_t capa = {.max_sessions = 1}; @@ -1495,15 +543,14 @@ static int create_hash_test_reference(odp_auth_alg_t auth, odp_bool_t ok; const uint32_t auth_bytes = 100; uint32_t enc_digest_offset = auth_bytes; - odp_packet_data_range_t cipher_range = {.offset = 0, .length = 0}; - odp_packet_data_range_t auth_range = {.offset = 0}; + ref->cipher = ODP_CIPHER_ALG_NULL; + ref->auth = auth; ref->auth_key_length = capa->key_len; ref->auth_iv_length = capa->iv_len; ref->digest_length = capa->digest_len; ref->is_length_in_bits = false; ref->length = auth_bytes; - auth_range.length = capa->bit_mode ? auth_bytes * 8 : auth_bytes; if (ref->auth_key_length > MAX_KEY_LEN || ref->auth_iv_length > MAX_IV_LEN || @@ -1525,15 +572,28 @@ static int create_hash_test_reference(odp_auth_alg_t auth, session = session_create(ODP_CRYPTO_OP_ENCODE, ODP_CRYPTO_OP_TYPE_LEGACY, - ODP_CIPHER_ALG_NULL, - auth, AUTH_PLAINTEXT, ref, HASH_NO_OVERLAP); + AUTH_PLAINTEXT, ref, HASH_NO_OVERLAP); if (session == ODP_CRYPTO_SESSION_INVALID) return -1; - rc = crypto_op(pkt, &pkt, &ok, session, ODP_CRYPTO_OP_TYPE_LEGACY, 0, - ref->cipher_iv, ref->auth_iv, - &cipher_range, &auth_range, ref->aad, enc_digest_offset); + odp_crypto_packet_op_param_t op_params = { + .session = session, + .cipher_iv_ptr = ref->cipher_iv, + .auth_iv_ptr = ref->auth_iv, + .hash_result_offset = enc_digest_offset, + .aad_ptr = ref->aad, + .cipher_range = {.offset = 0, .length = 0}, + .auth_range = { .offset = 0, + .length = capa->bit_mode ? auth_bytes * 8 : auth_bytes }, + .dst_offset_shift = 0, + }; + rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_LEGACY); + CU_ASSERT(rc == 0); + if (rc) { + (void)odp_crypto_session_destroy(session); + return -1; + } CU_ASSERT(ok); rc = odp_crypto_session_destroy(session); @@ -1590,8 +650,6 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * hash bytes in the ciphertext packet before calculating the hash. */ alg_test(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - auth, order, &ref, cipher_range, auth_range, @@ -1619,8 +677,6 @@ static void test_auth_hash_in_auth_range(odp_auth_alg_t auth, * the hash bytes in the plaintext packet before calculating the hash. */ alg_test(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - auth, order, &ref, cipher_range, auth_range, @@ -1700,8 +756,6 @@ static void test_auth_hashes_in_auth_range(void) * Encode ref->plaintext and save result in ref->ciphertext. */ static int crypto_encode_ref(crypto_test_reference_t *ref, - odp_cipher_alg_t cipher, - odp_auth_alg_t auth, odp_packet_data_range_t cipher_range, odp_packet_data_range_t auth_range, uint32_t hash_result_offset) @@ -1720,8 +774,6 @@ static int crypto_encode_ref(crypto_test_reference_t *ref, session = session_create(ODP_CRYPTO_OP_ENCODE, ODP_CRYPTO_OP_TYPE_LEGACY, - cipher, - auth, AUTH_PLAINTEXT, ref, HASH_OVERLAP); @@ -1731,20 +783,31 @@ static int crypto_encode_ref(crypto_test_reference_t *ref, return 1; } - if (cipher == ODP_CIPHER_ALG_NULL) + if (ref->cipher == ODP_CIPHER_ALG_NULL) cipher_range = zero_range; - if (auth == ODP_AUTH_ALG_NULL) { + if (ref->auth == ODP_AUTH_ALG_NULL) { auth_range = zero_range; hash_result_offset = 0; } CU_ASSERT_FATAL(hash_result_offset + ref->digest_length <= ref->length); - rc = crypto_op(pkt, &pkt, &ok, session, ODP_CRYPTO_OP_TYPE_LEGACY, 0, - ref->cipher_iv, ref->auth_iv, - &cipher_range, &auth_range, - ref->aad, hash_result_offset); + odp_crypto_packet_op_param_t op_params = { + .session = session, + .cipher_iv_ptr = ref->cipher_iv, + .auth_iv_ptr = ref->auth_iv, + .hash_result_offset = hash_result_offset, + .aad_ptr = ref->aad, + .cipher_range = cipher_range, + .auth_range = auth_range, + .dst_offset_shift = 0, + }; + rc = crypto_op(pkt, &pkt, &ok, &op_params, ODP_CRYPTO_OP_TYPE_LEGACY); CU_ASSERT(rc == 0); + if (rc) { + (void)odp_crypto_session_destroy(session); + return -1; + } CU_ASSERT(ok); rc = odp_crypto_session_destroy(session); @@ -1780,8 +843,6 @@ static int create_combined_ref(const crypto_suite_t *suite, crypto_test_reference_t ref_cipher_only; crypto_test_reference_t ref_auth_only; crypto_test_reference_t *first_ref, *second_ref; - odp_auth_alg_t first_auth, second_auth; - odp_cipher_alg_t first_cipher, second_cipher; total_len = cipher_range->offset + cipher_range->length; if (auth_range->offset + auth_range->length > total_len) @@ -1789,6 +850,8 @@ static int create_combined_ref(const crypto_suite_t *suite, if (digest_offset + suite->auth_capa->digest_len > total_len) total_len = digest_offset + suite->auth_capa->digest_len; + ref->cipher = suite->cipher; + ref->auth = suite->auth; ref->cipher_key_length = suite->cipher_capa->key_len; ref->cipher_iv_length = suite->cipher_capa->iv_len; ref->auth_key_length = suite->auth_capa->key_len; @@ -1821,39 +884,31 @@ static int create_combined_ref(const crypto_suite_t *suite, memset(ref->plaintext + digest_offset, 0, ref->digest_length); ref_cipher_only = *ref; + ref_cipher_only.auth = ODP_AUTH_ALG_NULL; ref_cipher_only.auth_key_length = 0; ref_cipher_only.auth_iv_length = 0; ref_cipher_only.aad_length = 0; ref_cipher_only.digest_length = 0; ref_auth_only = *ref; + ref_auth_only.cipher = ODP_CIPHER_ALG_NULL; ref_auth_only.cipher_key_length = 0; ref_auth_only.cipher_iv_length = 0; if (suite->order == AUTH_CIPHERTEXT) { first_ref = &ref_cipher_only; - first_cipher = suite->cipher; - first_auth = ODP_AUTH_ALG_NULL; second_ref = &ref_auth_only; - second_cipher = ODP_CIPHER_ALG_NULL; - second_auth = suite->auth; } else { first_ref = &ref_auth_only; - first_cipher = ODP_CIPHER_ALG_NULL; - first_auth = suite->auth; second_ref = &ref_cipher_only; - second_cipher = suite->cipher; - second_auth = ODP_AUTH_ALG_NULL; } rc = crypto_encode_ref(first_ref, - first_cipher, first_auth, *cipher_range, *auth_range, digest_offset); if (rc) return 1; memcpy(second_ref->plaintext, first_ref->ciphertext, ref->length); rc = crypto_encode_ref(second_ref, - second_cipher, second_auth, *cipher_range, *auth_range, digest_offset); if (rc) @@ -2135,8 +1190,6 @@ static void test_combo(const crypto_suite_t *suite, return; alg_test(ODP_CRYPTO_OP_ENCODE, - suite->cipher, - suite->auth, suite->order, &ref, cipher_range, auth_range, @@ -2145,8 +1198,6 @@ static void test_combo(const crypto_suite_t *suite, suite->auth_capa->bit_mode); alg_test(ODP_CRYPTO_OP_DECODE, - suite->cipher, - suite->auth, suite->order, &ref, cipher_range, auth_range, @@ -2238,8 +1289,6 @@ static int check_alg_null(void) static void crypto_test_enc_alg_null(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_NULL, null_reference, ARRAY_SIZE(null_reference)); } @@ -2247,8 +1296,6 @@ static void crypto_test_enc_alg_null(void) static void crypto_test_dec_alg_null(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_NULL, null_reference, ARRAY_SIZE(null_reference)); } @@ -2261,8 +1308,6 @@ static int check_alg_3des_cbc(void) static void crypto_test_enc_alg_3des_cbc(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_3DES_CBC, - ODP_AUTH_ALG_NULL, tdes_cbc_reference, ARRAY_SIZE(tdes_cbc_reference)); } @@ -2270,8 +1315,6 @@ static void crypto_test_enc_alg_3des_cbc(void) static void crypto_test_dec_alg_3des_cbc(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_3DES_CBC, - ODP_AUTH_ALG_NULL, tdes_cbc_reference, ARRAY_SIZE(tdes_cbc_reference)); } @@ -2284,8 +1327,6 @@ static int check_alg_3des_ecb(void) static void crypto_test_enc_alg_3des_ecb(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_3DES_ECB, - ODP_AUTH_ALG_NULL, tdes_ecb_reference, ARRAY_SIZE(tdes_ecb_reference)); } @@ -2293,8 +1334,6 @@ static void crypto_test_enc_alg_3des_ecb(void) static void crypto_test_dec_alg_3des_ecb(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_3DES_ECB, - ODP_AUTH_ALG_NULL, tdes_ecb_reference, ARRAY_SIZE(tdes_ecb_reference)); } @@ -2308,8 +1347,6 @@ static int check_alg_chacha20_poly1305(void) static void crypto_test_enc_alg_chacha20_poly1305(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_CHACHA20_POLY1305, - ODP_AUTH_ALG_CHACHA20_POLY1305, chacha20_poly1305_reference, ARRAY_SIZE(chacha20_poly1305_reference)); } @@ -2317,8 +1354,6 @@ static void crypto_test_enc_alg_chacha20_poly1305(void) static void crypto_test_dec_alg_chacha20_poly1305(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_CHACHA20_POLY1305, - ODP_AUTH_ALG_CHACHA20_POLY1305, chacha20_poly1305_reference, ARRAY_SIZE(chacha20_poly1305_reference)); } @@ -2331,8 +1366,6 @@ static int check_alg_aes_gcm(void) static void crypto_test_enc_alg_aes_gcm(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_GCM, - ODP_AUTH_ALG_AES_GCM, aes_gcm_reference, ARRAY_SIZE(aes_gcm_reference)); } @@ -2340,8 +1373,6 @@ static void crypto_test_enc_alg_aes_gcm(void) static void crypto_test_dec_alg_aes_gcm(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_GCM, - ODP_AUTH_ALG_AES_GCM, aes_gcm_reference, ARRAY_SIZE(aes_gcm_reference)); } @@ -2354,8 +1385,6 @@ static int check_alg_aes_ccm(void) static void crypto_test_enc_alg_aes_ccm(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_CCM, - ODP_AUTH_ALG_AES_CCM, aes_ccm_reference, ARRAY_SIZE(aes_ccm_reference)); } @@ -2363,8 +1392,6 @@ static void crypto_test_enc_alg_aes_ccm(void) static void crypto_test_dec_alg_aes_ccm(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_CCM, - ODP_AUTH_ALG_AES_CCM, aes_ccm_reference, ARRAY_SIZE(aes_ccm_reference)); } @@ -2377,8 +1404,6 @@ static int check_alg_aes_cbc(void) static void crypto_test_enc_alg_aes_cbc(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_CBC, - ODP_AUTH_ALG_NULL, aes_cbc_reference, ARRAY_SIZE(aes_cbc_reference)); } @@ -2386,8 +1411,6 @@ static void crypto_test_enc_alg_aes_cbc(void) static void crypto_test_dec_alg_aes_cbc(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_CBC, - ODP_AUTH_ALG_NULL, aes_cbc_reference, ARRAY_SIZE(aes_cbc_reference)); } @@ -2400,8 +1423,6 @@ static int check_alg_aes_ctr(void) static void crypto_test_enc_alg_aes_ctr(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_CTR, - ODP_AUTH_ALG_NULL, aes_ctr_reference, ARRAY_SIZE(aes_ctr_reference)); } @@ -2409,8 +1430,6 @@ static void crypto_test_enc_alg_aes_ctr(void) static void crypto_test_dec_alg_aes_ctr(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_CTR, - ODP_AUTH_ALG_NULL, aes_ctr_reference, ARRAY_SIZE(aes_ctr_reference)); } @@ -2423,8 +1442,6 @@ static int check_alg_aes_ecb(void) static void crypto_test_enc_alg_aes_ecb(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_ECB, - ODP_AUTH_ALG_NULL, aes_ecb_reference, ARRAY_SIZE(aes_ecb_reference)); } @@ -2432,8 +1449,6 @@ static void crypto_test_enc_alg_aes_ecb(void) static void crypto_test_dec_alg_aes_ecb(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_ECB, - ODP_AUTH_ALG_NULL, aes_ecb_reference, ARRAY_SIZE(aes_ecb_reference)); } @@ -2446,8 +1461,6 @@ static int check_alg_aes_cfb128(void) static void crypto_test_enc_alg_aes_cfb128(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_CFB128, - ODP_AUTH_ALG_NULL, aes_cfb128_reference, ARRAY_SIZE(aes_cfb128_reference)); } @@ -2455,8 +1468,6 @@ static void crypto_test_enc_alg_aes_cfb128(void) static void crypto_test_dec_alg_aes_cfb128(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_CFB128, - ODP_AUTH_ALG_NULL, aes_cfb128_reference, ARRAY_SIZE(aes_cfb128_reference)); } @@ -2469,8 +1480,6 @@ static int check_alg_aes_xts(void) static void crypto_test_enc_alg_aes_xts(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_XTS, - ODP_AUTH_ALG_NULL, aes_xts_reference, ARRAY_SIZE(aes_xts_reference)); } @@ -2478,8 +1487,6 @@ static void crypto_test_enc_alg_aes_xts(void) static void crypto_test_dec_alg_aes_xts(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_XTS, - ODP_AUTH_ALG_NULL, aes_xts_reference, ARRAY_SIZE(aes_xts_reference)); } @@ -2492,8 +1499,6 @@ static int check_alg_kasumi_f8(void) static void crypto_test_enc_alg_kasumi_f8(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_KASUMI_F8, - ODP_AUTH_ALG_NULL, kasumi_f8_reference, ARRAY_SIZE(kasumi_f8_reference)); } @@ -2501,8 +1506,6 @@ static void crypto_test_enc_alg_kasumi_f8(void) static void crypto_test_dec_alg_kasumi_f8(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_KASUMI_F8, - ODP_AUTH_ALG_NULL, kasumi_f8_reference, ARRAY_SIZE(kasumi_f8_reference)); } @@ -2515,8 +1518,6 @@ static int check_alg_snow3g_uea2(void) static void crypto_test_enc_alg_snow3g_uea2(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_SNOW3G_UEA2, - ODP_AUTH_ALG_NULL, snow3g_uea2_reference, ARRAY_SIZE(snow3g_uea2_reference)); } @@ -2524,8 +1525,6 @@ static void crypto_test_enc_alg_snow3g_uea2(void) static void crypto_test_dec_alg_snow3g_uea2(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_SNOW3G_UEA2, - ODP_AUTH_ALG_NULL, snow3g_uea2_reference, ARRAY_SIZE(snow3g_uea2_reference)); } @@ -2539,8 +1538,6 @@ static int check_alg_aes_eea2(void) static void crypto_test_enc_alg_aes_eea2(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_AES_EEA2, - ODP_AUTH_ALG_NULL, aes_eea2_reference, ARRAY_SIZE(aes_eea2_reference)); } @@ -2548,8 +1545,6 @@ static void crypto_test_enc_alg_aes_eea2(void) static void crypto_test_dec_alg_aes_eea2(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_AES_EEA2, - ODP_AUTH_ALG_NULL, aes_eea2_reference, ARRAY_SIZE(aes_eea2_reference)); } @@ -2562,8 +1557,6 @@ static int check_alg_zuc_eea3(void) static void crypto_test_enc_alg_zuc_eea3(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_ZUC_EEA3, - ODP_AUTH_ALG_NULL, zuc_eea3_reference, ARRAY_SIZE(zuc_eea3_reference)); } @@ -2571,8 +1564,6 @@ static void crypto_test_enc_alg_zuc_eea3(void) static void crypto_test_dec_alg_zuc_eea3(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_ZUC_EEA3, - ODP_AUTH_ALG_NULL, zuc_eea3_reference, ARRAY_SIZE(zuc_eea3_reference)); } @@ -2585,8 +1576,6 @@ static int check_alg_hmac_md5(void) static void crypto_test_gen_alg_hmac_md5(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_MD5_HMAC, hmac_md5_reference, ARRAY_SIZE(hmac_md5_reference)); } @@ -2594,8 +1583,6 @@ static void crypto_test_gen_alg_hmac_md5(void) static void crypto_test_check_alg_hmac_md5(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_MD5_HMAC, hmac_md5_reference, ARRAY_SIZE(hmac_md5_reference)); } @@ -2608,8 +1595,6 @@ static int check_alg_hmac_sha1(void) static void crypto_test_gen_alg_hmac_sha1(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA1_HMAC, hmac_sha1_reference, ARRAY_SIZE(hmac_sha1_reference)); } @@ -2617,8 +1602,6 @@ static void crypto_test_gen_alg_hmac_sha1(void) static void crypto_test_check_alg_hmac_sha1(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA1_HMAC, hmac_sha1_reference, ARRAY_SIZE(hmac_sha1_reference)); } @@ -2631,8 +1614,6 @@ static int check_alg_hmac_sha224(void) static void crypto_test_gen_alg_hmac_sha224(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA224_HMAC, hmac_sha224_reference, ARRAY_SIZE(hmac_sha224_reference)); } @@ -2640,8 +1621,6 @@ static void crypto_test_gen_alg_hmac_sha224(void) static void crypto_test_check_alg_hmac_sha224(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA224_HMAC, hmac_sha224_reference, ARRAY_SIZE(hmac_sha224_reference)); } @@ -2654,8 +1633,6 @@ static int check_alg_hmac_sha256(void) static void crypto_test_gen_alg_hmac_sha256(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA256_HMAC, hmac_sha256_reference, ARRAY_SIZE(hmac_sha256_reference)); } @@ -2663,8 +1640,6 @@ static void crypto_test_gen_alg_hmac_sha256(void) static void crypto_test_check_alg_hmac_sha256(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA256_HMAC, hmac_sha256_reference, ARRAY_SIZE(hmac_sha256_reference)); } @@ -2677,8 +1652,6 @@ static int check_alg_hmac_sha384(void) static void crypto_test_gen_alg_hmac_sha384(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA384_HMAC, hmac_sha384_reference, ARRAY_SIZE(hmac_sha384_reference)); } @@ -2686,8 +1659,6 @@ static void crypto_test_gen_alg_hmac_sha384(void) static void crypto_test_check_alg_hmac_sha384(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA384_HMAC, hmac_sha384_reference, ARRAY_SIZE(hmac_sha384_reference)); } @@ -2700,8 +1671,6 @@ static int check_alg_hmac_sha512(void) static void crypto_test_gen_alg_hmac_sha512(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA512_HMAC, hmac_sha512_reference, ARRAY_SIZE(hmac_sha512_reference)); } @@ -2709,8 +1678,6 @@ static void crypto_test_gen_alg_hmac_sha512(void) static void crypto_test_check_alg_hmac_sha512(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA512_HMAC, hmac_sha512_reference, ARRAY_SIZE(hmac_sha512_reference)); } @@ -2724,8 +1691,6 @@ static int check_alg_aes_xcbc(void) static void crypto_test_gen_alg_aes_xcbc(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_XCBC_MAC, aes_xcbc_reference, ARRAY_SIZE(aes_xcbc_reference)); } @@ -2733,8 +1698,6 @@ static void crypto_test_gen_alg_aes_xcbc(void) static void crypto_test_check_alg_aes_xcbc(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_XCBC_MAC, aes_xcbc_reference, ARRAY_SIZE(aes_xcbc_reference)); } @@ -2747,8 +1710,6 @@ static int check_alg_aes_gmac(void) static void crypto_test_gen_alg_aes_gmac(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_GMAC, aes_gmac_reference, ARRAY_SIZE(aes_gmac_reference)); } @@ -2756,8 +1717,6 @@ static void crypto_test_gen_alg_aes_gmac(void) static void crypto_test_check_alg_aes_gmac(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_GMAC, aes_gmac_reference, ARRAY_SIZE(aes_gmac_reference)); } @@ -2770,8 +1729,6 @@ static int check_alg_aes_cmac(void) static void crypto_test_gen_alg_aes_cmac(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_CMAC, aes_cmac_reference, ARRAY_SIZE(aes_cmac_reference)); } @@ -2779,8 +1736,6 @@ static void crypto_test_gen_alg_aes_cmac(void) static void crypto_test_check_alg_aes_cmac(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_CMAC, aes_cmac_reference, ARRAY_SIZE(aes_cmac_reference)); } @@ -2793,8 +1748,6 @@ static int check_alg_kasumi_f9(void) static void crypto_test_gen_alg_kasumi_f9(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_KASUMI_F9, kasumi_f9_reference, ARRAY_SIZE(kasumi_f9_reference)); } @@ -2802,8 +1755,6 @@ static void crypto_test_gen_alg_kasumi_f9(void) static void crypto_test_check_alg_kasumi_f9(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_KASUMI_F9, kasumi_f9_reference, ARRAY_SIZE(kasumi_f9_reference)); } @@ -2816,8 +1767,6 @@ static int check_alg_snow3g_uia2(void) static void crypto_test_gen_alg_snow3g_uia2(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SNOW3G_UIA2, snow3g_uia2_reference, ARRAY_SIZE(snow3g_uia2_reference)); } @@ -2825,8 +1774,6 @@ static void crypto_test_gen_alg_snow3g_uia2(void) static void crypto_test_check_alg_snow3g_uia2(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SNOW3G_UIA2, snow3g_uia2_reference, ARRAY_SIZE(snow3g_uia2_reference)); } @@ -2840,8 +1787,6 @@ static int check_alg_aes_eia2(void) static void crypto_test_gen_alg_aes_eia2(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_EIA2, aes_eia2_reference, ARRAY_SIZE(aes_eia2_reference)); } @@ -2849,8 +1794,6 @@ static void crypto_test_gen_alg_aes_eia2(void) static void crypto_test_check_alg_aes_eia2(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_AES_EIA2, aes_eia2_reference, ARRAY_SIZE(aes_eia2_reference)); } @@ -2863,8 +1806,6 @@ static int check_alg_zuc_eia3(void) static void crypto_test_gen_alg_zuc_eia3(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_ZUC_EIA3, zuc_eia3_reference, ARRAY_SIZE(zuc_eia3_reference)); } @@ -2872,8 +1813,6 @@ static void crypto_test_gen_alg_zuc_eia3(void) static void crypto_test_check_alg_zuc_eia3(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_ZUC_EIA3, zuc_eia3_reference, ARRAY_SIZE(zuc_eia3_reference)); } @@ -2886,8 +1825,6 @@ static int check_alg_md5(void) static void crypto_test_gen_alg_md5(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_MD5, md5_reference, ARRAY_SIZE(md5_reference)); } @@ -2895,8 +1832,6 @@ static void crypto_test_gen_alg_md5(void) static void crypto_test_check_alg_md5(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_MD5, md5_reference, ARRAY_SIZE(md5_reference)); } @@ -2909,8 +1844,6 @@ static int check_alg_sha1(void) static void crypto_test_gen_alg_sha1(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA1, sha1_reference, ARRAY_SIZE(sha1_reference)); } @@ -2918,8 +1851,6 @@ static void crypto_test_gen_alg_sha1(void) static void crypto_test_check_alg_sha1(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA1, sha1_reference, ARRAY_SIZE(sha1_reference)); } @@ -2932,8 +1863,6 @@ static int check_alg_sha224(void) static void crypto_test_gen_alg_sha224(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA224, sha224_reference, ARRAY_SIZE(sha224_reference)); } @@ -2941,8 +1870,6 @@ static void crypto_test_gen_alg_sha224(void) static void crypto_test_check_alg_sha224(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA224, sha224_reference, ARRAY_SIZE(sha224_reference)); } @@ -2955,8 +1882,6 @@ static int check_alg_sha256(void) static void crypto_test_gen_alg_sha256(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA256, sha256_reference, ARRAY_SIZE(sha256_reference)); } @@ -2964,8 +1889,6 @@ static void crypto_test_gen_alg_sha256(void) static void crypto_test_check_alg_sha256(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA256, sha256_reference, ARRAY_SIZE(sha256_reference)); } @@ -2978,8 +1901,6 @@ static int check_alg_sha384(void) static void crypto_test_gen_alg_sha384(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA384, sha384_reference, ARRAY_SIZE(sha384_reference)); } @@ -2987,8 +1908,6 @@ static void crypto_test_gen_alg_sha384(void) static void crypto_test_check_alg_sha384(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA384, sha384_reference, ARRAY_SIZE(sha384_reference)); } @@ -3001,8 +1920,6 @@ static int check_alg_sha512(void) static void crypto_test_gen_alg_sha512(void) { check_alg(ODP_CRYPTO_OP_ENCODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA512, sha512_reference, ARRAY_SIZE(sha512_reference)); } @@ -3010,8 +1927,6 @@ static void crypto_test_gen_alg_sha512(void) static void crypto_test_check_alg_sha512(void) { check_alg(ODP_CRYPTO_OP_DECODE, - ODP_CIPHER_ALG_NULL, - ODP_AUTH_ALG_SHA512, sha512_reference, ARRAY_SIZE(sha512_reference)); } @@ -3068,7 +1983,7 @@ static int crypto_suite_packet_async_plain_init(void) out_queue = plain_compl_queue_create(); if (ODP_QUEUE_INVALID == out_queue) { - fprintf(stderr, "Crypto outq creation failed.\n"); + ODPH_ERR("Crypto outq creation failed\n"); return -1; } suite_context.queue = out_queue; @@ -3090,7 +2005,7 @@ static int crypto_suite_packet_async_sched_init(void) out_queue = sched_compl_queue_create(); if (ODP_QUEUE_INVALID == out_queue) { - fprintf(stderr, "Crypto outq creation failed.\n"); + ODPH_ERR("Crypto outq creation failed\n"); return -1; } suite_context.queue = out_queue; @@ -3104,9 +2019,9 @@ static int crypto_suite_term(void) { if (ODP_QUEUE_INVALID != suite_context.queue) { if (odp_queue_destroy(suite_context.queue)) - fprintf(stderr, "Crypto outq destroy failed.\n"); + ODPH_ERR("Crypto outq destroy failed\n"); } else { - fprintf(stderr, "Crypto outq not found.\n"); + ODPH_ERR("Crypto outq not found\n"); } return odp_cunit_print_inactive(); @@ -3277,7 +2192,7 @@ static int crypto_init(odp_instance_t *inst) odph_helper_options_t helper_options; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -3285,23 +2200,23 @@ static int crypto_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } /* Configure the scheduler. */ if (odp_schedule_config(NULL)) { - fprintf(stderr, "odp_schedule_config() failed.\n"); + ODPH_ERR("odp_schedule_config() failed\n"); return -1; } if (odp_pool_capability(&pool_capa) < 0) { - fprintf(stderr, "error: odp_pool_capability() failed.\n"); + ODPH_ERR("odp_pool_capability() failed\n"); return -1; } @@ -3322,20 +2237,20 @@ static int crypto_init(odp_instance_t *inst) if (pool_capa.pkt.max_seg_len && PKT_POOL_LEN > pool_capa.pkt.max_seg_len) { - fprintf(stderr, "Warning: small packet segment length\n"); + ODPH_ERR("Warning: small packet segment length\n"); params.pkt.seg_len = pool_capa.pkt.max_seg_len; } if (pool_capa.pkt.max_len && PKT_POOL_LEN > pool_capa.pkt.max_len) { - fprintf(stderr, "Pool max packet length too small\n"); + ODPH_ERR("Pool max packet length too small\n"); return -1; } pool = odp_pool_create("packet_pool", ¶ms); if (ODP_POOL_INVALID == pool) { - fprintf(stderr, "Packet pool creation failed.\n"); + ODPH_ERR("Packet pool creation failed\n"); return -1; } @@ -3349,18 +2264,18 @@ static int crypto_term(odp_instance_t inst) pool = odp_pool_lookup("packet_pool"); if (ODP_POOL_INVALID != pool) { if (odp_pool_destroy(pool)) - fprintf(stderr, "Packet pool destroy failed.\n"); + ODPH_ERR("Packet pool destroy failed\n"); } else { - fprintf(stderr, "Packet pool not found.\n"); + ODPH_ERR("Packet pool not found\n"); } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/crypto/test_vector_defs.h b/test/validation/api/crypto/test_vector_defs.h new file mode 100644 index 000000000..46ae4e4e1 --- /dev/null +++ b/test/validation/api/crypto/test_vector_defs.h @@ -0,0 +1,3167 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TEST_VECTOR_DEFS_H +#define TEST_VECTOR_DEFS_H + +#include <odp_api.h> +#include "test_vectors.h" + +ODP_STATIC_ASSERT(ODP_CIPHER_ALG_NULL == 0, "null cipher is not the default"); +ODP_STATIC_ASSERT(ODP_AUTH_ALG_NULL == 0, "null auth is not the default"); + +static crypto_test_reference_t null_reference[] = { + { + .length = 8, + .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }, + .ciphertext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 } + }, + { + .length = 16, + .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, + 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }, + .ciphertext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, + 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 } + } +}; + +/* TDES-CBC reference vectors, according to + * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf" + */ +static crypto_test_reference_t tdes_cbc_reference[] = { + { + .cipher = ODP_CIPHER_ALG_3DES_CBC, + .cipher_key_length = TDES_CBC_KEY_LEN, + .cipher_key = { 0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, + 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1, + 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c}, + .cipher_iv_length = TDES_CBC_IV_LEN, + .cipher_iv = { 0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75 }, + .length = 8, + .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }, + .ciphertext = { 0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92 } + }, + { + .cipher = ODP_CIPHER_ALG_3DES_CBC, + .cipher_key_length = TDES_CBC_KEY_LEN, + .cipher_key = { 0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc, + 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85, + 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae}, + .cipher_iv_length = TDES_CBC_IV_LEN, + .cipher_iv = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65 }, + .length = 16, + .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, + 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }, + .ciphertext = { 0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, + 0xbd, 0x04, 0xa7, 0x5f, 0xfb, 0xa7, 0xd2, 0xf5 } + } +}; + +/* + * TDES-ECB reference vectors, according to + * CAVS 18.0 TECBMMT + */ +static crypto_test_reference_t tdes_ecb_reference[] = { + /* CAVS 18.0 TECBMMT2.rsp #0 */ + { + .cipher = ODP_CIPHER_ALG_3DES_ECB, + .cipher_key_length = TDES_ECB_KEY_LEN, + .cipher_key = { 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b, + 0x4a, 0x76, 0x3b, 0xd5, 0x4a, 0x46, 0xa4, 0x45, + 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b}, + .length = 8, + .plaintext = { 0xd8, 0xda, 0x89, 0x29, 0x88, 0x78, 0xed, 0x7d }, + .ciphertext = { 0x89, 0x32, 0x1b, 0xa7, 0x5b, 0xa5, 0x45, 0xdb } + }, + /* CAVS 18.0 TECBMMT2.rsp #2 */ + { + .cipher = ODP_CIPHER_ALG_3DES_ECB, + .cipher_key_length = TDES_ECB_KEY_LEN, + .cipher_key = { 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5, + 0xfe, 0xe6, 0x73, 0x34, 0x31, 0x1c, 0xa4, 0x62, + 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5}, + .length = 24, + .plaintext = { 0x2f, 0x2a, 0x36, 0x1c, 0x8e, 0x14, 0x5d, 0xc0, + 0xa7, 0x4a, 0x1b, 0xdb, 0x7c, 0xa9, 0x29, 0xc3, + 0x38, 0x14, 0x4d, 0x89, 0x13, 0x5b, 0x50, 0xa7 }, + .ciphertext = { 0x7f, 0x1f, 0xd3, 0x2b, 0x36, 0x90, 0x05, 0x4b, + 0xfa, 0x1b, 0x17, 0x35, 0x15, 0x79, 0x33, 0x80, + 0x99, 0xff, 0xa8, 0x4f, 0xea, 0x16, 0x8c, 0x6b } + } +}; + +static crypto_test_reference_t aes_cbc_reference[] = { + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, + 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, + 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, + .length = 16, + .plaintext = "Single block msg", + .ciphertext = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, + 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, + 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, + 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, + .length = 32, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, + .ciphertext = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a, + 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a, + 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9, + 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, + 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb, + 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 }, + .length = 48, + .plaintext = "This is a 48-byte message (exactly 3 AES blocks)", + .ciphertext = { 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53, + 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86, + 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7, + 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5, + 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c, + 0x85, 0x79, 0x69, 0x5d, 0x83, 0xba, 0x26, 0x84 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, + 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, + 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 }, + .length = 64, + .plaintext = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf }, + .ciphertext = { 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e, + 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa, + 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6, + 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e, + 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf, + 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad, + 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d, + 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88, 0x01, 0x23, 0x45, 0x67 }, + .length = 32, + .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00, + 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f, + 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8, + 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e }, + .ciphertext = { 0x0d, 0xbe, 0x02, 0xda, 0x68, 0x9c, 0x8f, 0x30, + 0xce, 0x7c, 0x91, 0x7d, 0x41, 0x08, 0xf6, 0xf1, + 0x8e, 0x0d, 0x7f, 0x02, 0xb6, 0x80, 0x9a, 0x2d, + 0x53, 0x1c, 0xc6, 0x98, 0x85, 0xc3, 0x00, 0xe6}, + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d, + 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8, + 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4, + 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a, + 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0, + 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0, + 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81, + 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, + 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, + 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, + 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c }, + .length = 48, + .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00, + 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02, + 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b, + 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00, + 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 }, + .ciphertext = { 0x92, 0x1e, 0x2f, 0x37, 0x36, 0x3c, 0x45, 0xda, + 0xc9, 0x58, 0xb7, 0x07, 0x06, 0x56, 0x54, 0xc5, + 0x93, 0x46, 0x90, 0xb8, 0xcf, 0x0d, 0x4f, 0x79, + 0xf1, 0x32, 0xc2, 0xf7, 0x23, 0xb8, 0x83, 0x09, + 0xbc, 0x37, 0x1c, 0xeb, 0x95, 0x2c, 0x42, 0x7b, + 0x39, 0x10, 0xa8, 0x76, 0xfa, 0xbe, 0x91, 0xe9}, + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CBC, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, + .cipher_iv_length = AES_CBC_IV_LEN, + .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, + 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6, + 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d, + 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d, + 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf, + 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61, + 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc, + 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b } + } +}; + +static crypto_test_reference_t aes_ctr_reference[] = { + /* RFC3686 https://tools.ietf.org/html/rfc3686 */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, + 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, + 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, + .length = 32, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, + .ciphertext = { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, + 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, + 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, + 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28} + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, + 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce, + 0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff, + 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff, + 0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e, + 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab, + 0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1, + 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee } + }, + /* Generated by Crypto++ 5.6.1 (715 bytes data)*/ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, + .length = 715, + .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, + 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, + 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, + 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, + 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, + 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, + 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, + 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, + 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, + 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, + 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, + 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, + 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, + 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, + 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, + 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, + 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, + 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, + 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, + 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, + 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, + 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, + 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, + 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, + 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, + 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, + 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, + 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, + 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, + 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, + 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, + 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, + 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, + 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, + 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, + 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, + 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, + 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, + 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, + 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, + 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, + 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, + 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, + 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, + 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, + 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, + 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, + 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, + 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, + 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, + 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, + 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, + 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, + 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, + 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, + 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, + 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, + 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, + 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, + 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, + 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, + 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, + 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, + 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, + 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, + 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, + 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, + 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, + 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, + 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, + 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, + 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, + 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, + 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, + 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, + 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, + 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, + 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, + 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, + 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, + 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xEC, 0xE7, 0x1E, 0xCD, 0x7A, 0x4E, 0x3C, 0x2F, + 0x64, 0x3B, 0x2B, 0x0B, 0xFB, 0xED, 0x32, 0xF3, + 0x1C, 0x85, 0x51, 0xB6, 0x30, 0x6D, 0x52, 0xCF, + 0x84, 0x3E, 0xC0, 0xB8, 0x50, 0x15, 0xDC, 0x20, + 0x3B, 0x1C, 0x0B, 0x64, 0x3E, 0x2A, 0x6B, 0xAB, + 0xAF, 0x51, 0x33, 0xDA, 0x0E, 0xA0, 0x66, 0x16, + 0x07, 0x6A, 0xA6, 0xBB, 0xB5, 0x2E, 0xD7, 0x5D, + 0xC3, 0xA7, 0x1A, 0x9A, 0x6E, 0x8A, 0xC7, 0xC9, + 0xA0, 0x0D, 0x2C, 0x39, 0xAA, 0x68, 0xBF, 0x4E, + 0x6F, 0xFE, 0xD9, 0xAA, 0xEE, 0x5A, 0xD6, 0x91, + 0x4F, 0xB3, 0xEA, 0x77, 0xC7, 0xB6, 0x1F, 0xF6, + 0xBF, 0x56, 0x4F, 0x2F, 0x12, 0x25, 0xAC, 0xB4, + 0xB5, 0x88, 0x9C, 0xB1, 0x55, 0x98, 0x88, 0xA5, + 0x81, 0x78, 0x49, 0xC3, 0x82, 0xE1, 0x68, 0x48, + 0x2F, 0x75, 0x38, 0x1F, 0x63, 0x86, 0x8C, 0x46, + 0x8E, 0x4D, 0x15, 0x83, 0xB1, 0xFE, 0x71, 0xDD, + 0x80, 0x8C, 0xB9, 0x4D, 0x81, 0x50, 0xAA, 0xB9, + 0xD5, 0x30, 0xA0, 0xFC, 0x17, 0xCD, 0xE7, 0x48, + 0xE9, 0x55, 0x45, 0xD8, 0xA0, 0x33, 0xB2, 0xF6, + 0x1F, 0x19, 0x54, 0xD0, 0xC0, 0x22, 0x61, 0x68, + 0x02, 0x2E, 0x1C, 0xD7, 0xE0, 0x31, 0xC5, 0x7D, + 0x04, 0x8A, 0xC5, 0x60, 0xF1, 0x52, 0x96, 0x0F, + 0x47, 0x70, 0x5E, 0x17, 0x4D, 0x95, 0x6D, 0x4B, + 0xB5, 0x3A, 0xE8, 0x0B, 0xFF, 0xCD, 0x1B, 0xD5, + 0x69, 0xED, 0x8E, 0xFF, 0xA2, 0x23, 0xC0, 0x05, + 0x58, 0xB7, 0x02, 0x40, 0x5F, 0x33, 0xE6, 0xE0, + 0xED, 0xB2, 0xD9, 0xB0, 0xC1, 0x48, 0xA1, 0x44, + 0x1C, 0xC8, 0x0D, 0x6A, 0xBB, 0xCE, 0x78, 0x5A, + 0xA1, 0xB9, 0xDA, 0xB7, 0xCB, 0x88, 0x32, 0xF1, + 0xB1, 0x2D, 0x2E, 0xE6, 0x0E, 0xE2, 0xDF, 0xCA, + 0x37, 0x94, 0x2C, 0xA1, 0x72, 0x4E, 0x56, 0x02, + 0xB7, 0xB7, 0x05, 0x25, 0xAC, 0x96, 0x62, 0x02, + 0x8A, 0x22, 0xDB, 0x23, 0x46, 0x76, 0x61, 0x5D, + 0xB4, 0x74, 0x53, 0x8C, 0xBC, 0x8D, 0x19, 0x7F, + 0x38, 0xC8, 0x8B, 0xCC, 0x4F, 0x9E, 0x8D, 0x20, + 0x75, 0x38, 0xCA, 0x18, 0xDE, 0x5F, 0x09, 0x54, + 0x20, 0xA2, 0xE4, 0xD5, 0x86, 0x8C, 0xEB, 0xB8, + 0xB3, 0x4A, 0x93, 0x77, 0xDC, 0x52, 0xD1, 0x19, + 0x79, 0x0B, 0x65, 0x21, 0x0F, 0x1B, 0x34, 0x6F, + 0x5E, 0x00, 0xD9, 0xBD, 0x00, 0xA8, 0x84, 0x70, + 0x48, 0x91, 0x3D, 0x80, 0x72, 0x6B, 0x9B, 0x74, + 0x5D, 0x56, 0x5E, 0x62, 0x84, 0xB9, 0x86, 0xDB, + 0xAE, 0xA9, 0x97, 0xFF, 0xC5, 0xA0, 0xDE, 0x50, + 0x51, 0x52, 0x7D, 0x44, 0xB2, 0xC1, 0x26, 0x6D, + 0xBC, 0x91, 0x30, 0xA6, 0xEB, 0x15, 0xF3, 0x7A, + 0x0F, 0x00, 0xB6, 0x28, 0x6D, 0x66, 0x78, 0xCA, + 0x65, 0x1C, 0x07, 0x74, 0x3B, 0xD3, 0x7F, 0x2E, + 0x8F, 0x6A, 0x94, 0xF5, 0xED, 0x8C, 0x63, 0x42, + 0x8A, 0xE4, 0x88, 0x3A, 0x96, 0x95, 0x18, 0x38, + 0x07, 0xE1, 0x04, 0xBC, 0x33, 0x5C, 0x64, 0xFE, + 0xAA, 0xC4, 0x0A, 0x60, 0x59, 0x13, 0xDF, 0x98, + 0xFF, 0x44, 0xE0, 0x80, 0x1B, 0x31, 0xA9, 0x68, + 0xCC, 0xE5, 0xDC, 0xAF, 0xAD, 0xE1, 0xE0, 0x17, + 0xFA, 0x71, 0x1E, 0x05, 0xFF, 0x5A, 0x54, 0xBF, + 0xA1, 0x99, 0x9C, 0x2C, 0x46, 0x3F, 0x97, 0xA3, + 0xA6, 0x6B, 0x30, 0x21, 0x1B, 0xD3, 0x06, 0xC8, + 0x91, 0x1C, 0x98, 0xF8, 0xEE, 0x5E, 0xF4, 0x7A, + 0x54, 0x74, 0x6A, 0x4D, 0x16, 0xB7, 0xC7, 0x42, + 0x4A, 0x69, 0x54, 0xB4, 0xFC, 0x3B, 0xCF, 0x1A, + 0x41, 0xBD, 0xE8, 0xA1, 0x9C, 0xE1, 0x02, 0x7A, + 0xE8, 0x6A, 0x32, 0x0D, 0x0E, 0x5E, 0x7D, 0x3C, + 0x7E, 0x50, 0xCF, 0xD0, 0xC4, 0x66, 0x5B, 0x81, + 0x1D, 0x86, 0xC3, 0x13, 0xF0, 0x9A, 0xDE, 0x5B, + 0x4D, 0xBE, 0x01, 0x72, 0x31, 0x85, 0x98, 0x81, + 0xE5, 0x87, 0x3E, 0x9E, 0xDB, 0x20, 0x11, 0xCF, + 0x59, 0x20, 0xD2, 0xF7, 0x27, 0x7C, 0x4D, 0xE1, + 0xAC, 0x43, 0x0A, 0x18, 0x49, 0xF0, 0xB8, 0x70, + 0xA6, 0x9A, 0xBE, 0x70, 0x1B, 0x6D, 0x0B, 0x51, + 0x23, 0xE5, 0xFF, 0x53, 0x39, 0x54, 0x09, 0x17, + 0x7C, 0xF8, 0x4B, 0xF4, 0x1E, 0xC3, 0x3C, 0x5E, + 0x4B, 0xCC, 0x2C, 0xF2, 0x92, 0x58, 0xDC, 0x7C, + 0x26, 0x04, 0x71, 0xAA, 0xBD, 0xA4, 0x9F, 0xDE, + 0x62, 0x91, 0x57, 0x58, 0xEE, 0x4E, 0x57, 0x8D, + 0x0F, 0x76, 0x98, 0xE6, 0x45, 0x6B, 0xC1, 0x44, + 0x57, 0x37, 0x39, 0xD5, 0xD5, 0x08, 0xCC, 0x76, + 0xB3, 0x89, 0x35, 0x9D, 0x2A, 0x0E, 0xCB, 0x5B, + 0x7E, 0xE5, 0xFC, 0xB4, 0xC3, 0x15, 0x1D, 0x5A, + 0xF7, 0xC7, 0x18, 0x19, 0xEA, 0x3D, 0xD5, 0xF3, + 0x6C, 0x7B, 0x27, 0xE5, 0x51, 0xFD, 0x23, 0x73, + 0xD0, 0x7F, 0xFD, 0xC7, 0x6A, 0x13, 0xFC, 0x4B, + 0x10, 0xA6, 0xF2, 0x9A, 0x83, 0xD6, 0xF4, 0x65, + 0xAC, 0xB6, 0x96, 0x06, 0x71, 0xEA, 0xCF, 0x21, + 0xA3, 0xE1, 0xCB, 0x44, 0x11, 0xC4, 0xDA, 0xA0, + 0xC2, 0xA8, 0x7D, 0xAE, 0xD2, 0x8A, 0xEE, 0x60, + 0xB7, 0xEC, 0x02, 0x58, 0xA9, 0xAF, 0x12, 0x5F, + 0x2D, 0xDC, 0x80, 0xB9, 0x87, 0x7E, 0xFE, 0x0F, + 0x37, 0x2D, 0x9B, 0x83, 0x2C, 0x78, 0x67, 0x70, + 0xA8, 0x4E, 0xA1, 0xA0, 0x7C, 0xB6, 0xE1, 0xA9, + 0x90, 0x7D, 0x65, 0x1B, 0xBD, 0x0E, 0xFD, 0xEF, + 0x2A, 0xFF, 0xC3 } + }, + /* RFC3686 https://tools.ietf.org/html/rfc3686 */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59, + 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B, + 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0x00, 0x07, 0xBD, 0xFD, 0x5C, 0xBD, 0x60, 0x27, + 0x8D, 0xCC, 0x09, 0x12, 0x00, 0x00, 0x00, 0x01 }, + .length = 36, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + .ciphertext = { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F, + 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58, + 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88, + 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88, + 0xAB, 0xEE, 0x09, 0x35 } + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2, + 0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b, + 0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef, + 0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94, + 0x1e, 0x36, 0xb2, 0x6b, 0xd1, 0xeb, 0xc6, 0x70, + 0xd1, 0xbd, 0x1d, 0x66, 0x56, 0x20, 0xab, 0xf7, + 0x4f, 0x78, 0xa7, 0xf6, 0xd2, 0x98, 0x09, 0x58, + 0x5a, 0x97, 0xda, 0xec, 0x58, 0xc6, 0xb0, 0x50 } + }, + /* RFC3686 https://tools.ietf.org/html/rfc3686 */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0xFF, 0x7A, 0x61, 0x7C, 0xE6, 0x91, 0x48, 0xE4, + 0xF1, 0x72, 0x6E, 0x2F, 0x43, 0x58, 0x1D, 0xE2, + 0xAA, 0x62, 0xD9, 0xF8, 0x05, 0x53, 0x2E, 0xDF, + 0xF1, 0xEE, 0xD6, 0x87, 0xFB, 0x54, 0x15, 0x3D}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0x00, 0x1C, 0xC5, 0xB7, 0x51, 0xA5, 0x1D, 0x70, + 0xA1, 0xC1, 0x11, 0x48, 0x00, 0x00, 0x00, 0x01 }, + .length = 36, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23 }, + .ciphertext = { 0xEB, 0x6C, 0x52, 0x82, 0x1D, 0x0B, 0xBB, 0xF7, + 0xCE, 0x75, 0x94, 0x46, 0x2A, 0xCA, 0x4F, 0xAA, + 0xB4, 0x07, 0xDF, 0x86, 0x65, 0x69, 0xFD, 0x07, + 0xF4, 0x8C, 0xC0, 0xB5, 0x83, 0xD6, 0x07, 0x1F, + 0x1E, 0xC0, 0xE6, 0xB8 }, + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CTR, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, + .cipher_iv_length = AES_CTR_IV_LEN, + .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5, + 0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28, + 0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a, + 0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5, + 0x2b, 0x09, 0x30, 0xda, 0xa2, 0x3d, 0xe9, 0x4c, + 0xe8, 0x70, 0x17, 0xba, 0x2d, 0x84, 0x98, 0x8d, + 0xdf, 0xc9, 0xc5, 0x8d, 0xb6, 0x7a, 0xad, 0xa6, + 0x13, 0xc2, 0xdd, 0x08, 0x45, 0x79, 0x41, 0xa6 } + }, +}; + +static crypto_test_reference_t aes_ecb_reference[] = { + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_ECB, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}, + .ciphertext = { 0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, + 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97, + 0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d, + 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf, + 0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23, + 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88, + 0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f, + 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4 } + }, + /* Generated by Crypto++ 5.6.1 (528 bytes) */ + { + .cipher = ODP_CIPHER_ALG_AES_ECB, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, + .length = 528, + .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, + 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, + 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, + 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, + 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, + 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, + 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, + 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, + 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, + 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, + 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, + 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, + 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, + 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, + 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, + 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, + 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, + 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, + 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, + 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, + 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, + 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, + 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, + 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, + 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, + 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, + 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, + 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, + 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, + 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, + 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, + 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, + 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, + 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, + 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, + 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, + 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, + 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, + 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, + 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, + 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, + 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, + 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, + 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, + 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, + 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, + 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, + 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, + 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, + 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, + 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, + 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, + 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, + 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, + 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, + 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, + 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, + 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, + 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, + 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, + 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, + 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, + 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, + 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, + 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, + 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00}, + .ciphertext = { 0x84, 0xC6, 0xCB, 0xDC, 0x2B, 0x5A, 0x39, 0x98, + 0x57, 0x74, 0xB2, 0x3B, 0xAB, 0x06, 0x6A, 0x6A, + 0xF8, 0xCB, 0x66, 0xC0, 0x8E, 0x4F, 0x05, 0x8E, + 0x5D, 0x3E, 0x7C, 0x35, 0x1E, 0xA8, 0x45, 0xCE, + 0xC7, 0xB2, 0x09, 0x21, 0x0E, 0xE7, 0xEF, 0xD3, + 0x82, 0x69, 0x62, 0x86, 0x87, 0xF2, 0x1C, 0xB9, + 0xBC, 0xEA, 0x34, 0x9D, 0xC0, 0x41, 0x8A, 0xDB, + 0xA2, 0xBF, 0x23, 0x64, 0xDF, 0x4D, 0xB1, 0xA1, + 0x1A, 0xD8, 0x4C, 0xF6, 0xA4, 0x22, 0xCE, 0x95, + 0xC3, 0x7B, 0x2C, 0xF8, 0x11, 0x96, 0x24, 0x5C, + 0xD8, 0x57, 0xD0, 0xB9, 0x54, 0xB8, 0x39, 0x85, + 0xC1, 0x88, 0x82, 0x30, 0xF3, 0xC3, 0x01, 0x84, + 0x7A, 0xAF, 0x71, 0x42, 0x53, 0xEF, 0x76, 0x8C, + 0x17, 0xE8, 0x9E, 0x4F, 0x55, 0x13, 0xDB, 0xD5, + 0xBE, 0xE1, 0x26, 0x6A, 0x2B, 0x2D, 0x70, 0x63, + 0xCE, 0x3D, 0x0B, 0xA8, 0x71, 0x62, 0x52, 0xC5, + 0xBC, 0xBB, 0x99, 0x22, 0xCD, 0x46, 0xF3, 0x74, + 0xB5, 0x2F, 0xDF, 0xF1, 0xFE, 0xBF, 0x15, 0x5F, + 0xF4, 0xAF, 0xEE, 0x18, 0x78, 0x89, 0x99, 0xBC, + 0x74, 0x23, 0x4A, 0x3F, 0xFB, 0xA7, 0xB2, 0x85, + 0x8B, 0xB2, 0x55, 0x2F, 0x17, 0x2E, 0x56, 0xEC, + 0x47, 0x45, 0x68, 0x78, 0x44, 0x0A, 0xBB, 0x5A, + 0xDA, 0xE4, 0x99, 0x41, 0xC1, 0xE4, 0x36, 0x16, + 0xAC, 0x5D, 0x6E, 0x31, 0xA0, 0x11, 0x61, 0x1B, + 0x82, 0x9F, 0x6A, 0x77, 0xBE, 0x1F, 0x50, 0x75, + 0x4F, 0x81, 0xF3, 0x5D, 0x24, 0xED, 0x89, 0xFD, + 0xE8, 0x04, 0xB1, 0x73, 0x63, 0xF9, 0xA8, 0x1C, + 0x3F, 0x12, 0xAE, 0x06, 0x7F, 0xDD, 0x41, 0xA2, + 0x98, 0x49, 0x12, 0xCA, 0xE1, 0x92, 0x6C, 0x5F, + 0xB3, 0xAC, 0x18, 0xE5, 0x41, 0xFA, 0x4A, 0xD1, + 0xE1, 0x71, 0x88, 0x8E, 0x61, 0x42, 0x8F, 0x2A, + 0x8F, 0x2E, 0x98, 0x1A, 0xE1, 0x6D, 0x0D, 0x4E, + 0x41, 0xD3, 0x3E, 0x5E, 0x67, 0x5F, 0x44, 0x6D, + 0xAE, 0x0F, 0x45, 0x4F, 0xC4, 0xCA, 0x05, 0x6F, + 0x41, 0xF3, 0xCC, 0x47, 0x44, 0xA9, 0xE9, 0x48, + 0x42, 0x8B, 0x22, 0x80, 0xF9, 0x66, 0x63, 0xB7, + 0x23, 0x0C, 0x09, 0x69, 0x25, 0x03, 0xC9, 0x5B, + 0x3E, 0x34, 0xF8, 0xDE, 0x8D, 0xF2, 0x31, 0x57, + 0xF4, 0x5B, 0xDF, 0x68, 0x9B, 0x25, 0x8D, 0x99, + 0x4D, 0x9E, 0x6C, 0xE5, 0xD4, 0xDD, 0x6B, 0xDB, + 0x96, 0x76, 0x3C, 0xCC, 0x41, 0xDB, 0xBE, 0x57, + 0xA4, 0x77, 0x8D, 0x5A, 0x9E, 0x90, 0x22, 0x6D, + 0x61, 0x4C, 0x33, 0x5E, 0x44, 0xCA, 0x8A, 0xB4, + 0x1E, 0xFE, 0xA8, 0x98, 0xBC, 0x17, 0x0C, 0x65, + 0x41, 0x2F, 0x77, 0x19, 0x4A, 0x43, 0xA1, 0x30, + 0x5E, 0xF2, 0x3A, 0xC7, 0x0B, 0x05, 0x9E, 0x6E, + 0x04, 0x77, 0x96, 0xEF, 0x51, 0x8D, 0x76, 0x96, + 0xBC, 0x3D, 0xAD, 0x5E, 0x26, 0x34, 0xF9, 0x2D, + 0xD1, 0xC9, 0x0D, 0x20, 0x6A, 0x2B, 0x6D, 0x3A, + 0x7C, 0xE8, 0x86, 0x68, 0xBE, 0xAD, 0x64, 0x61, + 0x4E, 0x90, 0x00, 0xAC, 0xFB, 0xA7, 0x9E, 0xB3, + 0x60, 0x16, 0x06, 0x21, 0x4E, 0x21, 0xE0, 0x8F, + 0x14, 0xCE, 0x77, 0xE3, 0x6B, 0xB6, 0x6F, 0xE4, + 0xA0, 0xFC, 0xD2, 0xA2, 0x1B, 0xCA, 0xA2, 0x39, + 0x1A, 0x9C, 0x20, 0x16, 0xAC, 0x3B, 0xC7, 0xCD, + 0xF1, 0x43, 0x8E, 0xB6, 0xDD, 0x26, 0x69, 0x66, + 0x44, 0x58, 0x3E, 0x2B, 0x0A, 0x0C, 0x68, 0x62, + 0x9D, 0x73, 0x6F, 0x67, 0x23, 0xDF, 0x66, 0x85, + 0x9C, 0xF8, 0x0B, 0x4E, 0x5B, 0x5C, 0x5B, 0xF0, + 0x3F, 0x33, 0x4D, 0x65, 0xC4, 0x8D, 0xB3, 0xB2, + 0x66, 0x0E, 0x2C, 0xE3, 0x3B, 0x51, 0x0F, 0xD6, + 0x0C, 0x91, 0x2B, 0x85, 0xD1, 0x6A, 0xEE, 0x7C, + 0xDB, 0xFD, 0xF6, 0x28, 0x5B, 0x0A, 0x77, 0xBA, + 0xE0, 0x7D, 0x98, 0x7F, 0x9C, 0xE1, 0x72, 0xA5, + 0x48, 0xE6, 0xBF, 0x0A, 0x30, 0xCF, 0x09, 0x9A, + 0xA8, 0x2B, 0xE0, 0xA2, 0x5E, 0x0E, 0x89, 0x19 } + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_ECB, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f, + 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc, + 0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad, + 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef, + 0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a, + 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e, + 0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72, + 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e } + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_ECB, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c, + 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8, + 0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26, + 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70, + 0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9, + 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d, + 0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff, + 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7} + } +}; + +static crypto_test_reference_t aes_cfb128_reference[] = { + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CFB128, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, + .cipher_iv_length = AES_CFB128_IV_LEN, + .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}, + .ciphertext = { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, + 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, + 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f, + 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b, + 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40, + 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf, + 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e, + 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6 } + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CFB128, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, + .cipher_iv_length = AES_CFB128_IV_LEN, + .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, + 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, + 0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21, + 0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a, + 0x2e, 0x1e, 0x8a, 0x1d, 0xd5, 0x9b, 0x88, 0xb1, + 0xc8, 0xe6, 0x0f, 0xed, 0x1e, 0xfa, 0xc4, 0xc9, + 0xc0, 0x5f, 0x9f, 0x9c, 0xa9, 0x83, 0x4f, 0xa0, + 0x42, 0xae, 0x8f, 0xba, 0x58, 0x4b, 0x09, 0xff } + }, + /* NIST Special Publication 800-38A */ + { + .cipher = ODP_CIPHER_ALG_AES_CFB128, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, + .cipher_iv_length = AES_CFB128_IV_LEN, + .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 64, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, + .ciphertext = { 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, + 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, + 0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8, + 0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b, + 0xdf, 0x10, 0x13, 0x24, 0x15, 0xe5, 0x4b, 0x92, + 0xa1, 0x3e, 0xd0, 0xa8, 0x26, 0x7a, 0xe2, 0xf9, + 0x75, 0xa3, 0x85, 0x74, 0x1a, 0xb9, 0xce, 0xf8, + 0x20, 0x31, 0x62, 0x3d, 0x55, 0xb1, 0xe4, 0x71 } + } +}; + +static crypto_test_reference_t aes_xts_reference[] = { + /* CAVS 11.0 XTSGen information, #1 */ + { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES128_XTS_KEY_LEN, + .cipher_key = { 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35, + 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62, + 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18, + 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6, + 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5}, + .length = 16, + .plaintext = { 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d, + 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c}, + .ciphertext = { 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a, + 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63} + }, + /* CAVS 11.0 XTSGen information, #101 */ + { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES128_XTS_KEY_LEN, + .cipher_key = { 0xb7, 0xb9, 0x3f, 0x51, 0x6a, 0xef, 0x29, 0x5e, + 0xff, 0x3a, 0x29, 0xd8, 0x37, 0xcf, 0x1f, 0x13, + 0x53, 0x47, 0xe8, 0xa2, 0x1d, 0xae, 0x61, 0x6f, + 0xf5, 0x06, 0x2b, 0x2e, 0x8d, 0x78, 0xce, 0x5e}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0x87, 0x3e, 0xde, 0xa6, 0x53, 0xb6, 0x43, 0xbd, + 0x8b, 0xcf, 0x51, 0x40, 0x31, 0x97, 0xed, 0x14}, + .length = 32, + .plaintext = { 0x23, 0x6f, 0x8a, 0x5b, 0x58, 0xdd, 0x55, 0xf6, + 0x19, 0x4e, 0xd7, 0x0c, 0x4a, 0xc1, 0xa1, 0x7f, + 0x1f, 0xe6, 0x0e, 0xc9, 0xa6, 0xc4, 0x54, 0xd0, + 0x87, 0xcc, 0xb7, 0x7d, 0x6b, 0x63, 0x8c, 0x47}, + .ciphertext = { 0x22, 0xe6, 0xa3, 0xc6, 0x37, 0x9d, 0xcf, 0x75, + 0x99, 0xb0, 0x52, 0xb5, 0xa7, 0x49, 0xc7, 0xf7, + 0x8a, 0xd8, 0xa1, 0x1b, 0x9f, 0x1a, 0xa9, 0x43, + 0x0c, 0xf3, 0xae, 0xf4, 0x45, 0x68, 0x2e, 0x19} + }, + /* CAVS 11.0 XTSGen information, #227 TODO (Length 130 bits)*/ + /* { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES128_XTS_KEY_LEN, + .cipher_key = { 0xec, 0x14, 0xc0, 0xa3, 0xb7, 0x72, 0x58, 0x5c, + 0x15, 0xd4, 0xeb, 0x94, 0xe6, 0x9e, 0x2c, 0x55, + 0x80, 0xcf, 0x3a, 0x63, 0xc1, 0x7c, 0xe9, 0xda, + 0xd8, 0x2b, 0xb4, 0x54, 0xe3, 0x87, 0x90, 0x45}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0x4a, 0x02, 0x87, 0xc2, 0x6e, 0xd2, 0x41, 0x26, + 0x5b, 0x3a, 0x42, 0xcd, 0xd1, 0x9c, 0xea, 0xe2}, + .length = 17, + .plaintext = { 0x50, 0x82, 0x64, 0x75, 0x82, 0xc6, 0xe5, 0xa7, + 0x88, 0x73, 0x6f, 0xc5, 0x90, 0x5e, 0xa5, 0x65, + 0xc0 }, + .ciphertext = { 0x04, 0x3a, 0xb9, 0xc0, 0x3d, 0x5b, 0x44, 0x13, + 0x1d, 0x3e, 0x6e, 0xb2, 0x57, 0x61, 0x89, 0xde, + 0x80 }, + }, */ + /* CAVS 11.0 XTSGen information, #1 */ + { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES256_XTS_KEY_LEN, + .cipher_key = { 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e, + 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14, + 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7, + 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c, + 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d, + 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3, + 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58, + 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2, + 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64}, + .length = 32, + .plaintext = { 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1, + 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64, + 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3, + 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e}, + .ciphertext = { 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5, + 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13, + 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a, + 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb}, + }, + /* CAVS 11.0 XTSGen information, #110 */ + { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES256_XTS_KEY_LEN, + .cipher_key = { 0x6b, 0x19, 0x84, 0xc2, 0x4e, 0x7e, 0xb6, 0x62, + 0x8e, 0x3a, 0x11, 0xc9, 0xcc, 0xd2, 0x59, 0x40, + 0x33, 0xa3, 0xa0, 0xd9, 0x01, 0x6e, 0xae, 0x65, + 0xc2, 0xf2, 0x4e, 0x09, 0xb9, 0xa6, 0x6e, 0x9f, + 0xe9, 0xd1, 0x63, 0xa5, 0x06, 0xdf, 0xbc, 0xcf, + 0x2d, 0x93, 0xe8, 0x99, 0x1e, 0x2f, 0xc5, 0x60, + 0xe1, 0x04, 0x35, 0xb8, 0x90, 0xb5, 0x88, 0x9a, + 0x50, 0x03, 0xe4, 0xbf, 0x81, 0x7d, 0xc3, 0xe0}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0x6b, 0xb0, 0xd3, 0xae, 0x4f, 0xa8, 0x6e, 0x43, + 0x16, 0x19, 0xe4, 0x07, 0xd5, 0x9a, 0xd4, 0xf4}, + .length = 48, + .plaintext = { 0x6a, 0x74, 0x1a, 0x94, 0x5b, 0xfb, 0xf0, 0xc6, + 0x7a, 0xfd, 0x43, 0xba, 0x1f, 0x84, 0x18, 0x16, + 0xc0, 0x99, 0x51, 0x58, 0x05, 0xd0, 0xfc, 0x1f, + 0x7d, 0xbf, 0x6d, 0xe9, 0x00, 0xe0, 0xaa, 0x7a, + 0x21, 0x9c, 0x88, 0x56, 0x32, 0x71, 0xb0, 0x09, + 0xd1, 0xac, 0x90, 0xeb, 0x7d, 0xc9, 0x97, 0x35}, + .ciphertext = { 0xe4, 0x7b, 0xce, 0x29, 0x2b, 0xaa, 0x63, 0xbe, + 0xf3, 0x16, 0xf6, 0x80, 0xa5, 0xf4, 0x80, 0xa7, + 0xb8, 0x83, 0xdf, 0xab, 0x6e, 0xd5, 0xa5, 0x7f, + 0x7e, 0x29, 0xec, 0xb8, 0x9e, 0x35, 0x4a, 0x31, + 0xc9, 0xb1, 0x74, 0xc4, 0xab, 0xad, 0x6c, 0xba, + 0xba, 0xba, 0x19, 0x14, 0x0c, 0x46, 0x20, 0xa3}, + }, + /* CAVS 11.0 XTSGen information, #211 TODO: length 140 bits */ + /* { + .cipher = ODP_CIPHER_ALG_AES_XTS, + .cipher_key_length = AES256_XTS_KEY_LEN, + .cipher_key = { 0x62, 0xc2, 0xe4, 0xf8, 0x52, 0xa9, 0x3e, 0xea, + 0x4a, 0x2f, 0x61, 0xe8, 0x67, 0x68, 0x14, 0xf4, + 0xa8, 0x0d, 0xc4, 0x7e, 0xe1, 0x81, 0x32, 0xc8, + 0x38, 0xbf, 0x89, 0xa6, 0x18, 0xfd, 0xb8, 0xe2, + 0x91, 0x3e, 0x2e, 0x5c, 0x32, 0x1b, 0x19, 0xea, + 0x04, 0xbb, 0xa6, 0x34, 0x7d, 0x22, 0x6f, 0x41, + 0xdb, 0xee, 0x88, 0x0d, 0x61, 0x67, 0xb8, 0xe1, + 0xe9, 0x17, 0xfa, 0xf0, 0x46, 0xf0, 0x87, 0x5e}, + .cipher_iv_length = AES_XTS_IV_LEN, + .cipher_iv = { 0x53, 0x7e, 0xe3, 0xdc, 0x13, 0xce, 0x27, 0xa8, + 0xd3, 0x0e, 0x6e, 0x42, 0xb5, 0xb9, 0x96, 0xae}, + .length = 18, + .plaintext = { 0x00, 0xc9, 0xeb, 0x87, 0x78, 0xe0, 0x3d, 0xdd, + 0x5f, 0x3d, 0xe8, 0xc1, 0x8b, 0x34, 0x8f, 0xac, + 0x9c, 0x30}, + .ciphertext = { 0x9d, 0x4a, 0x08, 0xac, 0x0f, 0xb4, 0x4e, 0x90, + 0xd0, 0x5f, 0x62, 0x86, 0x19, 0x3f, 0x3a, 0xab, + 0xc2, 0x90}, + } */ +}; + +/* AES-GCM test vectors extracted from + * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2 + */ +static crypto_test_reference_t aes_gcm_reference[] = { + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, + 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e, + 0x3b, 0x24, 0x4c, 0xfe }, + .length = 72, + .plaintext = { 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00, + 0x80, 0x11, 0x4d, 0xb7, 0xc0, 0xa8, 0x01, 0x02, + 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x9b, 0xf1, 0x56, + 0x38, 0xd3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, 0x73, 0x69, + 0x70, 0x04, 0x5f, 0x75, 0x64, 0x70, 0x03, 0x73, + 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, 0x65, 0x72, + 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00, + 0x00, 0x21, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0xfe, 0xcf, 0x53, 0x7e, 0x72, 0x9d, 0x5b, 0x07, + 0xdc, 0x30, 0xdf, 0x52, 0x8d, 0xd2, 0x2b, 0x76, + 0x8d, 0x1b, 0x98, 0x73, 0x66, 0x96, 0xa6, 0xfd, + 0x34, 0x85, 0x09, 0xfa, 0x13, 0xce, 0xac, 0x34, + 0xcf, 0xa2, 0x43, 0x6f, 0x14, 0xa3, 0xf3, 0xcf, + 0x65, 0x92, 0x5b, 0xf1, 0xf4, 0xa1, 0x3c, 0x5d, + 0x15, 0xb2, 0x1e, 0x18, 0x84, 0xf5, 0xff, 0x62, + 0x47, 0xae, 0xab, 0xb7, 0x86, 0xb9, 0x3b, 0xce, + 0x61, 0xbc, 0x17, 0xd7, 0x68, 0xfd, 0x97, 0x32}, + .aad_length = 12, + .aad = { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, + 0x00, 0x00, 0x00, 0x00 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, + 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88 }, + .length = 64, + .plaintext = { 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00, + 0x80, 0x11, 0x4d, 0xcc, 0xc0, 0xa8, 0x01, 0x02, + 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x98, 0x00, 0x35, + 0x00, 0x2a, 0x23, 0x43, 0xb2, 0xd0, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x73, 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, + 0x65, 0x72, 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, + 0x6b, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }, + .ciphertext = { 0xde, 0xb2, 0x2c, 0xd9, 0xb0, 0x7c, 0x72, 0xc1, + 0x6e, 0x3a, 0x65, 0xbe, 0xeb, 0x8d, 0xf3, 0x04, + 0xa5, 0xa5, 0x89, 0x7d, 0x33, 0xae, 0x53, 0x0f, + 0x1b, 0xa7, 0x6d, 0x5d, 0x11, 0x4d, 0x2a, 0x5c, + 0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f, + 0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42, + 0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4, + 0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1}, + .aad_length = 8, + .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, + 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a } + }, + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + .length = 64, + .plaintext = { 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00, + 0x80, 0x01, 0xcb, 0x7a, 0x40, 0x67, 0x93, 0x18, + 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x07, 0x5c, + 0x02, 0x00, 0x44, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, + 0x66, 0x67, 0x68, 0x69, 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0x46, 0x88, 0xda, 0xf2, 0xf9, 0x73, 0xa3, 0x92, + 0x73, 0x29, 0x09, 0xc3, 0x31, 0xd5, 0x6d, 0x60, + 0xf6, 0x94, 0xab, 0xaa, 0x41, 0x4b, 0x5e, 0x7f, + 0xf5, 0xfd, 0xcd, 0xff, 0xf5, 0xe9, 0xa2, 0x84, + 0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6, + 0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94, + 0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18, + 0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3}, + .aad_length = 8, + .aad = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, + 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d } + }, + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, + 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, + 0xa2, 0xfc, 0xa1, 0xa3 }, + .length = 28, + .plaintext = { 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, + 0x80, 0x01, 0x44, 0x1f, 0x40, 0x67, 0x93, 0xb6, + 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff, + 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0xfb, 0xa2, 0xca, 0x84, 0x5e, 0x5d, 0xf9, 0xf0, + 0xf2, 0x2c, 0x3e, 0x6e, 0x86, 0xdd, 0x83, 0x1e, + 0x1f, 0xc6, 0x57, 0x92, 0xcd, 0x1a, 0xf9, 0x13, + 0x0e, 0x13, 0x79, 0xed }, + .aad_length = 12, + .aad = { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe, + 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, + 0xde, 0xca, 0xf8, 0x88 }, + .length = 40, + .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00, + 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f, + 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8, + 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e, + 0x50, 0x10, 0x16, 0xd0, 0x75, 0x68, 0x00, 0x01 }, + .ciphertext = { 0xa5, 0xb1, 0xf8, 0x06, 0x60, 0x29, 0xae, 0xa4, + 0x0e, 0x59, 0x8b, 0x81, 0x22, 0xde, 0x02, 0x42, + 0x09, 0x38, 0xb3, 0xab, 0x33, 0xf8, 0x28, 0xe6, + 0x87, 0xb8, 0x85, 0x8b, 0x5b, 0xfb, 0xdb, 0xd0, + 0x31, 0x5b, 0x27, 0x45, 0x21, 0x44, 0xcc, 0x77}, + .aad_length = 8, + .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0x95, 0x45, 0x7b, 0x96, 0x52, 0x03, 0x7f, 0x53, + 0x18, 0x02, 0x7b, 0x5b, 0x4c, 0xd7, 0xa6, 0x36 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_GCM, + .auth = ODP_AUTH_ALG_AES_GCM, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, + 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, + 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, + 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab}, + .cipher_iv_length = AES_GCM_IV_LEN, + .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08 }, + .length = 52, + .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00, + 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02, + 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b, + 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00, + 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02, + 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0xff, 0x42, 0x5c, 0x9b, 0x72, 0x45, 0x99, 0xdf, + 0x7a, 0x3b, 0xcd, 0x51, 0x01, 0x94, 0xe0, 0x0d, + 0x6a, 0x78, 0x10, 0x7f, 0x1b, 0x0b, 0x1c, 0xbf, + 0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63, + 0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34, + 0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d, + 0xef, 0x84, 0x2d, 0x8e }, + .aad_length = 8, + .aad = { 0x4a, 0x2c, 0xbf, 0xe3, 0x00, 0x00, 0x00, 0x02 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xb3, 0x35, 0xf4, 0xee, 0xcf, 0xdb, 0xf8, 0x31, + 0x82, 0x4b, 0x4c, 0x49, 0x15, 0x95, 0x6c, 0x96 } + } +}; + +static crypto_test_reference_t aes_ccm_reference[] = { + /* + * AES-CCM reference from RFC 3610 + */ + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf}, + .cipher_iv_length = 13, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2, + 0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80, + 0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84 }, + .digest_length = 8, + .digest = { 0x17, 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0 } + }, + /* The rest of test vectors are generated manually, no "interesting" + * vectors for use cases in RFC 3610 or SP 800-38C. */ + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7}, + .cipher_iv_length = 13, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0x57, 0x9f, 0xb8, 0x6e, 0xdd, 0xb4, 0xa6, 0x4a, + 0xae, 0x5f, 0xe9, 0x6d, 0xbd, 0x75, 0x44, 0x05, + 0x33, 0xa9, 0xfc, 0x3a, 0x84, 0x57, 0x36 }, + .digest_length = 8, + .digest = { 0x67, 0xae, 0xc8, 0x0a, 0xc5, 0x88, 0xab, 0x16 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf}, + .cipher_iv_length = 13, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0x59, 0x61, 0x55, 0x10, 0xa7, 0xc4, 0x3b, 0xfb, + 0x12, 0x3d, 0x63, 0x6b, 0x46, 0x13, 0xc0, 0x3c, + 0x6c, 0xe2, 0x69, 0x07, 0x10, 0x2a, 0x3f }, + .digest_length = 8, + .digest = { 0xb5, 0x57, 0x2a, 0x17, 0x2d, 0x49, 0x16, 0xd5 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES128_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf}, + .cipher_iv_length = 11, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0xaa, 0x2d, 0x3e, 0xcb, 0xa6, 0x68, 0x63, 0x75, + 0x8f, 0x03, 0x01, 0x51, 0x16, 0xde, 0x30, 0xed, + 0x8a, 0xb5, 0x42, 0xdc, 0xfa, 0x72, 0xd0 }, + .digest_length = 8, + .digest = { 0x63, 0xe7, 0x01, 0x5c, 0x69, 0xaf, 0xb4, 0x0c } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES192_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7}, + .cipher_iv_length = 11, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0xee, 0x99, 0x99, 0x1e, 0xc5, 0x8f, 0xd7, 0x7e, + 0x56, 0x71, 0x16, 0x39, 0x8e, 0xc4, 0x4f, 0xcc, + 0x14, 0x45, 0x57, 0x3e, 0x38, 0x76, 0x51 }, + .digest_length = 8, + .digest = { 0x31, 0x29, 0x47, 0xa4, 0x6d, 0x76, 0x34, 0xb4 } + }, + { + .cipher = ODP_CIPHER_ALG_AES_CCM, + .auth = ODP_AUTH_ALG_AES_CCM, + .cipher_key_length = AES256_KEY_LEN, + .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf}, + .cipher_iv_length = 11, + .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, + 0xa1, 0xa2, 0xa3 }, + .aad_length = 8, + .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, + .length = 23, + .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, + .ciphertext = { 0xfa, 0x07, 0x47, 0x5c, 0xe8, 0xc9, 0x37, 0x88, + 0x54, 0x64, 0xb8, 0xc3, 0x85, 0xbb, 0x76, 0x0b, + 0xf2, 0xc2, 0x4c, 0x4e, 0x31, 0x16, 0x77 }, + .digest_length = 8, + .digest = { 0x88, 0x56, 0x7e, 0x19, 0x84, 0x13, 0x29, 0xc4 } + }, +}; + +static crypto_test_reference_t aes_gmac_reference[] = { + { + .auth = ODP_AUTH_ALG_AES_GMAC, + .auth_key_length = AES128_KEY_LEN, + .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, + 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, + .auth_iv_length = AES_GCM_IV_LEN, + .auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, + .length = 68, + .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, 0x6a, + 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa } + }, + /* AES192-GMAC from DPDK 17.02 */ + { + .auth = ODP_AUTH_ALG_AES_GMAC, + .auth_key_length = AES192_KEY_LEN, + .auth_key = { 0xaa, 0x74, 0x0a, 0xbf, 0xad, 0xcd, 0xa7, 0x79, + 0x22, 0x0d, 0x3b, 0x40, 0x6c, 0x5d, 0x7e, 0xc0, + 0x9a, 0x77, 0xfe, 0x9d, 0x94, 0x10, 0x45, 0x39}, + .auth_iv_length = AES_GCM_IV_LEN, + .auth_iv = { 0xab, 0x22, 0x65, 0xb4, 0xc1, 0x68, 0x95, 0x55, + 0x61, 0xf0, 0x43, 0x15 }, + .length = 80, + .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}, + .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xCF, 0x82, 0x80, 0x64, 0x02, 0x46, 0xF4, 0xFB, + 0x33, 0xAE, 0x1D, 0x90, 0xEA, 0x48, 0x83, 0xDB }, + }, + /* AES256-GMAC from DPDK 17.02 */ + { + .auth = ODP_AUTH_ALG_AES_GMAC, + .auth_key_length = AES256_KEY_LEN, + .auth_key = { 0xb5, 0x48, 0xe4, 0x93, 0x4f, 0x5c, 0x64, 0xd3, + 0xc0, 0xf0, 0xb7, 0x8f, 0x7b, 0x4d, 0x88, 0x24, + 0xaa, 0xc4, 0x6b, 0x3c, 0x8d, 0x2c, 0xc3, 0x5e, + 0xe4, 0xbf, 0xb2, 0x54, 0xe4, 0xfc, 0xba, 0xf7}, + .auth_iv_length = AES_GCM_IV_LEN, + .auth_iv = { 0x2e, 0xed, 0xe1, 0xdc, 0x64, 0x47, 0xc7, 0xaf, + 0xc4, 0x41, 0x53, 0x58 }, + .length = 65, + .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02 }, + .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + 0x01, 0x02 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0x77, 0x46, 0x0D, 0x6F, 0xB1, 0x87, 0xDB, 0xA9, + 0x46, 0xAD, 0xCD, 0xFB, 0xB7, 0xF9, 0x13, 0xA1 }, + } +}; + +/* + * Test vectors from SP800-38B / CSRC examples + * 12-byte vectors are just truncated 16-byte vectors + */ +static crypto_test_reference_t aes_cmac_reference[] = { + { + .auth = ODP_AUTH_ALG_AES_CMAC, + .auth_key_length = AES128_KEY_LEN, + .auth_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }, + .length = 16, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, + .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a + }, + .digest_length = 16, + .digest = { 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44, + 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c }, + }, + { + .copy_previous_vector = 1, + .digest_length = 12, + }, + { + .auth = ODP_AUTH_ALG_AES_CMAC, + .auth_key_length = AES192_KEY_LEN, + .auth_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b }, + .length = 16, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, + .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a + }, + .digest_length = 16, + .digest = { 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, + 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84 }, + }, + { + .copy_previous_vector = 1, + .digest_length = 12, + }, + { + .auth = ODP_AUTH_ALG_AES_CMAC, + .auth_key_length = AES256_KEY_LEN, + .auth_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 }, + .length = 16, + .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, + .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a + }, + .digest_length = 16, + .digest = { 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, + 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c }, + }, + { + .copy_previous_vector = 1, + .digest_length = 12, + }, +}; + +/* + * Test vector from RFC 7539, sections 2.8.2, A.5 + */ +static crypto_test_reference_t chacha20_poly1305_reference[] = { + { + .cipher = ODP_CIPHER_ALG_CHACHA20_POLY1305, + .auth = ODP_AUTH_ALG_CHACHA20_POLY1305, + .cipher_key_length = CHACHA20_POLY1305_KEY_LEN, + .cipher_key = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f}, + .cipher_iv_length = CHACHA20_POLY1305_IV_LEN, + .cipher_iv = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, + 0x44, 0x45, 0x46, 0x47 }, + .length = 114, + .plaintext = { 0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61, + 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73, + 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39, + 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63, + 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66, + 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f, + 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20, + 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75, + 0x72, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x6e, 0x73, + 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, + 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, + 0x74, 0x2e }, + .ciphertext = { 0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb, + 0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2, + 0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe, + 0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6, + 0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12, + 0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b, + 0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29, + 0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36, + 0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c, + 0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58, + 0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94, + 0x55, 0x85, 0x80, 0x8b, 0x48, 0x31, 0xd7, 0xbc, + 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d, + 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b, + 0x61, 0x16 }, + .aad_length = 12, + .aad = { 0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, + 0xc5, 0xc6, 0xc7 }, + .digest_length = 16, + .digest = { 0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a, + 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91 } + }, + { + .cipher = ODP_CIPHER_ALG_CHACHA20_POLY1305, + .auth = ODP_AUTH_ALG_CHACHA20_POLY1305, + .cipher_key_length = CHACHA20_POLY1305_KEY_LEN, + .cipher_key = { 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, + 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, + 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, + 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0}, + .cipher_iv_length = CHACHA20_POLY1305_IV_LEN, + .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08 }, + .length = 265, + .plaintext = { 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x73, 0x20, + 0x61, 0x72, 0x65, 0x20, 0x64, 0x72, 0x61, 0x66, + 0x74, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20, + 0x6f, 0x66, 0x20, 0x73, 0x69, 0x78, 0x20, 0x6d, + 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e, + 0x64, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65, + 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, + 0x2c, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x64, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x6f, + 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x64, + 0x20, 0x62, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65, + 0x72, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x20, 0x61, 0x74, 0x20, 0x61, + 0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x2e, + 0x20, 0x49, 0x74, 0x20, 0x69, 0x73, 0x20, 0x69, + 0x6e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72, + 0x69, 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, + 0x75, 0x73, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61, + 0x66, 0x74, 0x73, 0x20, 0x61, 0x73, 0x20, 0x72, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20, + 0x63, 0x69, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, + 0x6d, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, + 0x74, 0x68, 0x61, 0x6e, 0x20, 0x61, 0x73, 0x20, + 0x2f, 0xe2, 0x80, 0x9c, 0x77, 0x6f, 0x72, 0x6b, + 0x20, 0x69, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, + 0x72, 0x65, 0x73, 0x73, 0x2e, 0x2f, 0xe2, 0x80, + 0x9d }, + .ciphertext = { 0x64, 0xa0, 0x86, 0x15, 0x75, 0x86, 0x1a, 0xf4, + 0x60, 0xf0, 0x62, 0xc7, 0x9b, 0xe6, 0x43, 0xbd, + 0x5e, 0x80, 0x5c, 0xfd, 0x34, 0x5c, 0xf3, 0x89, + 0xf1, 0x08, 0x67, 0x0a, 0xc7, 0x6c, 0x8c, 0xb2, + 0x4c, 0x6c, 0xfc, 0x18, 0x75, 0x5d, 0x43, 0xee, + 0xa0, 0x9e, 0xe9, 0x4e, 0x38, 0x2d, 0x26, 0xb0, + 0xbd, 0xb7, 0xb7, 0x3c, 0x32, 0x1b, 0x01, 0x00, + 0xd4, 0xf0, 0x3b, 0x7f, 0x35, 0x58, 0x94, 0xcf, + 0x33, 0x2f, 0x83, 0x0e, 0x71, 0x0b, 0x97, 0xce, + 0x98, 0xc8, 0xa8, 0x4a, 0xbd, 0x0b, 0x94, 0x81, + 0x14, 0xad, 0x17, 0x6e, 0x00, 0x8d, 0x33, 0xbd, + 0x60, 0xf9, 0x82, 0xb1, 0xff, 0x37, 0xc8, 0x55, + 0x97, 0x97, 0xa0, 0x6e, 0xf4, 0xf0, 0xef, 0x61, + 0xc1, 0x86, 0x32, 0x4e, 0x2b, 0x35, 0x06, 0x38, + 0x36, 0x06, 0x90, 0x7b, 0x6a, 0x7c, 0x02, 0xb0, + 0xf9, 0xf6, 0x15, 0x7b, 0x53, 0xc8, 0x67, 0xe4, + 0xb9, 0x16, 0x6c, 0x76, 0x7b, 0x80, 0x4d, 0x46, + 0xa5, 0x9b, 0x52, 0x16, 0xcd, 0xe7, 0xa4, 0xe9, + 0x90, 0x40, 0xc5, 0xa4, 0x04, 0x33, 0x22, 0x5e, + 0xe2, 0x82, 0xa1, 0xb0, 0xa0, 0x6c, 0x52, 0x3e, + 0xaf, 0x45, 0x34, 0xd7, 0xf8, 0x3f, 0xa1, 0x15, + 0x5b, 0x00, 0x47, 0x71, 0x8c, 0xbc, 0x54, 0x6a, + 0x0d, 0x07, 0x2b, 0x04, 0xb3, 0x56, 0x4e, 0xea, + 0x1b, 0x42, 0x22, 0x73, 0xf5, 0x48, 0x27, 0x1a, + 0x0b, 0xb2, 0x31, 0x60, 0x53, 0xfa, 0x76, 0x99, + 0x19, 0x55, 0xeb, 0xd6, 0x31, 0x59, 0x43, 0x4e, + 0xce, 0xbb, 0x4e, 0x46, 0x6d, 0xae, 0x5a, 0x10, + 0x73, 0xa6, 0x72, 0x76, 0x27, 0x09, 0x7a, 0x10, + 0x49, 0xe6, 0x17, 0xd9, 0x1d, 0x36, 0x10, 0x94, + 0xfa, 0x68, 0xf0, 0xff, 0x77, 0x98, 0x71, 0x30, + 0x30, 0x5b, 0xea, 0xba, 0x2e, 0xda, 0x04, 0xdf, + 0x99, 0x7b, 0x71, 0x4d, 0x6c, 0x6f, 0x2c, 0x29, + 0xa6, 0xad, 0x5c, 0xb4, 0x02, 0x2b, 0x02, 0x70, + 0x9b }, + .aad_length = 12, + .aad = { 0xf3, 0x33, 0x88, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x4e, 0x91 }, + .digest_length = CHACHA20_POLY1305_CHECK_LEN, + .digest = { 0xee, 0xad, 0x9d, 0x67, 0x89, 0x0c, 0xbb, 0x22, + 0x39, 0x23, 0x36, 0xfe, 0xa1, 0x85, 0x1f, 0x38 } + }, +}; + +static crypto_test_reference_t hmac_md5_reference[] = { + { + .auth = ODP_AUTH_ALG_MD5_HMAC, + .auth_key_length = HMAC_MD5_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_MD5_CHECK_LEN, + .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, + 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d }, + + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_MD5_96_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_MD5_HMAC, + .auth_key_length = HMAC_MD5_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_MD5_CHECK_LEN, + .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, + 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 }, + + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_MD5_96_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_MD5_HMAC, + .auth_key_length = HMAC_MD5_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_MD5_CHECK_LEN, + .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, + 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_MD5_96_CHECK_LEN, + }, +}; + +static crypto_test_reference_t hmac_sha1_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA1_HMAC, + .auth_key_length = HMAC_SHA1_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_SHA1_CHECK_LEN, + .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, + 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, + 0xf1, 0x46, 0xbe, 0x00 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA1_96_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA1_HMAC, + .auth_key_length = HMAC_SHA1_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_SHA1_CHECK_LEN, + .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, + 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, + 0x25, 0x9a, 0x7c, 0x79 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA1_96_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA1_HMAC, + .auth_key_length = HMAC_SHA1_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_SHA1_CHECK_LEN, + .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, + 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, + 0x63, 0xf1, 0x75, 0xd3 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA1_96_CHECK_LEN, + }, +}; + +static crypto_test_reference_t hmac_sha224_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA224_HMAC, + .auth_key_length = HMAC_SHA224_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_SHA224_CHECK_LEN, + .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, + 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f, + 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f, + 0x53, 0x68, 0x4b, 0x22 } + }, + { + .auth = ODP_AUTH_ALG_SHA224_HMAC, + .auth_key_length = HMAC_SHA224_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_SHA224_CHECK_LEN, + .digest = { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf, + 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f, + 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00, + 0x8f, 0xd0, 0x5e, 0x44 } + }, + { + .auth = ODP_AUTH_ALG_SHA224_HMAC, + .auth_key_length = HMAC_SHA224_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_SHA224_CHECK_LEN, + .digest = { 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6, + 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64, + 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1, + 0xec, 0x83, 0x33, 0xea } + } +}; + +static crypto_test_reference_t hmac_sha256_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA256_HMAC, + .auth_key_length = HMAC_SHA256_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_SHA256_CHECK_LEN, + .digest = { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, + 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, + 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, + 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA256_128_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA256_HMAC, + .auth_key_length = HMAC_SHA256_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_SHA256_CHECK_LEN, + .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, + 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, + 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, + 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA256_128_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA256_HMAC, + .auth_key_length = HMAC_SHA256_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_SHA256_CHECK_LEN, + .digest = { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, + 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, + 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, + 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA256_128_CHECK_LEN, + }, +}; + +static crypto_test_reference_t hmac_sha384_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA384_HMAC, + .auth_key_length = HMAC_SHA384_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_SHA384_CHECK_LEN, + .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, + 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f, + 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, + 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c, + 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, + 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA384_192_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA384_HMAC, + .auth_key_length = HMAC_SHA384_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_SHA384_CHECK_LEN, + .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31, + 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b, + 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47, + 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e, + 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7, + 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA384_192_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA384_HMAC, + .auth_key_length = HMAC_SHA384_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_SHA384_CHECK_LEN, + .digest = {0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a, + 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f, + 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb, + 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b, + 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9, + 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA384_192_CHECK_LEN, + }, +}; + +static crypto_test_reference_t hmac_sha512_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA512_HMAC, + .auth_key_length = HMAC_SHA512_KEY_LEN, + .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, + 0x0b, 0x0b, 0x0b, 0x0b }, + .length = 8, + /* "Hi There" */ + .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, + .digest_length = HMAC_SHA512_CHECK_LEN, + .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d, + 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0, + 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78, + 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde, + 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02, + 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4, + 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70, + 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA512_256_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA512_HMAC, + .auth_key_length = HMAC_SHA512_KEY_LEN, + /* "Jefe" */ + .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, + .length = 28, + /* what do ya want for nothing?*/ + .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, + 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, + 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, + 0x69, 0x6e, 0x67, 0x3f }, + .digest_length = HMAC_SHA512_CHECK_LEN, + .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2, + 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3, + 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6, + 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54, + 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a, + 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd, + 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b, + 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA512_256_CHECK_LEN, + }, + { + .auth = ODP_AUTH_ALG_SHA512_HMAC, + .auth_key_length = HMAC_SHA512_KEY_LEN, + .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa }, + .length = 50, + .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, + 0xdd, 0xdd }, + .digest_length = HMAC_SHA512_CHECK_LEN, + .digest = { 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84, + 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9, + 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36, + 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39, + 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8, + 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07, + 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26, + 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb } + }, + { + .copy_previous_vector = 1, + .digest_length = HMAC_SHA512_256_CHECK_LEN, + }, +}; + +/* + * RFC 3566 + */ +static crypto_test_reference_t aes_xcbc_reference[] = { + /* Test Case #1 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, + .length = 0, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = {0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c, + 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29} + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #2 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 3, + .plaintext = { 0x00, 0x01, 0x02 }, + .ciphertext = { 0x00, 0x01, 0x02 }, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf, + 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f } + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #3 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 16, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7, + 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 } + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #4 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, + .length = 20, + .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13 }, + .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13 }, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15, + 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 } + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #5 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, + .length = 32, + .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, + .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = {0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3, + 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4} + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #6 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, + .length = 34, + .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21}, + .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21}, + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = {0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3, + 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8} + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, + /* Test Case #7 */ + { + .auth = ODP_AUTH_ALG_AES_XCBC_MAC, + .auth_key_length = AES_XCBC_MAC_KEY_LEN, + .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, + .length = 1000, + /* Plaintext is 1000 zero bytes. No explicit init needed. */ + .digest_length = AES_XCBC_MAC_CHECK_LEN, + .digest = {0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, 0x30, 0x25, + 0x37, 0x61, 0x10, 0x3b, 0x5d, 0x84, 0x52, 0x8f} + }, + { + .copy_previous_vector = 1, + .digest_length = AES_XCBC_MAC_96_CHECK_LEN, + }, +}; + +/* + * Kasumi F8 and F9 test vectors are taken from + * 3GPP TS 35.203 V9.0.0 (2009-12) + * 3rd Generation Partnership Project; + * Technical Specification Group Services and System Aspects; + * 3G Security; + * Specification of the 3GPP Confidentiality + * and Integrity Algorithms; + * Document 3: Implementors' Test Data + * (Release 9) + */ +static crypto_test_reference_t kasumi_f8_reference[] = { + { + .cipher = ODP_CIPHER_ALG_KASUMI_F8, + .cipher_key_length = KASUMI_F8_KEY_LEN, + .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20, + 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52}, + .cipher_iv_length = KASUMI_F8_IV_LEN, + .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00}, + .length = 120, /* 15 bytes */ + .is_length_in_bits = true, + .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4, + 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 }, + .ciphertext = { 0x9b, 0xc9, 0x2c, 0xa8, 0x03, 0xc6, 0x7b, 0x28, + 0xa1, 0x1a, 0x4b, 0xee, 0x5a, 0x0c, 0x25 } + } +}; + +static crypto_test_reference_t kasumi_f9_reference[] = { + { + .auth = ODP_AUTH_ALG_KASUMI_F9, + .auth_key_length = KASUMI_F9_KEY_LEN, + .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9, + 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e }, + .auth_iv_length = KASUMI_F9_IV_LEN, + .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd, + 0x01, }, + .length = 384, /* 48 bytes */ + .is_length_in_bits = true, + .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, + 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, + 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, + 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, + 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, + 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, + .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, + 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, + 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, + 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, + 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, + 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, + .digest_length = KASUMI_F9_DIGEST_LEN, + .digest = { 0xdd, 0x7d, 0xfa, 0xdd }, + } +}; + +/* + * Snow3G UEA2 & UIA2 test vectors are taken from + * Specification of the 3GPP Confidentiality and + * Integrity Algorithms UEA2 & UIA2 + * Document 3: Implementors’ Test Data + * Version: 1.1 + * Date: 25 th October 2012 + */ +static crypto_test_reference_t snow3g_uea2_reference[] = { + { + .cipher = ODP_CIPHER_ALG_SNOW3G_UEA2, + .cipher_key_length = SNOW3G_UEA2_KEY_LEN, + .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20, + 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52}, + .cipher_iv_length = SNOW3G_UEA2_IV_LEN, + .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00, + 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00}, + .length = 120, /* 15 bytes */ + .is_length_in_bits = true, + .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4, + 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 }, + .ciphertext = { 0xba, 0x0f, 0x31, 0x30, 0x03, 0x34, 0xc5, 0x6b, + 0x52, 0xa7, 0x49, 0x7c, 0xba, 0xc0, 0x46 } + } +}; + +static crypto_test_reference_t snow3g_uia2_reference[] = { + { + .auth = ODP_AUTH_ALG_SNOW3G_UIA2, + .auth_key_length = SNOW3G_UIA2_KEY_LEN, + .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9, + 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e}, + .auth_iv_length = SNOW3G_UIA2_IV_LEN, + .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd, + 0x94, 0x79, 0x3e, 0x41, 0x03, 0x97, 0x68, 0xfd }, + .length = 384, /* 48 bytes */ + .is_length_in_bits = true, + .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, + 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, + 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, + 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, + 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, + 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, + .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, + 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, + 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, + 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, + 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, + 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, + .digest_length = SNOW3G_UIA2_DIGEST_LEN, + .digest = { 0x38, 0xb5, 0x54, 0xc0 } + } +}; + +/* + * AES EEA2 and AES EIA2 test vectors from + * Specification of the 3GPP Confidentiality and Integrity + * Algorithms 128-EEA2 & 128-EIA2 + */ +static crypto_test_reference_t aes_eea2_reference[] = { + { + .cipher = ODP_CIPHER_ALG_AES_EEA2, + .cipher_key_length = AES_EEA2_KEY_LEN, + .cipher_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, + 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1}, + .cipher_iv_length = AES_EEA2_IV_LEN, + .cipher_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xac, }, + .length = 253, + .is_length_in_bits = true, + .plaintext = { 0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x1A, + 0xB4, 0x85, 0x47, 0x20, 0x29, 0xB7, 0x1D, 0x80, + 0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC, + 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF0 }, + .ciphertext = { 0xE9, 0xFE, 0xD8, 0xA6, 0x3D, 0x15, 0x53, 0x04, + 0xD7, 0x1D, 0xF2, 0x0B, 0xF3, 0xE8, 0x22, 0x14, + 0xB2, 0x0E, 0xD7, 0xDA, 0xD2, 0xF2, 0x33, 0xDC, + 0x3C, 0x22, 0xD7, 0xBD, 0xEE, 0xED, 0x8E, 0x78} + }, + { + .cipher = ODP_CIPHER_ALG_AES_EEA2, + .cipher_key_length = AES_EEA2_KEY_LEN, + .cipher_key = { 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC4, 0x40, 0xE0, + 0x95, 0x2C, 0x49, 0x10, 0x48, 0x05, 0xFF, 0x48}, + .cipher_iv_length = AES_EEA2_IV_LEN, + .cipher_iv = { 0xc6, 0x75, 0xa6, 0x4b, 0x64, }, + .length = 798, + .is_length_in_bits = true, + .plaintext = { 0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61, + 0x47, 0x26, 0x44, 0x6A, 0x6C, 0x38, 0xCE, 0xD1, + 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54, 0x30, 0x04, + 0x42, 0x86, 0x34, 0x6C, 0xEF, 0x13, 0x0F, 0x92, + 0x92, 0x2B, 0x03, 0x45, 0x0D, 0x3A, 0x99, 0x75, + 0xE5, 0xBD, 0x2E, 0xA0, 0xEB, 0x55, 0xAD, 0x8E, + 0x1B, 0x19, 0x9E, 0x3E, 0xC4, 0x31, 0x60, 0x20, + 0xE9, 0xA1, 0xB2, 0x85, 0xE7, 0x62, 0x79, 0x53, + 0x59, 0xB7, 0xBD, 0xFD, 0x39, 0xBE, 0xF4, 0xB2, + 0x48, 0x45, 0x83, 0xD5, 0xAF, 0xE0, 0x82, 0xAE, + 0xE6, 0x38, 0xBF, 0x5F, 0xD5, 0xA6, 0x06, 0x19, + 0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB, + 0x9B, 0x13, 0x48, 0x80 }, + .ciphertext = { 0x59, 0x61, 0x60, 0x53, 0x53, 0xC6, 0x4B, 0xDC, + 0xA1, 0x5B, 0x19, 0x5E, 0x28, 0x85, 0x53, 0xA9, + 0x10, 0x63, 0x25, 0x06, 0xD6, 0x20, 0x0A, 0xA7, + 0x90, 0xC4, 0xC8, 0x06, 0xC9, 0x99, 0x04, 0xCF, + 0x24, 0x45, 0xCC, 0x50, 0xBB, 0x1C, 0xF1, 0x68, + 0xA4, 0x96, 0x73, 0x73, 0x4E, 0x08, 0x1B, 0x57, + 0xE3, 0x24, 0xCE, 0x52, 0x59, 0xC0, 0xE7, 0x8D, + 0x4C, 0xD9, 0x7B, 0x87, 0x09, 0x76, 0x50, 0x3C, + 0x09, 0x43, 0xF2, 0xCB, 0x5A, 0xE8, 0xF0, 0x52, + 0xC7, 0xB7, 0xD3, 0x92, 0x23, 0x95, 0x87, 0xB8, + 0x95, 0x60, 0x86, 0xBC, 0xAB, 0x18, 0x83, 0x60, + 0x42, 0xE2, 0xE6, 0xCE, 0x42, 0x43, 0x2A, 0x17, + 0x10, 0x5C, 0x53, 0xD0 } + }, +}; + +static crypto_test_reference_t aes_eia2_reference[] = { + /* 3GPP TS 33.401, C.2.1 */ + { + .auth = ODP_AUTH_ALG_AES_EIA2, + .auth_key_length = AES_EIA2_KEY_LEN, + .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, + 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 }, + .auth_iv_length = AES_EIA2_IV_LEN, + .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0xc0 }, + .length = 58, + .is_length_in_bits = true, + .plaintext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 }, + .ciphertext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 }, + .digest_length = AES_EIA2_DIGEST_LEN, + .digest = { 0x11, 0x8c, 0x6e, 0xb8 } + }, + /* 3GPP TS 33.401, C.2.2. */ + { + .auth = ODP_AUTH_ALG_AES_EIA2, + .auth_key_length = AES_EIA2_KEY_LEN, + .auth_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, + 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1 }, + .auth_iv_length = AES_EIA2_IV_LEN, + .auth_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xd4, }, + .length = 64, /* 8 bytes */ + .is_length_in_bits = true, + .plaintext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae }, + .ciphertext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae}, + .digest_length = AES_EIA2_DIGEST_LEN, + .digest = { 0xb9, 0x37, 0x87, 0xe6 } + }, + /* 3GPP TS 33.401, C.2.5 */ + { + .auth = ODP_AUTH_ALG_AES_EIA2, + .auth_key_length = AES_EIA2_KEY_LEN, + .auth_key = { 0x83, 0xfd, 0x23, 0xa2, 0x44, 0xa7, 0x4c, 0xf3, + 0x58, 0xda, 0x30, 0x19, 0xf1, 0x72, 0x26, 0x35 }, + .auth_iv_length = AES_EIA2_IV_LEN, + .auth_iv = { 0x36, 0xaf, 0x61, 0x44, 0x7c }, + .length = 768, /* 96 bytes */ + .is_length_in_bits = true, + .plaintext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb, + 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11, + 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39, + 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39, + 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5, + 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef, + 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1, + 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72, + 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf, + 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef, + 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6, + 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a }, + .ciphertext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb, + 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11, + 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39, + 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39, + 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5, + 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef, + 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1, + 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72, + 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf, + 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef, + 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6, + 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a }, + .digest_length = AES_EIA2_DIGEST_LEN, + .digest = { 0xe6, 0x57, 0xe1, 0x82 } + }, +}; + +/* + * ZUC EEA3 and EIA3 test vectors from + * Specification of the 3GPP Confidentiality and Integrity + * Algorithms 128-EEA3 & 128-EIA3 + * Document 3: Implementor’s Test Data + * Version: 1.1 + * Date: 4 th Jan. 2011 + */ +static crypto_test_reference_t zuc_eea3_reference[] = { + { + .cipher = ODP_CIPHER_ALG_ZUC_EEA3, + .cipher_key_length = ZUC_EEA3_KEY_LEN, + .cipher_key = { 0xe5, 0xbd, 0x3e, 0xa0, 0xeb, 0x55, 0xad, 0xe8, + 0x66, 0xc6, 0xac, 0x58, 0xbd, 0x54, 0x30, 0x2a}, + .cipher_iv_length = ZUC_EEA3_IV_LEN, + .cipher_iv = { 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00, + 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00 }, + .length = 800, /* 100 bytes */ + .is_length_in_bits = true, + .plaintext = { 0x14, 0xa8, 0xef, 0x69, 0x3d, 0x67, 0x85, 0x07, + 0xbb, 0xe7, 0x27, 0x0a, 0x7f, 0x67, 0xff, 0x50, + 0x06, 0xc3, 0x52, 0x5b, 0x98, 0x07, 0xe4, 0x67, + 0xc4, 0xe5, 0x60, 0x00, 0xba, 0x33, 0x8f, 0x5d, + 0x42, 0x95, 0x59, 0x03, 0x67, 0x51, 0x82, 0x22, + 0x46, 0xc8, 0x0d, 0x3b, 0x38, 0xf0, 0x7f, 0x4b, + 0xe2, 0xd8, 0xff, 0x58, 0x05, 0xf5, 0x13, 0x22, + 0x29, 0xbd, 0xe9, 0x3b, 0xbb, 0xdc, 0xaf, 0x38, + 0x2b, 0xf1, 0xee, 0x97, 0x2f, 0xbf, 0x99, 0x77, + 0xba, 0xda, 0x89, 0x45, 0x84, 0x7a, 0x2a, 0x6c, + 0x9a, 0xd3, 0x4a, 0x66, 0x75, 0x54, 0xe0, 0x4d, + 0x1f, 0x7f, 0xa2, 0xc3, 0x32, 0x41, 0xbd, 0x8f, + 0x01, 0xba, 0x22, 0x0d }, + .ciphertext = { 0x13, 0x1d, 0x43, 0xe0, 0xde, 0xa1, 0xbe, 0x5c, + 0x5a, 0x1b, 0xfd, 0x97, 0x1d, 0x85, 0x2c, 0xbf, + 0x71, 0x2d, 0x7b, 0x4f, 0x57, 0x96, 0x1f, 0xea, + 0x32, 0x08, 0xaf, 0xa8, 0xbc, 0xa4, 0x33, 0xf4, + 0x56, 0xad, 0x09, 0xc7, 0x41, 0x7e, 0x58, 0xbc, + 0x69, 0xcf, 0x88, 0x66, 0xd1, 0x35, 0x3f, 0x74, + 0x86, 0x5e, 0x80, 0x78, 0x1d, 0x20, 0x2d, 0xfb, + 0x3e, 0xcf, 0xf7, 0xfc, 0xbc, 0x3b, 0x19, 0x0f, + 0xe8, 0x2a, 0x20, 0x4e, 0xd0, 0xe3, 0x50, 0xfc, + 0x0f, 0x6f, 0x26, 0x13, 0xb2, 0xf2, 0xbc, 0xa6, + 0xdf, 0x5a, 0x47, 0x3a, 0x57, 0xa4, 0xa0, 0x0d, + 0x98, 0x5e, 0xba, 0xd8, 0x80, 0xd6, 0xf2, 0x38, + 0x64, 0xa0, 0x7b, 0x01 } + }, + + /* Privately generated test data */ + { + .cipher = ODP_CIPHER_ALG_ZUC_EEA3, + .cipher_key_length = ZUC_EEA3_256_KEY_LEN, + .cipher_key = { 0xf7, 0xb4, 0x04, 0x5a, 0x81, 0x5c, 0x1b, 0x01, + 0x82, 0xf9, 0xf4, 0x26, 0x80, 0xd4, 0x56, 0x26, + 0xd5, 0xf7, 0x4b, 0x68, 0x48, 0x6b, 0x92, 0x6a, + 0x34, 0x1f, 0x86, 0x66, 0x60, 0x0a, 0xfc, 0x57}, + .cipher_iv_length = ZUC_EEA3_256_IV_LEN, + .cipher_iv = { 0x8e, 0x5d, 0xbc, 0x3f, 0xb9, 0xae, 0x66, 0xa3, + 0xb9, 0x5c, 0x12, 0x14, 0xdb, 0xc5, 0xbc, 0x18, + 0x48, 0x12, 0x09, 0x06, 0x25, 0x33, 0x2e, 0x12, + 0x12 }, + .length = 1024, + .is_length_in_bits = true, + .plaintext = { 0x36, 0xdb, 0x63, 0x68, 0xb5, 0x1f, 0x4e, 0x92, + 0x46, 0x1f, 0xde, 0xdb, 0xc2, 0xec, 0xfa, 0x7e, + 0x49, 0x85, 0x77, 0xaa, 0x46, 0x98, 0x30, 0x2d, + 0x3b, 0xc4, 0x11, 0x24, 0x98, 0x20, 0xa9, 0xce, + 0xfb, 0x0d, 0x36, 0xb0, 0x2c, 0x85, 0x42, 0x72, + 0xa4, 0x21, 0x4e, 0x66, 0x0d, 0x48, 0xe4, 0x57, + 0xce, 0x5b, 0x01, 0x14, 0xf3, 0x31, 0x42, 0x2e, + 0xf5, 0x53, 0x52, 0x8d, 0x73, 0xfc, 0x5c, 0x6e, + 0x09, 0x92, 0x1e, 0x35, 0x17, 0x60, 0xa8, 0xbb, + 0x81, 0xf6, 0x21, 0x8f, 0x3e, 0x05, 0xe6, 0x0c, + 0x60, 0xe7, 0x21, 0x53, 0x18, 0x63, 0x81, 0x0d, + 0xb6, 0xd4, 0x9a, 0x29, 0xd0, 0xf6, 0x97, 0xd9, + 0x89, 0xb5, 0x0e, 0xa0, 0x15, 0xb6, 0x5c, 0x97, + 0xac, 0x7d, 0x26, 0xeb, 0x83, 0x0c, 0xf7, 0xe3, + 0xf3, 0x18, 0x37, 0x0b, 0x7b, 0xb8, 0x18, 0x31, + 0x8c, 0xb2, 0x5a, 0x5c, 0xa9, 0xf1, 0x35, 0x32 }, + .ciphertext = { 0xa6, 0xe5, 0x71, 0x58, 0x5c, 0xcf, 0x5d, 0x0d, + 0x59, 0xb5, 0x51, 0xab, 0xf5, 0xfa, 0x31, 0xf9, + 0x8d, 0x4f, 0xf0, 0x3c, 0x7d, 0x61, 0x8d, 0x7a, + 0x6b, 0xcb, 0x2c, 0x79, 0xca, 0x99, 0x06, 0x6f, + 0xff, 0x5d, 0x12, 0x5f, 0x0e, 0x7a, 0x33, 0x6b, + 0x51, 0xbc, 0x58, 0x53, 0xff, 0xbd, 0x85, 0xc9, + 0xac, 0x5f, 0x33, 0xc2, 0xa2, 0xf1, 0x17, 0x7a, + 0xd9, 0x3f, 0x81, 0x82, 0x2f, 0x0a, 0xb0, 0xaf, + 0xb9, 0x19, 0x3b, 0xfa, 0xcd, 0xa4, 0x06, 0x81, + 0x2a, 0x7a, 0xbf, 0x2c, 0x07, 0xde, 0xc1, 0xa4, + 0x8c, 0x15, 0x85, 0x81, 0xa6, 0xd3, 0x73, 0x1c, + 0x29, 0x0b, 0xee, 0x3c, 0x57, 0xfa, 0x82, 0xad, + 0x6f, 0xe0, 0xa1, 0x54, 0x8d, 0xa4, 0x92, 0x29, + 0xf4, 0xfa, 0x6d, 0x01, 0xe3, 0x6c, 0xb9, 0x76, + 0x80, 0x53, 0xbb, 0x27, 0xb8, 0x18, 0x47, 0x6c, + 0xae, 0xb5, 0x44, 0x60, 0x43, 0x9d, 0xa7, 0x3f } + }, + /* Privately generated test data */ + { + .cipher = ODP_CIPHER_ALG_ZUC_EEA3, + .cipher_key_length = ZUC_EEA3_256_KEY_LEN, + .cipher_key = { 0x1d, 0x0f, 0x0e, 0x75, 0x86, 0xb3, 0xfc, 0x65, + 0x94, 0xbf, 0xaa, 0xa8, 0xf5, 0xd0, 0x0f, 0xe8, + 0x14, 0x7a, 0x96, 0x61, 0x15, 0x49, 0x79, 0x71, + 0x13, 0x82, 0xb4, 0xae, 0x34, 0x04, 0x75, 0x51 }, + .cipher_iv_length = ZUC_EEA3_256_IV_LEN, + .cipher_iv = { 0x98, 0xcc, 0x89, 0x9f, 0xaf, 0x6d, 0x64, 0xb6, + 0xb1, 0xe8, 0x21, 0x72, 0xee, 0xb6, 0xcc, 0xe3, + 0xcf, 0x32, 0x28, 0x21, 0x21, 0x0d, 0x1e, 0x1c, + 0x34 }, + .length = 1928, + .is_length_in_bits = true, + .plaintext = { 0xa4, 0xcb, 0x6e, 0x76, 0x99, 0xfb, 0x0c, 0xab, + 0x6d, 0x57, 0xb1, 0x69, 0xc0, 0x47, 0x80, 0x63, + 0x00, 0xe1, 0xf9, 0x51, 0x10, 0xbe, 0xc0, 0x0f, + 0x99, 0x62, 0x2d, 0x71, 0xca, 0x75, 0xa0, 0x6e, + 0x41, 0x0e, 0xe4, 0xda, 0x09, 0xf1, 0x86, 0x76, + 0x48, 0x37, 0xe0, 0x08, 0x7e, 0x60, 0x6c, 0x7f, + 0x41, 0x65, 0xd0, 0x51, 0x24, 0x91, 0x61, 0xbd, + 0xf3, 0x8e, 0x2e, 0xbd, 0x04, 0xce, 0x2b, 0x45, + 0xdc, 0x0f, 0x1f, 0xe5, 0x00, 0xa5, 0x5c, 0x48, + 0xdd, 0x3c, 0x51, 0x5b, 0x9c, 0xbd, 0xda, 0xde, + 0x22, 0xab, 0x2f, 0x46, 0x3c, 0x90, 0x03, 0x2f, + 0x1f, 0x31, 0xec, 0x23, 0xff, 0x17, 0x68, 0xdb, + 0x26, 0x87, 0xc1, 0x27, 0x2d, 0x1d, 0x6f, 0x0a, + 0x59, 0xc0, 0x65, 0xf5, 0x7d, 0x40, 0xd3, 0xa0, + 0xeb, 0x03, 0xe6, 0x27, 0x93, 0xea, 0x56, 0xb2, + 0x1b, 0x42, 0xd5, 0x1b, 0x59, 0x3d, 0xf6, 0x7f, + 0xc5, 0xb7, 0xa6, 0xf2, 0xd4, 0x16, 0xfc, 0x2d, + 0xd6, 0x61, 0x23, 0x54, 0xa1, 0xf6, 0xf4, 0x8c, + 0xf9, 0xda, 0xb3, 0x8d, 0xc4, 0x09, 0x3f, 0xe0, + 0x4b, 0x15, 0xfb, 0xa4, 0x52, 0xf1, 0x24, 0x17, + 0xa9, 0xca, 0x09, 0x7d, 0xe0, 0x05, 0xab, 0xb7, + 0x67, 0xce, 0x0b, 0x08, 0xc4, 0xff, 0x95, 0xbe, + 0xd9, 0x48, 0x4b, 0x9e, 0x52, 0x8a, 0x7e, 0x9d, + 0x9f, 0x79, 0x42, 0xf2, 0x6a, 0x66, 0x09, 0x13, + 0x30, 0x13, 0x91, 0x11, 0x18, 0x3c, 0xc8, 0x7f, + 0x0a, 0xd3, 0x88, 0xce, 0xd2, 0x1d, 0x8c, 0xab, + 0x65, 0xd7, 0x49, 0xb7, 0x62, 0xc7, 0x55, 0x01, + 0x40, 0x97, 0xf3, 0xab, 0xfd, 0xfd, 0xbe, 0x2d, + 0x10, 0x4f, 0x3e, 0x28, 0x8b, 0x06, 0xa8, 0x95, + 0xd9, 0x30, 0x64, 0xab, 0x4d, 0xf0, 0x57, 0xb2, + 0xc8 }, + .ciphertext = { 0xd0, 0xf9, 0xff, 0xce, 0x03, 0x81, 0x14, 0x9c, + 0xd5, 0xf2, 0xbf, 0xe5, 0xff, 0xc8, 0x15, 0x4a, + 0x9c, 0x06, 0x2b, 0x17, 0x99, 0xe3, 0x48, 0x70, + 0x37, 0x01, 0x5e, 0x24, 0x80, 0x9a, 0x46, 0x4e, + 0xa8, 0xc0, 0x59, 0xd7, 0x03, 0x74, 0x28, 0x91, + 0x79, 0xb4, 0xb5, 0xd6, 0x52, 0x92, 0x04, 0x77, + 0x5b, 0x4f, 0x34, 0xd1, 0xbe, 0xaa, 0x74, 0xd9, + 0x01, 0x40, 0x24, 0xc7, 0x8c, 0x62, 0x2a, 0x51, + 0x5a, 0x58, 0x0e, 0xc8, 0x70, 0x12, 0x06, 0x1c, + 0x62, 0x7f, 0xf5, 0x23, 0xcb, 0x3c, 0xc1, 0xbe, + 0x8b, 0x7f, 0x9d, 0x12, 0xb8, 0x26, 0xc8, 0xa3, + 0x77, 0x7e, 0x83, 0xda, 0x83, 0xe1, 0x9f, 0xef, + 0x33, 0x62, 0x17, 0xa7, 0x74, 0x68, 0x34, 0x5e, + 0x16, 0xcc, 0xbc, 0x6c, 0x33, 0x2f, 0x73, 0xf0, + 0xfc, 0xe5, 0x2c, 0x2d, 0xfb, 0x81, 0xbe, 0x1e, + 0x6e, 0x4f, 0xf4, 0x14, 0x37, 0x7c, 0x97, 0xac, + 0xa9, 0xac, 0x68, 0x95, 0xf3, 0x55, 0xb3, 0xfb, + 0xf6, 0x64, 0xd9, 0x1b, 0xe1, 0x54, 0x79, 0x6e, + 0xfa, 0x21, 0xa4, 0x19, 0x9f, 0xb4, 0x4b, 0xb7, + 0xef, 0x52, 0xd8, 0x44, 0x75, 0x99, 0x07, 0x6d, + 0xa9, 0xcf, 0x32, 0xc5, 0xc1, 0x31, 0x0c, 0xa8, + 0x86, 0x40, 0x75, 0xeb, 0x12, 0xcf, 0x26, 0x5c, + 0x5f, 0xa3, 0x3c, 0xb6, 0x12, 0x45, 0xf3, 0x0a, + 0x38, 0x09, 0xa8, 0x36, 0x32, 0x4a, 0x2f, 0xad, + 0x50, 0x11, 0x38, 0xba, 0x8f, 0xdd, 0xd1, 0x58, + 0xd7, 0x3d, 0x3a, 0x40, 0x7c, 0x3f, 0xa7, 0x98, + 0xf3, 0x12, 0x7f, 0x9f, 0x89, 0xcf, 0x48, 0x58, + 0x01, 0xeb, 0x98, 0x7c, 0x59, 0x11, 0x9f, 0x57, + 0x74, 0x5f, 0x70, 0x72, 0x74, 0xa4, 0x82, 0x3c, + 0x36, 0xe6, 0x31, 0x9e, 0xba, 0x7b, 0x53, 0xfc, + 0x56 } + }, +}; + +static crypto_test_reference_t zuc_eia3_reference[] = { + { + .auth = ODP_AUTH_ALG_ZUC_EIA3, + .auth_key_length = ZUC_EIA3_KEY_LEN, + .auth_key = { 0xc9, 0xe6, 0xce, 0xc4, 0x60, 0x7c, 0x72, 0xdb, + 0x00, 0x0a, 0xef, 0xa8, 0x83, 0x85, 0xab, 0x0a }, + .auth_iv_length = ZUC_EIA3_IV_LEN, + .auth_iv = { 0xa9, 0x40, 0x59, 0xda, 0x50, 0x00, 0x00, 0x00, + 0x29, 0x40, 0x59, 0xda, 0x50, 0x00, 0x80, 0x00 }, + .length = 584, /* 73 bytes */ + .is_length_in_bits = true, + .plaintext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e, + 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1, + 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83, + 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0, + 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9, + 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9, + 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d, + 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c, + 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81, + 0x00, 0x00, 0x00, 0x00 }, + .ciphertext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e, + 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1, + 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83, + 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0, + 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9, + 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9, + 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d, + 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c, + 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81, + 0x00, 0x00, 0x00, 0x00 }, + .digest_length = ZUC_EIA3_DIGEST_LEN, + .digest = { 0x24, 0xa8, 0x42, 0xb3 } + }, + /* Privately generated test data */ + { + .auth = ODP_AUTH_ALG_ZUC_EIA3, + .auth_key_length = ZUC_EIA3_256_KEY_LEN, + .auth_key = { 0xe3, 0x8e, 0xaf, 0x08, 0xde, 0x8c, 0x08, 0x41, + 0x7f, 0x2b, 0x97, 0x20, 0x10, 0x87, 0xc7, 0xf7, + 0xbe, 0x3c, 0xd2, 0x68, 0x80, 0x10, 0x1e, 0x71, + 0xfd, 0xb2, 0xbb, 0xad, 0x25, 0x0f, 0x06, 0x08 }, + .auth_iv_length = ZUC_EIA3_256_IV_LEN, + .auth_iv = { 0xf5, 0x8d, 0x08, 0x26, 0x94, 0x14, 0xc7, 0x4d, + 0xf5, 0x7c, 0x9c, 0xaa, 0x45, 0x53, 0xfd, 0x85, + 0x23, 0x0b, 0x00, 0x0e, 0x26, 0x2b, 0x0f, 0x01, + 0x26 }, + .length = 360, + .is_length_in_bits = true, + .plaintext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf, + 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87, + 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46, + 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f, + 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7, + 0xca, 0x86, 0x93, 0x6d, 0xee }, + .ciphertext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf, + 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87, + 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46, + 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f, + 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7, + 0xca, 0x86, 0x93, 0x6d, 0xee }, + .digest_length = ZUC_EIA3_DIGEST_LEN, + .digest = {0x58, 0x19, 0xab, 0xa5} + }, + /* Privately generated test data */ + { + .auth = ODP_AUTH_ALG_ZUC_EIA3, + .auth_key_length = ZUC_EIA3_256_KEY_LEN, + .auth_key = { 0x6a, 0x7e, 0x4c, 0x7e, 0x51, 0x25, 0xb3, 0x48, + 0x84, 0x53, 0x3a, 0x94, 0xfb, 0x31, 0x99, 0x90, + 0x32, 0x57, 0x44, 0xee, 0x9b, 0xbc, 0xe9, 0xe5, + 0x25, 0xcf, 0x08, 0xf5, 0xe9, 0xe2, 0x5e, 0x53 }, + .auth_iv_length = ZUC_EIA3_256_IV_LEN, + .auth_iv = { 0x60, 0xaa, 0xd2, 0xb2, 0xd0, 0x85, 0xfa, 0x54, + 0xd8, 0x35, 0xe8, 0xd4, 0x66, 0x82, 0x64, 0x98, + 0xd9, 0x2a, 0x08, 0x1d, 0x35, 0x19, 0x17, 0x01, + 0x1A }, + .length = 2872, + .is_length_in_bits = true, + .plaintext = { 0xc6, 0x69, 0x73, 0x51, 0xff, 0x4a, 0xec, 0x29, + 0xcd, 0xba, 0xab, 0xf2, 0xfb, 0xe3, 0x46, 0x7c, + 0xc2, 0x54, 0xf8, 0x1b, 0xe8, 0xe7, 0x8d, 0x76, + 0x5a, 0x2e, 0x63, 0x33, 0x9f, 0xc9, 0x9a, 0x66, + 0x32, 0x0d, 0xb7, 0x31, 0x58, 0xa3, 0x5a, 0x25, + 0x5d, 0x05, 0x17, 0x58, 0xe9, 0x5e, 0xd4, 0xab, + 0xb2, 0xcd, 0xc6, 0x9b, 0xb4, 0x54, 0x11, 0x0e, + 0x82, 0x74, 0x41, 0x21, 0x3d, 0xdc, 0x87, 0x70, + 0xe9, 0x3e, 0xa1, 0x41, 0xe1, 0xfc, 0x67, 0x3e, + 0x01, 0x7e, 0x97, 0xea, 0xdc, 0x6b, 0x96, 0x8f, + 0x38, 0x5c, 0x2a, 0xec, 0xb0, 0x3b, 0xfb, 0x32, + 0xaf, 0x3c, 0x54, 0xec, 0x18, 0xdb, 0x5c, 0x02, + 0x1a, 0xfe, 0x43, 0xfb, 0xfa, 0xaa, 0x3a, 0xfb, + 0x29, 0xd1, 0xe6, 0x05, 0x3c, 0x7c, 0x94, 0x75, + 0xd8, 0xbe, 0x61, 0x89, 0xf9, 0x5c, 0xbb, 0xa8, + 0x99, 0x0f, 0x95, 0xb1, 0xeb, 0xf1, 0xb3, 0x05, + 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5, 0xca, + 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd, 0x1f, + 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5, 0x14, + 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63, 0x3b, + 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc, 0xaa, + 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b, 0x33, + 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c, 0xbb, + 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5, 0x0b, + 0xe1, 0x1a, 0x1c, 0x7f, 0x23, 0xf8, 0x29, 0xf8, + 0xa4, 0x1b, 0x13, 0xb5, 0xca, 0x4e, 0xe8, 0x98, + 0x32, 0x38, 0xe0, 0x79, 0x4d, 0x3d, 0x34, 0xbc, + 0x5f, 0x4e, 0x77, 0xfa, 0xcb, 0x6c, 0x05, 0xac, + 0x86, 0x21, 0x2b, 0xaa, 0x1a, 0x55, 0xa2, 0xbe, + 0x70, 0xb5, 0x73, 0x3b, 0x04, 0x5c, 0xd3, 0x36, + 0x94, 0xb3, 0xaf, 0xe2, 0xf0, 0xe4, 0x9e, 0x4f, + 0x32, 0x15, 0x49, 0xfd, 0x82, 0x4e, 0xa9, 0x08, + 0x70, 0xd4, 0xb2, 0x8a, 0x29, 0x54, 0x48, 0x9a, + 0x0a, 0xbc, 0xd5, 0x0e, 0x18, 0xa8, 0x44, 0xac, + 0x5b, 0xf3, 0x8e, 0x4c, 0xd7, 0x2d, 0x9b, 0x09, + 0x42, 0xe5, 0x06, 0xc4, 0x33, 0xaf, 0xcd, 0xa3, + 0x84, 0x7f, 0x2d, 0xad, 0xd4, 0x76, 0x47, 0xde, + 0x32, 0x1c, 0xec, 0x4a, 0xc4, 0x30, 0xf6, 0x20, + 0x23, 0x85, 0x6c, 0xfb, 0xb2, 0x07, 0x04, 0xf4, + 0xec, 0x0b, 0xb9, 0x20, 0xba, 0x86, 0xc3, 0x3e, + 0x05, 0xf1, 0xec, 0xd9, 0x67, 0x33, 0xb7, 0x99, + 0x50, 0xa3, 0xe3, 0x14, 0xd3, 0xd9, 0x34, 0xf7, + 0x5e, 0xa0, 0xf2, 0x10, 0xa8, 0xf6, 0x05, 0x94, + 0x01, 0xbe, 0xb4, 0xbc, 0x44, 0x78, 0xfa, 0x49, + 0x69, 0xe6, 0x23, 0xd0, 0x1a, 0xda, 0x69 }, + .ciphertext = { 0xc6, 0x69, 0x73, 0x51, 0xff, 0x4a, 0xec, 0x29, + 0xcd, 0xba, 0xab, 0xf2, 0xfb, 0xe3, 0x46, 0x7c, + 0xc2, 0x54, 0xf8, 0x1b, 0xe8, 0xe7, 0x8d, 0x76, + 0x5a, 0x2e, 0x63, 0x33, 0x9f, 0xc9, 0x9a, 0x66, + 0x32, 0x0d, 0xb7, 0x31, 0x58, 0xa3, 0x5a, 0x25, + 0x5d, 0x05, 0x17, 0x58, 0xe9, 0x5e, 0xd4, 0xab, + 0xb2, 0xcd, 0xc6, 0x9b, 0xb4, 0x54, 0x11, 0x0e, + 0x82, 0x74, 0x41, 0x21, 0x3d, 0xdc, 0x87, 0x70, + 0xe9, 0x3e, 0xa1, 0x41, 0xe1, 0xfc, 0x67, 0x3e, + 0x01, 0x7e, 0x97, 0xea, 0xdc, 0x6b, 0x96, 0x8f, + 0x38, 0x5c, 0x2a, 0xec, 0xb0, 0x3b, 0xfb, 0x32, + 0xaf, 0x3c, 0x54, 0xec, 0x18, 0xdb, 0x5c, 0x02, + 0x1a, 0xfe, 0x43, 0xfb, 0xfa, 0xaa, 0x3a, 0xfb, + 0x29, 0xd1, 0xe6, 0x05, 0x3c, 0x7c, 0x94, 0x75, + 0xd8, 0xbe, 0x61, 0x89, 0xf9, 0x5c, 0xbb, 0xa8, + 0x99, 0x0f, 0x95, 0xb1, 0xeb, 0xf1, 0xb3, 0x05, + 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5, 0xca, + 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd, 0x1f, + 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5, 0x14, + 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63, 0x3b, + 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc, 0xaa, + 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b, 0x33, + 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c, 0xbb, + 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5, 0x0b, + 0xe1, 0x1a, 0x1c, 0x7f, 0x23, 0xf8, 0x29, 0xf8, + 0xa4, 0x1b, 0x13, 0xb5, 0xca, 0x4e, 0xe8, 0x98, + 0x32, 0x38, 0xe0, 0x79, 0x4d, 0x3d, 0x34, 0xbc, + 0x5f, 0x4e, 0x77, 0xfa, 0xcb, 0x6c, 0x05, 0xac, + 0x86, 0x21, 0x2b, 0xaa, 0x1a, 0x55, 0xa2, 0xbe, + 0x70, 0xb5, 0x73, 0x3b, 0x04, 0x5c, 0xd3, 0x36, + 0x94, 0xb3, 0xaf, 0xe2, 0xf0, 0xe4, 0x9e, 0x4f, + 0x32, 0x15, 0x49, 0xfd, 0x82, 0x4e, 0xa9, 0x08, + 0x70, 0xd4, 0xb2, 0x8a, 0x29, 0x54, 0x48, 0x9a, + 0x0a, 0xbc, 0xd5, 0x0e, 0x18, 0xa8, 0x44, 0xac, + 0x5b, 0xf3, 0x8e, 0x4c, 0xd7, 0x2d, 0x9b, 0x09, + 0x42, 0xe5, 0x06, 0xc4, 0x33, 0xaf, 0xcd, 0xa3, + 0x84, 0x7f, 0x2d, 0xad, 0xd4, 0x76, 0x47, 0xde, + 0x32, 0x1c, 0xec, 0x4a, 0xc4, 0x30, 0xf6, 0x20, + 0x23, 0x85, 0x6c, 0xfb, 0xb2, 0x07, 0x04, 0xf4, + 0xec, 0x0b, 0xb9, 0x20, 0xba, 0x86, 0xc3, 0x3e, + 0x05, 0xf1, 0xec, 0xd9, 0x67, 0x33, 0xb7, 0x99, + 0x50, 0xa3, 0xe3, 0x14, 0xd3, 0xd9, 0x34, 0xf7, + 0x5e, 0xa0, 0xf2, 0x10, 0xa8, 0xf6, 0x05, 0x94, + 0x01, 0xbe, 0xb4, 0xbc, 0x44, 0x78, 0xfa, 0x49, + 0x69, 0xe6, 0x23, 0xd0, 0x1a, 0xda, 0x69 }, + .digest_length = ZUC_EIA3_DIGEST_LEN, + .digest = {0xd1, 0x1e, 0x33, 0xf6} + }, +}; + +/* + * MD5 test vectors from RFC 1321 + */ +static crypto_test_reference_t md5_reference[] = { + { + .auth = ODP_AUTH_ALG_MD5, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = MD5_DIGEST_LEN, + .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72} + }, + { + .auth = ODP_AUTH_ALG_MD5, + .length = 62, + .plaintext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }, + .ciphertext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, + 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }, + .digest_length = MD5_DIGEST_LEN, + .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f}, + } +}; + +/* + * SHA test vectors from Crypto++ + */ +static crypto_test_reference_t sha1_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA1, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = SHA1_DIGEST_LEN, + .digest = { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, + 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, + 0x9C, 0xD0, 0xD8, 0x9D}, + }, + { + .auth = ODP_AUTH_ALG_SHA1, + .length = 56, + .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .digest_length = SHA1_DIGEST_LEN, + .digest = { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, + 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, + 0xE5, 0x46, 0x70, 0xF1}, + } +}; + +static crypto_test_reference_t sha224_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA224, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = SHA224_DIGEST_LEN, + .digest = { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22, + 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3, + 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7, + 0xe3, 0x6c, 0x9d, 0xa7 }, + }, + { + .auth = ODP_AUTH_ALG_SHA224, + .length = 56, + .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .digest_length = SHA224_DIGEST_LEN, + .digest = { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc, + 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50, + 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19, + 0x52, 0x52, 0x25, 0x25}, + } +}; + +static crypto_test_reference_t sha256_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA256, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = SHA256_DIGEST_LEN, + .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, + 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, + 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, + 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, + }, + { + .auth = ODP_AUTH_ALG_SHA256, + .length = 56, + .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, + 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, + 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, + 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, + 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, + 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, + .digest_length = SHA256_DIGEST_LEN, + .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, + 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, + 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, + 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}, + } +}; + +static crypto_test_reference_t sha384_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA384, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = SHA384_DIGEST_LEN, + .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, + 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, + 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, + 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, + 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, + 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7}, + }, + { + .auth = ODP_AUTH_ALG_SHA384, + .length = 112, + .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, + .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, + .digest_length = SHA384_DIGEST_LEN, + .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, + 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, + 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, + 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, + 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, + 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39}, + } +}; + +static crypto_test_reference_t sha512_reference[] = { + { + .auth = ODP_AUTH_ALG_SHA512, + .length = 3, + .plaintext = { 0x61, 0x62, 0x63 }, + .ciphertext = { 0x61, 0x62, 0x63 }, + .digest_length = SHA512_DIGEST_LEN, + .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, + 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, + 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, + 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a, + 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, + 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, + 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, + 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f}, + }, + { + .auth = ODP_AUTH_ALG_SHA512, + .length = 112, + .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, + .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, + .digest_length = SHA512_DIGEST_LEN, + .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, + 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, + 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, + 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, + 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, + 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, + 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, + 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09}, + } +}; + +#endif diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h index b9a9c2f06..a38644246 100644 --- a/test/validation/api/crypto/test_vectors.h +++ b/test/validation/api/crypto/test_vectors.h @@ -1,17 +1,20 @@ /* Copyright (c) 2014-2018, Linaro Limited - * Copyright (c) 2021-2022, Nokia + * Copyright (c) 2021-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef _ODP_TEST_CRYPTO_VECTORS_H_ -#define _ODP_TEST_CRYPTO_VECTORS_H_ +#ifndef TEST_VECTORS_H +#define TEST_VECTORS_H +#include <odp_api.h> #include "test_vectors_len.h" typedef struct crypto_test_reference_s { uint8_t copy_previous_vector; /* does not copy digest_length */ + odp_cipher_alg_t cipher; + odp_auth_alg_t auth; uint32_t cipher_key_length; uint8_t cipher_key[MAX_KEY_LEN]; uint32_t auth_key_length; @@ -30,6 +33,9 @@ typedef struct crypto_test_reference_s { uint8_t digest[MAX_DIGEST_LEN]; } crypto_test_reference_t; +ODP_STATIC_ASSERT(ODP_CIPHER_ALG_NULL == 0, "null cipher is not the default"); +ODP_STATIC_ASSERT(ODP_AUTH_ALG_NULL == 0, "null auth is not the default"); + /* * Return test data length in bytes, rounding up to full bytes. */ @@ -46,3039 +52,7 @@ static inline uint32_t ref_length_in_bits(const crypto_test_reference_t *ref) return ref->is_length_in_bits ? ref->length : 8 * ref->length; } -static crypto_test_reference_t null_reference[] = { - { - .length = 8, - .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }, - .ciphertext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 } - }, - { - .length = 16, - .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, - 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }, - .ciphertext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, - 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 } - } -}; - -/* TDES-CBC reference vectors, according to - * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf" - */ -static crypto_test_reference_t tdes_cbc_reference[] = { - { - .cipher_key_length = TDES_CBC_KEY_LEN, - .cipher_key = { 0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, - 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1, - 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c}, - .cipher_iv_length = TDES_CBC_IV_LEN, - .cipher_iv = { 0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75 }, - .length = 8, - .plaintext = { 0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56 }, - .ciphertext = { 0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92 } - }, - { - .cipher_key_length = TDES_CBC_KEY_LEN, - .cipher_key = { 0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc, - 0x07, 0x54, 0xb9, 0x4f, 0x31, 0xcb, 0xb3, 0x85, - 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae}, - .cipher_iv_length = TDES_CBC_IV_LEN, - .cipher_iv = {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65 }, - .length = 16, - .plaintext = { 0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, - 0x6d, 0x8e, 0xa2, 0x30, 0x94, 0xea, 0x53, 0x09 }, - .ciphertext = { 0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, - 0xbd, 0x04, 0xa7, 0x5f, 0xfb, 0xa7, 0xd2, 0xf5 } - } -}; - -/* - * TDES-ECB reference vectors, according to - * CAVS 18.0 TECBMMT - */ -static crypto_test_reference_t tdes_ecb_reference[] = { - /* CAVS 18.0 TECBMMT2.rsp #0 */ - { - .cipher_key_length = TDES_ECB_KEY_LEN, - .cipher_key = { 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b, - 0x4a, 0x76, 0x3b, 0xd5, 0x4a, 0x46, 0xa4, 0x45, - 0x15, 0x1f, 0x10, 0x38, 0x3d, 0x6d, 0x19, 0x9b}, - .length = 8, - .plaintext = { 0xd8, 0xda, 0x89, 0x29, 0x88, 0x78, 0xed, 0x7d }, - .ciphertext = { 0x89, 0x32, 0x1b, 0xa7, 0x5b, 0xa5, 0x45, 0xdb } - }, - /* CAVS 18.0 TECBMMT2.rsp #2 */ - { - .cipher_key_length = TDES_ECB_KEY_LEN, - .cipher_key = { 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5, - 0xfe, 0xe6, 0x73, 0x34, 0x31, 0x1c, 0xa4, 0x62, - 0xcd, 0x3d, 0x9b, 0xf7, 0x2f, 0x8c, 0x8a, 0xb5}, - .length = 24, - .plaintext = { 0x2f, 0x2a, 0x36, 0x1c, 0x8e, 0x14, 0x5d, 0xc0, - 0xa7, 0x4a, 0x1b, 0xdb, 0x7c, 0xa9, 0x29, 0xc3, - 0x38, 0x14, 0x4d, 0x89, 0x13, 0x5b, 0x50, 0xa7 }, - .ciphertext = { 0x7f, 0x1f, 0xd3, 0x2b, 0x36, 0x90, 0x05, 0x4b, - 0xfa, 0x1b, 0x17, 0x35, 0x15, 0x79, 0x33, 0x80, - 0x99, 0xff, 0xa8, 0x4f, 0xea, 0x16, 0x8c, 0x6b } - } -}; - -static crypto_test_reference_t aes_cbc_reference[] = { - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, - 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, - 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, - .length = 16, - .plaintext = "Single block msg", - .ciphertext = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, - 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, - 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, - 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, - .length = 32, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, - .ciphertext = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a, - 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a, - 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9, - 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, - 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb, - 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 }, - .length = 48, - .plaintext = "This is a 48-byte message (exactly 3 AES blocks)", - .ciphertext = { 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53, - 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86, - 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7, - 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5, - 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c, - 0x85, 0x79, 0x69, 0x5d, 0x83, 0xba, 0x26, 0x84 } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, - 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, - 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 }, - .length = 64, - .plaintext = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf }, - .ciphertext = { 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e, - 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa, - 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6, - 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e, - 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf, - 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad, - 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d, - 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55 } - }, - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, - 0xde, 0xca, 0xf8, 0x88, 0x01, 0x23, 0x45, 0x67 }, - .length = 32, - .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00, - 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f, - 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8, - 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e }, - .ciphertext = { 0x0d, 0xbe, 0x02, 0xda, 0x68, 0x9c, 0x8f, 0x30, - 0xce, 0x7c, 0x91, 0x7d, 0x41, 0x08, 0xf6, 0xf1, - 0x8e, 0x0d, 0x7f, 0x02, 0xb6, 0x80, 0x9a, 0x2d, - 0x53, 0x1c, 0xc6, 0x98, 0x85, 0xc3, 0x00, 0xe6}, - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, - 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, - 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d, - 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8, - 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4, - 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a, - 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0, - 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0, - 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81, - 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd } - }, - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, - 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, - 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, - 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c }, - .length = 48, - .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00, - 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02, - 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b, - 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00, - 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 }, - .ciphertext = { 0x92, 0x1e, 0x2f, 0x37, 0x36, 0x3c, 0x45, 0xda, - 0xc9, 0x58, 0xb7, 0x07, 0x06, 0x56, 0x54, 0xc5, - 0x93, 0x46, 0x90, 0xb8, 0xcf, 0x0d, 0x4f, 0x79, - 0xf1, 0x32, 0xc2, 0xf7, 0x23, 0xb8, 0x83, 0x09, - 0xbc, 0x37, 0x1c, 0xeb, 0x95, 0x2c, 0x42, 0x7b, - 0x39, 0x10, 0xa8, 0x76, 0xfa, 0xbe, 0x91, 0xe9}, - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, - 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, - 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, - 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, - .cipher_iv_length = AES_CBC_IV_LEN, - .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, - 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6, - 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d, - 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d, - 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf, - 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61, - 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc, - 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b } - } -}; - -static crypto_test_reference_t aes_ctr_reference[] = { - /* RFC3686 https://tools.ietf.org/html/rfc3686 */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x7E, 0x24, 0x06, 0x78, 0x17, 0xFA, 0xE0, 0xD7, - 0x43, 0xD6, 0xCE, 0x1F, 0x32, 0x53, 0x91, 0x63}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0x00, 0x6C, 0xB6, 0xDB, 0xC0, 0x54, 0x3B, 0x59, - 0xDA, 0x48, 0xD9, 0x0B, 0x00, 0x00, 0x00, 0x01 }, - .length = 32, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, - .ciphertext = { 0x51, 0x04, 0xA1, 0x06, 0x16, 0x8A, 0x72, 0xD9, - 0x79, 0x0D, 0x41, 0xEE, 0x8E, 0xDA, 0xD3, 0x88, - 0xEB, 0x2E, 0x1E, 0xFC, 0x46, 0xDA, 0x57, 0xC8, - 0xFC, 0xE6, 0x30, 0xDF, 0x91, 0x41, 0xBE, 0x28} - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, - 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce, - 0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff, - 0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff, - 0x5a, 0xe4, 0xdf, 0x3e, 0xdb, 0xd5, 0xd3, 0x5e, - 0x5b, 0x4f, 0x09, 0x02, 0x0d, 0xb0, 0x3e, 0xab, - 0x1e, 0x03, 0x1d, 0xda, 0x2f, 0xbe, 0x03, 0xd1, - 0x79, 0x21, 0x70, 0xa0, 0xf3, 0x00, 0x9c, 0xee } - }, - /* Generated by Crypto++ 5.6.1 (715 bytes data)*/ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, - .length = 715, - .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, - 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, - 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, - 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, - 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, - 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, - 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, - 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, - 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, - 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, - 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, - 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, - 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, - 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, - 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, - 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, - 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, - 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, - 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, - 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, - 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, - 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, - 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, - 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, - 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, - 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, - 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, - 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, - 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, - 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, - 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, - 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, - 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, - 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, - 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, - 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, - 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, - 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, - 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, - 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, 0xc1, - 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, - 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, - 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, - 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, - 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, - 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, - 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, - 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x6b, - 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, - 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, - 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, - 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, - 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, - 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, - 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, - 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, - 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, - 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, - 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, - 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, - 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, - 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, - 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, - 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, - 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, - 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, - 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, - 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, - 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, - 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, - 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, - 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, - 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, - 0x37, 0x10, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, - 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, - 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, - 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, - 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, - 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, - 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, - 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xEC, 0xE7, 0x1E, 0xCD, 0x7A, 0x4E, 0x3C, 0x2F, - 0x64, 0x3B, 0x2B, 0x0B, 0xFB, 0xED, 0x32, 0xF3, - 0x1C, 0x85, 0x51, 0xB6, 0x30, 0x6D, 0x52, 0xCF, - 0x84, 0x3E, 0xC0, 0xB8, 0x50, 0x15, 0xDC, 0x20, - 0x3B, 0x1C, 0x0B, 0x64, 0x3E, 0x2A, 0x6B, 0xAB, - 0xAF, 0x51, 0x33, 0xDA, 0x0E, 0xA0, 0x66, 0x16, - 0x07, 0x6A, 0xA6, 0xBB, 0xB5, 0x2E, 0xD7, 0x5D, - 0xC3, 0xA7, 0x1A, 0x9A, 0x6E, 0x8A, 0xC7, 0xC9, - 0xA0, 0x0D, 0x2C, 0x39, 0xAA, 0x68, 0xBF, 0x4E, - 0x6F, 0xFE, 0xD9, 0xAA, 0xEE, 0x5A, 0xD6, 0x91, - 0x4F, 0xB3, 0xEA, 0x77, 0xC7, 0xB6, 0x1F, 0xF6, - 0xBF, 0x56, 0x4F, 0x2F, 0x12, 0x25, 0xAC, 0xB4, - 0xB5, 0x88, 0x9C, 0xB1, 0x55, 0x98, 0x88, 0xA5, - 0x81, 0x78, 0x49, 0xC3, 0x82, 0xE1, 0x68, 0x48, - 0x2F, 0x75, 0x38, 0x1F, 0x63, 0x86, 0x8C, 0x46, - 0x8E, 0x4D, 0x15, 0x83, 0xB1, 0xFE, 0x71, 0xDD, - 0x80, 0x8C, 0xB9, 0x4D, 0x81, 0x50, 0xAA, 0xB9, - 0xD5, 0x30, 0xA0, 0xFC, 0x17, 0xCD, 0xE7, 0x48, - 0xE9, 0x55, 0x45, 0xD8, 0xA0, 0x33, 0xB2, 0xF6, - 0x1F, 0x19, 0x54, 0xD0, 0xC0, 0x22, 0x61, 0x68, - 0x02, 0x2E, 0x1C, 0xD7, 0xE0, 0x31, 0xC5, 0x7D, - 0x04, 0x8A, 0xC5, 0x60, 0xF1, 0x52, 0x96, 0x0F, - 0x47, 0x70, 0x5E, 0x17, 0x4D, 0x95, 0x6D, 0x4B, - 0xB5, 0x3A, 0xE8, 0x0B, 0xFF, 0xCD, 0x1B, 0xD5, - 0x69, 0xED, 0x8E, 0xFF, 0xA2, 0x23, 0xC0, 0x05, - 0x58, 0xB7, 0x02, 0x40, 0x5F, 0x33, 0xE6, 0xE0, - 0xED, 0xB2, 0xD9, 0xB0, 0xC1, 0x48, 0xA1, 0x44, - 0x1C, 0xC8, 0x0D, 0x6A, 0xBB, 0xCE, 0x78, 0x5A, - 0xA1, 0xB9, 0xDA, 0xB7, 0xCB, 0x88, 0x32, 0xF1, - 0xB1, 0x2D, 0x2E, 0xE6, 0x0E, 0xE2, 0xDF, 0xCA, - 0x37, 0x94, 0x2C, 0xA1, 0x72, 0x4E, 0x56, 0x02, - 0xB7, 0xB7, 0x05, 0x25, 0xAC, 0x96, 0x62, 0x02, - 0x8A, 0x22, 0xDB, 0x23, 0x46, 0x76, 0x61, 0x5D, - 0xB4, 0x74, 0x53, 0x8C, 0xBC, 0x8D, 0x19, 0x7F, - 0x38, 0xC8, 0x8B, 0xCC, 0x4F, 0x9E, 0x8D, 0x20, - 0x75, 0x38, 0xCA, 0x18, 0xDE, 0x5F, 0x09, 0x54, - 0x20, 0xA2, 0xE4, 0xD5, 0x86, 0x8C, 0xEB, 0xB8, - 0xB3, 0x4A, 0x93, 0x77, 0xDC, 0x52, 0xD1, 0x19, - 0x79, 0x0B, 0x65, 0x21, 0x0F, 0x1B, 0x34, 0x6F, - 0x5E, 0x00, 0xD9, 0xBD, 0x00, 0xA8, 0x84, 0x70, - 0x48, 0x91, 0x3D, 0x80, 0x72, 0x6B, 0x9B, 0x74, - 0x5D, 0x56, 0x5E, 0x62, 0x84, 0xB9, 0x86, 0xDB, - 0xAE, 0xA9, 0x97, 0xFF, 0xC5, 0xA0, 0xDE, 0x50, - 0x51, 0x52, 0x7D, 0x44, 0xB2, 0xC1, 0x26, 0x6D, - 0xBC, 0x91, 0x30, 0xA6, 0xEB, 0x15, 0xF3, 0x7A, - 0x0F, 0x00, 0xB6, 0x28, 0x6D, 0x66, 0x78, 0xCA, - 0x65, 0x1C, 0x07, 0x74, 0x3B, 0xD3, 0x7F, 0x2E, - 0x8F, 0x6A, 0x94, 0xF5, 0xED, 0x8C, 0x63, 0x42, - 0x8A, 0xE4, 0x88, 0x3A, 0x96, 0x95, 0x18, 0x38, - 0x07, 0xE1, 0x04, 0xBC, 0x33, 0x5C, 0x64, 0xFE, - 0xAA, 0xC4, 0x0A, 0x60, 0x59, 0x13, 0xDF, 0x98, - 0xFF, 0x44, 0xE0, 0x80, 0x1B, 0x31, 0xA9, 0x68, - 0xCC, 0xE5, 0xDC, 0xAF, 0xAD, 0xE1, 0xE0, 0x17, - 0xFA, 0x71, 0x1E, 0x05, 0xFF, 0x5A, 0x54, 0xBF, - 0xA1, 0x99, 0x9C, 0x2C, 0x46, 0x3F, 0x97, 0xA3, - 0xA6, 0x6B, 0x30, 0x21, 0x1B, 0xD3, 0x06, 0xC8, - 0x91, 0x1C, 0x98, 0xF8, 0xEE, 0x5E, 0xF4, 0x7A, - 0x54, 0x74, 0x6A, 0x4D, 0x16, 0xB7, 0xC7, 0x42, - 0x4A, 0x69, 0x54, 0xB4, 0xFC, 0x3B, 0xCF, 0x1A, - 0x41, 0xBD, 0xE8, 0xA1, 0x9C, 0xE1, 0x02, 0x7A, - 0xE8, 0x6A, 0x32, 0x0D, 0x0E, 0x5E, 0x7D, 0x3C, - 0x7E, 0x50, 0xCF, 0xD0, 0xC4, 0x66, 0x5B, 0x81, - 0x1D, 0x86, 0xC3, 0x13, 0xF0, 0x9A, 0xDE, 0x5B, - 0x4D, 0xBE, 0x01, 0x72, 0x31, 0x85, 0x98, 0x81, - 0xE5, 0x87, 0x3E, 0x9E, 0xDB, 0x20, 0x11, 0xCF, - 0x59, 0x20, 0xD2, 0xF7, 0x27, 0x7C, 0x4D, 0xE1, - 0xAC, 0x43, 0x0A, 0x18, 0x49, 0xF0, 0xB8, 0x70, - 0xA6, 0x9A, 0xBE, 0x70, 0x1B, 0x6D, 0x0B, 0x51, - 0x23, 0xE5, 0xFF, 0x53, 0x39, 0x54, 0x09, 0x17, - 0x7C, 0xF8, 0x4B, 0xF4, 0x1E, 0xC3, 0x3C, 0x5E, - 0x4B, 0xCC, 0x2C, 0xF2, 0x92, 0x58, 0xDC, 0x7C, - 0x26, 0x04, 0x71, 0xAA, 0xBD, 0xA4, 0x9F, 0xDE, - 0x62, 0x91, 0x57, 0x58, 0xEE, 0x4E, 0x57, 0x8D, - 0x0F, 0x76, 0x98, 0xE6, 0x45, 0x6B, 0xC1, 0x44, - 0x57, 0x37, 0x39, 0xD5, 0xD5, 0x08, 0xCC, 0x76, - 0xB3, 0x89, 0x35, 0x9D, 0x2A, 0x0E, 0xCB, 0x5B, - 0x7E, 0xE5, 0xFC, 0xB4, 0xC3, 0x15, 0x1D, 0x5A, - 0xF7, 0xC7, 0x18, 0x19, 0xEA, 0x3D, 0xD5, 0xF3, - 0x6C, 0x7B, 0x27, 0xE5, 0x51, 0xFD, 0x23, 0x73, - 0xD0, 0x7F, 0xFD, 0xC7, 0x6A, 0x13, 0xFC, 0x4B, - 0x10, 0xA6, 0xF2, 0x9A, 0x83, 0xD6, 0xF4, 0x65, - 0xAC, 0xB6, 0x96, 0x06, 0x71, 0xEA, 0xCF, 0x21, - 0xA3, 0xE1, 0xCB, 0x44, 0x11, 0xC4, 0xDA, 0xA0, - 0xC2, 0xA8, 0x7D, 0xAE, 0xD2, 0x8A, 0xEE, 0x60, - 0xB7, 0xEC, 0x02, 0x58, 0xA9, 0xAF, 0x12, 0x5F, - 0x2D, 0xDC, 0x80, 0xB9, 0x87, 0x7E, 0xFE, 0x0F, - 0x37, 0x2D, 0x9B, 0x83, 0x2C, 0x78, 0x67, 0x70, - 0xA8, 0x4E, 0xA1, 0xA0, 0x7C, 0xB6, 0xE1, 0xA9, - 0x90, 0x7D, 0x65, 0x1B, 0xBD, 0x0E, 0xFD, 0xEF, - 0x2A, 0xFF, 0xC3 } - }, - /* RFC3686 https://tools.ietf.org/html/rfc3686 */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0x02, 0xBF, 0x39, 0x1E, 0xE8, 0xEC, 0xB1, 0x59, - 0xB9, 0x59, 0x61, 0x7B, 0x09, 0x65, 0x27, 0x9B, - 0xF5, 0x9B, 0x60, 0xA7, 0x86, 0xD3, 0xE0, 0xFE}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0x00, 0x07, 0xBD, 0xFD, 0x5C, 0xBD, 0x60, 0x27, - 0x8D, 0xCC, 0x09, 0x12, 0x00, 0x00, 0x00, 0x01 }, - .length = 36, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23 }, - .ciphertext = { 0x96, 0x89, 0x3F, 0xC5, 0x5E, 0x5C, 0x72, 0x2F, - 0x54, 0x0B, 0x7D, 0xD1, 0xDD, 0xF7, 0xE7, 0x58, - 0xD2, 0x88, 0xBC, 0x95, 0xC6, 0x91, 0x65, 0x88, - 0x45, 0x36, 0xC8, 0x11, 0x66, 0x2F, 0x21, 0x88, - 0xAB, 0xEE, 0x09, 0x35 } - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, - 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, - 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2, - 0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b, - 0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef, - 0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94, - 0x1e, 0x36, 0xb2, 0x6b, 0xd1, 0xeb, 0xc6, 0x70, - 0xd1, 0xbd, 0x1d, 0x66, 0x56, 0x20, 0xab, 0xf7, - 0x4f, 0x78, 0xa7, 0xf6, 0xd2, 0x98, 0x09, 0x58, - 0x5a, 0x97, 0xda, 0xec, 0x58, 0xc6, 0xb0, 0x50 } - }, - /* RFC3686 https://tools.ietf.org/html/rfc3686 */ - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0xFF, 0x7A, 0x61, 0x7C, 0xE6, 0x91, 0x48, 0xE4, - 0xF1, 0x72, 0x6E, 0x2F, 0x43, 0x58, 0x1D, 0xE2, - 0xAA, 0x62, 0xD9, 0xF8, 0x05, 0x53, 0x2E, 0xDF, - 0xF1, 0xEE, 0xD6, 0x87, 0xFB, 0x54, 0x15, 0x3D}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0x00, 0x1C, 0xC5, 0xB7, 0x51, 0xA5, 0x1D, 0x70, - 0xA1, 0xC1, 0x11, 0x48, 0x00, 0x00, 0x00, 0x01 }, - .length = 36, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23 }, - .ciphertext = { 0xEB, 0x6C, 0x52, 0x82, 0x1D, 0x0B, 0xBB, 0xF7, - 0xCE, 0x75, 0x94, 0x46, 0x2A, 0xCA, 0x4F, 0xAA, - 0xB4, 0x07, 0xDF, 0x86, 0x65, 0x69, 0xFD, 0x07, - 0xF4, 0x8C, 0xC0, 0xB5, 0x83, 0xD6, 0x07, 0x1F, - 0x1E, 0xC0, 0xE6, 0xB8 }, - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, - 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, - 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, - 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, - .cipher_iv_length = AES_CTR_IV_LEN, - .cipher_iv = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5, - 0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28, - 0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a, - 0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5, - 0x2b, 0x09, 0x30, 0xda, 0xa2, 0x3d, 0xe9, 0x4c, - 0xe8, 0x70, 0x17, 0xba, 0x2d, 0x84, 0x98, 0x8d, - 0xdf, 0xc9, 0xc5, 0x8d, 0xb6, 0x7a, 0xad, 0xa6, - 0x13, 0xc2, 0xdd, 0x08, 0x45, 0x79, 0x41, 0xa6 } - }, -}; - -static crypto_test_reference_t aes_ecb_reference[] = { - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}, - .ciphertext = { 0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, - 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97, - 0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d, - 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf, - 0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23, - 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88, - 0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f, - 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4 } - }, - /* Generated by Crypto++ 5.6.1 (528 bytes) */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, - .length = 528, - .plaintext = { 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, - 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, - 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, - 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, - 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, - 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, - 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, - 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, - 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, - 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, - 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, - 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, - 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, - 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, - 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, - 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, - 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, - 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, - 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, - 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, - 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, - 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, - 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, - 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, - 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, - 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, - 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, - 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, - 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, - 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, - 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, - 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, - 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, - 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, - 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, - 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, - 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, - 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, - 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, - 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, - 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, - 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, - 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, - 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, - 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, - 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, - 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, - 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, - 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, 0xc1, 0xbe, - 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, - 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, - 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, - 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, - 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, - 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, - 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, - 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00, 0x00, 0x6b, - 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, - 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, - 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, - 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, - 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, - 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, - 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, - 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, 0x00}, - .ciphertext = { 0x84, 0xC6, 0xCB, 0xDC, 0x2B, 0x5A, 0x39, 0x98, - 0x57, 0x74, 0xB2, 0x3B, 0xAB, 0x06, 0x6A, 0x6A, - 0xF8, 0xCB, 0x66, 0xC0, 0x8E, 0x4F, 0x05, 0x8E, - 0x5D, 0x3E, 0x7C, 0x35, 0x1E, 0xA8, 0x45, 0xCE, - 0xC7, 0xB2, 0x09, 0x21, 0x0E, 0xE7, 0xEF, 0xD3, - 0x82, 0x69, 0x62, 0x86, 0x87, 0xF2, 0x1C, 0xB9, - 0xBC, 0xEA, 0x34, 0x9D, 0xC0, 0x41, 0x8A, 0xDB, - 0xA2, 0xBF, 0x23, 0x64, 0xDF, 0x4D, 0xB1, 0xA1, - 0x1A, 0xD8, 0x4C, 0xF6, 0xA4, 0x22, 0xCE, 0x95, - 0xC3, 0x7B, 0x2C, 0xF8, 0x11, 0x96, 0x24, 0x5C, - 0xD8, 0x57, 0xD0, 0xB9, 0x54, 0xB8, 0x39, 0x85, - 0xC1, 0x88, 0x82, 0x30, 0xF3, 0xC3, 0x01, 0x84, - 0x7A, 0xAF, 0x71, 0x42, 0x53, 0xEF, 0x76, 0x8C, - 0x17, 0xE8, 0x9E, 0x4F, 0x55, 0x13, 0xDB, 0xD5, - 0xBE, 0xE1, 0x26, 0x6A, 0x2B, 0x2D, 0x70, 0x63, - 0xCE, 0x3D, 0x0B, 0xA8, 0x71, 0x62, 0x52, 0xC5, - 0xBC, 0xBB, 0x99, 0x22, 0xCD, 0x46, 0xF3, 0x74, - 0xB5, 0x2F, 0xDF, 0xF1, 0xFE, 0xBF, 0x15, 0x5F, - 0xF4, 0xAF, 0xEE, 0x18, 0x78, 0x89, 0x99, 0xBC, - 0x74, 0x23, 0x4A, 0x3F, 0xFB, 0xA7, 0xB2, 0x85, - 0x8B, 0xB2, 0x55, 0x2F, 0x17, 0x2E, 0x56, 0xEC, - 0x47, 0x45, 0x68, 0x78, 0x44, 0x0A, 0xBB, 0x5A, - 0xDA, 0xE4, 0x99, 0x41, 0xC1, 0xE4, 0x36, 0x16, - 0xAC, 0x5D, 0x6E, 0x31, 0xA0, 0x11, 0x61, 0x1B, - 0x82, 0x9F, 0x6A, 0x77, 0xBE, 0x1F, 0x50, 0x75, - 0x4F, 0x81, 0xF3, 0x5D, 0x24, 0xED, 0x89, 0xFD, - 0xE8, 0x04, 0xB1, 0x73, 0x63, 0xF9, 0xA8, 0x1C, - 0x3F, 0x12, 0xAE, 0x06, 0x7F, 0xDD, 0x41, 0xA2, - 0x98, 0x49, 0x12, 0xCA, 0xE1, 0x92, 0x6C, 0x5F, - 0xB3, 0xAC, 0x18, 0xE5, 0x41, 0xFA, 0x4A, 0xD1, - 0xE1, 0x71, 0x88, 0x8E, 0x61, 0x42, 0x8F, 0x2A, - 0x8F, 0x2E, 0x98, 0x1A, 0xE1, 0x6D, 0x0D, 0x4E, - 0x41, 0xD3, 0x3E, 0x5E, 0x67, 0x5F, 0x44, 0x6D, - 0xAE, 0x0F, 0x45, 0x4F, 0xC4, 0xCA, 0x05, 0x6F, - 0x41, 0xF3, 0xCC, 0x47, 0x44, 0xA9, 0xE9, 0x48, - 0x42, 0x8B, 0x22, 0x80, 0xF9, 0x66, 0x63, 0xB7, - 0x23, 0x0C, 0x09, 0x69, 0x25, 0x03, 0xC9, 0x5B, - 0x3E, 0x34, 0xF8, 0xDE, 0x8D, 0xF2, 0x31, 0x57, - 0xF4, 0x5B, 0xDF, 0x68, 0x9B, 0x25, 0x8D, 0x99, - 0x4D, 0x9E, 0x6C, 0xE5, 0xD4, 0xDD, 0x6B, 0xDB, - 0x96, 0x76, 0x3C, 0xCC, 0x41, 0xDB, 0xBE, 0x57, - 0xA4, 0x77, 0x8D, 0x5A, 0x9E, 0x90, 0x22, 0x6D, - 0x61, 0x4C, 0x33, 0x5E, 0x44, 0xCA, 0x8A, 0xB4, - 0x1E, 0xFE, 0xA8, 0x98, 0xBC, 0x17, 0x0C, 0x65, - 0x41, 0x2F, 0x77, 0x19, 0x4A, 0x43, 0xA1, 0x30, - 0x5E, 0xF2, 0x3A, 0xC7, 0x0B, 0x05, 0x9E, 0x6E, - 0x04, 0x77, 0x96, 0xEF, 0x51, 0x8D, 0x76, 0x96, - 0xBC, 0x3D, 0xAD, 0x5E, 0x26, 0x34, 0xF9, 0x2D, - 0xD1, 0xC9, 0x0D, 0x20, 0x6A, 0x2B, 0x6D, 0x3A, - 0x7C, 0xE8, 0x86, 0x68, 0xBE, 0xAD, 0x64, 0x61, - 0x4E, 0x90, 0x00, 0xAC, 0xFB, 0xA7, 0x9E, 0xB3, - 0x60, 0x16, 0x06, 0x21, 0x4E, 0x21, 0xE0, 0x8F, - 0x14, 0xCE, 0x77, 0xE3, 0x6B, 0xB6, 0x6F, 0xE4, - 0xA0, 0xFC, 0xD2, 0xA2, 0x1B, 0xCA, 0xA2, 0x39, - 0x1A, 0x9C, 0x20, 0x16, 0xAC, 0x3B, 0xC7, 0xCD, - 0xF1, 0x43, 0x8E, 0xB6, 0xDD, 0x26, 0x69, 0x66, - 0x44, 0x58, 0x3E, 0x2B, 0x0A, 0x0C, 0x68, 0x62, - 0x9D, 0x73, 0x6F, 0x67, 0x23, 0xDF, 0x66, 0x85, - 0x9C, 0xF8, 0x0B, 0x4E, 0x5B, 0x5C, 0x5B, 0xF0, - 0x3F, 0x33, 0x4D, 0x65, 0xC4, 0x8D, 0xB3, 0xB2, - 0x66, 0x0E, 0x2C, 0xE3, 0x3B, 0x51, 0x0F, 0xD6, - 0x0C, 0x91, 0x2B, 0x85, 0xD1, 0x6A, 0xEE, 0x7C, - 0xDB, 0xFD, 0xF6, 0x28, 0x5B, 0x0A, 0x77, 0xBA, - 0xE0, 0x7D, 0x98, 0x7F, 0x9C, 0xE1, 0x72, 0xA5, - 0x48, 0xE6, 0xBF, 0x0A, 0x30, 0xCF, 0x09, 0x9A, - 0xA8, 0x2B, 0xE0, 0xA2, 0x5E, 0x0E, 0x89, 0x19 } - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, - 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, - 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f, - 0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc, - 0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad, - 0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef, - 0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a, - 0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e, - 0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72, - 0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e } - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, - 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, - 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, - 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c, - 0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8, - 0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26, - 0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70, - 0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9, - 0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d, - 0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff, - 0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7} - } -}; - -static crypto_test_reference_t aes_cfb128_reference[] = { - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}, - .cipher_iv_length = AES_CFB128_IV_LEN, - .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}, - .ciphertext = { 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, - 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, - 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f, - 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b, - 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40, - 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf, - 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e, - 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6 } - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, - 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, - 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b}, - .cipher_iv_length = AES_CFB128_IV_LEN, - .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, - 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, - 0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21, - 0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a, - 0x2e, 0x1e, 0x8a, 0x1d, 0xd5, 0x9b, 0x88, 0xb1, - 0xc8, 0xe6, 0x0f, 0xed, 0x1e, 0xfa, 0xc4, 0xc9, - 0xc0, 0x5f, 0x9f, 0x9c, 0xa9, 0x83, 0x4f, 0xa0, - 0x42, 0xae, 0x8f, 0xba, 0x58, 0x4b, 0x09, 0xff } - }, - /* NIST Special Publication 800-38A */ - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, - 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, - 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, - 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}, - .cipher_iv_length = AES_CFB128_IV_LEN, - .cipher_iv = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 64, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, - 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, - 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, - 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, - 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, - 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, - 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }, - .ciphertext = { 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, - 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, - 0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8, - 0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b, - 0xdf, 0x10, 0x13, 0x24, 0x15, 0xe5, 0x4b, 0x92, - 0xa1, 0x3e, 0xd0, 0xa8, 0x26, 0x7a, 0xe2, 0xf9, - 0x75, 0xa3, 0x85, 0x74, 0x1a, 0xb9, 0xce, 0xf8, - 0x20, 0x31, 0x62, 0x3d, 0x55, 0xb1, 0xe4, 0x71 } - } -}; - -static crypto_test_reference_t aes_xts_reference[] = { - /* CAVS 11.0 XTSGen information, #1 */ - { - .cipher_key_length = AES128_XTS_KEY_LEN, - .cipher_key = { 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35, - 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62, - 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18, - 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6, - 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5}, - .length = 16, - .plaintext = { 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d, - 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c}, - .ciphertext = { 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a, - 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63} - }, - /* CAVS 11.0 XTSGen information, #101 */ - { - .cipher_key_length = AES128_XTS_KEY_LEN, - .cipher_key = { 0xb7, 0xb9, 0x3f, 0x51, 0x6a, 0xef, 0x29, 0x5e, - 0xff, 0x3a, 0x29, 0xd8, 0x37, 0xcf, 0x1f, 0x13, - 0x53, 0x47, 0xe8, 0xa2, 0x1d, 0xae, 0x61, 0x6f, - 0xf5, 0x06, 0x2b, 0x2e, 0x8d, 0x78, 0xce, 0x5e}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0x87, 0x3e, 0xde, 0xa6, 0x53, 0xb6, 0x43, 0xbd, - 0x8b, 0xcf, 0x51, 0x40, 0x31, 0x97, 0xed, 0x14}, - .length = 32, - .plaintext = { 0x23, 0x6f, 0x8a, 0x5b, 0x58, 0xdd, 0x55, 0xf6, - 0x19, 0x4e, 0xd7, 0x0c, 0x4a, 0xc1, 0xa1, 0x7f, - 0x1f, 0xe6, 0x0e, 0xc9, 0xa6, 0xc4, 0x54, 0xd0, - 0x87, 0xcc, 0xb7, 0x7d, 0x6b, 0x63, 0x8c, 0x47}, - .ciphertext = { 0x22, 0xe6, 0xa3, 0xc6, 0x37, 0x9d, 0xcf, 0x75, - 0x99, 0xb0, 0x52, 0xb5, 0xa7, 0x49, 0xc7, 0xf7, - 0x8a, 0xd8, 0xa1, 0x1b, 0x9f, 0x1a, 0xa9, 0x43, - 0x0c, 0xf3, 0xae, 0xf4, 0x45, 0x68, 0x2e, 0x19} - }, - /* CAVS 11.0 XTSGen information, #227 TODO (Length 130 bits)*/ - /* { - .cipher_key_length = AES128_XTS_KEY_LEN, - .cipher_key = { 0xec, 0x14, 0xc0, 0xa3, 0xb7, 0x72, 0x58, 0x5c, - 0x15, 0xd4, 0xeb, 0x94, 0xe6, 0x9e, 0x2c, 0x55, - 0x80, 0xcf, 0x3a, 0x63, 0xc1, 0x7c, 0xe9, 0xda, - 0xd8, 0x2b, 0xb4, 0x54, 0xe3, 0x87, 0x90, 0x45}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0x4a, 0x02, 0x87, 0xc2, 0x6e, 0xd2, 0x41, 0x26, - 0x5b, 0x3a, 0x42, 0xcd, 0xd1, 0x9c, 0xea, 0xe2}, - .length = 17, - .plaintext = { 0x50, 0x82, 0x64, 0x75, 0x82, 0xc6, 0xe5, 0xa7, - 0x88, 0x73, 0x6f, 0xc5, 0x90, 0x5e, 0xa5, 0x65, - 0xc0 }, - .ciphertext = { 0x04, 0x3a, 0xb9, 0xc0, 0x3d, 0x5b, 0x44, 0x13, - 0x1d, 0x3e, 0x6e, 0xb2, 0x57, 0x61, 0x89, 0xde, - 0x80 }, - }, */ - /* CAVS 11.0 XTSGen information, #1 */ - { - .cipher_key_length = AES256_XTS_KEY_LEN, - .cipher_key = { 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e, - 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14, - 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7, - 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c, - 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d, - 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3, - 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58, - 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2, - 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64}, - .length = 32, - .plaintext = { 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1, - 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64, - 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3, - 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e}, - .ciphertext = { 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5, - 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13, - 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a, - 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb}, - }, - /* CAVS 11.0 XTSGen information, #110 */ - { - .cipher_key_length = AES256_XTS_KEY_LEN, - .cipher_key = { 0x6b, 0x19, 0x84, 0xc2, 0x4e, 0x7e, 0xb6, 0x62, - 0x8e, 0x3a, 0x11, 0xc9, 0xcc, 0xd2, 0x59, 0x40, - 0x33, 0xa3, 0xa0, 0xd9, 0x01, 0x6e, 0xae, 0x65, - 0xc2, 0xf2, 0x4e, 0x09, 0xb9, 0xa6, 0x6e, 0x9f, - 0xe9, 0xd1, 0x63, 0xa5, 0x06, 0xdf, 0xbc, 0xcf, - 0x2d, 0x93, 0xe8, 0x99, 0x1e, 0x2f, 0xc5, 0x60, - 0xe1, 0x04, 0x35, 0xb8, 0x90, 0xb5, 0x88, 0x9a, - 0x50, 0x03, 0xe4, 0xbf, 0x81, 0x7d, 0xc3, 0xe0}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0x6b, 0xb0, 0xd3, 0xae, 0x4f, 0xa8, 0x6e, 0x43, - 0x16, 0x19, 0xe4, 0x07, 0xd5, 0x9a, 0xd4, 0xf4}, - .length = 48, - .plaintext = { 0x6a, 0x74, 0x1a, 0x94, 0x5b, 0xfb, 0xf0, 0xc6, - 0x7a, 0xfd, 0x43, 0xba, 0x1f, 0x84, 0x18, 0x16, - 0xc0, 0x99, 0x51, 0x58, 0x05, 0xd0, 0xfc, 0x1f, - 0x7d, 0xbf, 0x6d, 0xe9, 0x00, 0xe0, 0xaa, 0x7a, - 0x21, 0x9c, 0x88, 0x56, 0x32, 0x71, 0xb0, 0x09, - 0xd1, 0xac, 0x90, 0xeb, 0x7d, 0xc9, 0x97, 0x35}, - .ciphertext = { 0xe4, 0x7b, 0xce, 0x29, 0x2b, 0xaa, 0x63, 0xbe, - 0xf3, 0x16, 0xf6, 0x80, 0xa5, 0xf4, 0x80, 0xa7, - 0xb8, 0x83, 0xdf, 0xab, 0x6e, 0xd5, 0xa5, 0x7f, - 0x7e, 0x29, 0xec, 0xb8, 0x9e, 0x35, 0x4a, 0x31, - 0xc9, 0xb1, 0x74, 0xc4, 0xab, 0xad, 0x6c, 0xba, - 0xba, 0xba, 0x19, 0x14, 0x0c, 0x46, 0x20, 0xa3}, - }, - /* CAVS 11.0 XTSGen information, #211 TODO: length 140 bits */ - /* { - .cipher_key_length = AES256_XTS_KEY_LEN, - .cipher_key = { 0x62, 0xc2, 0xe4, 0xf8, 0x52, 0xa9, 0x3e, 0xea, - 0x4a, 0x2f, 0x61, 0xe8, 0x67, 0x68, 0x14, 0xf4, - 0xa8, 0x0d, 0xc4, 0x7e, 0xe1, 0x81, 0x32, 0xc8, - 0x38, 0xbf, 0x89, 0xa6, 0x18, 0xfd, 0xb8, 0xe2, - 0x91, 0x3e, 0x2e, 0x5c, 0x32, 0x1b, 0x19, 0xea, - 0x04, 0xbb, 0xa6, 0x34, 0x7d, 0x22, 0x6f, 0x41, - 0xdb, 0xee, 0x88, 0x0d, 0x61, 0x67, 0xb8, 0xe1, - 0xe9, 0x17, 0xfa, 0xf0, 0x46, 0xf0, 0x87, 0x5e}, - .cipher_iv_length = AES_XTS_IV_LEN, - .cipher_iv = { 0x53, 0x7e, 0xe3, 0xdc, 0x13, 0xce, 0x27, 0xa8, - 0xd3, 0x0e, 0x6e, 0x42, 0xb5, 0xb9, 0x96, 0xae}, - .length = 18, - .plaintext = { 0x00, 0xc9, 0xeb, 0x87, 0x78, 0xe0, 0x3d, 0xdd, - 0x5f, 0x3d, 0xe8, 0xc1, 0x8b, 0x34, 0x8f, 0xac, - 0x9c, 0x30}, - .ciphertext = { 0x9d, 0x4a, 0x08, 0xac, 0x0f, 0xb4, 0x4e, 0x90, - 0xd0, 0x5f, 0x62, 0x86, 0x19, 0x3f, 0x3a, 0xab, - 0xc2, 0x90}, - } */ -}; - -/* AES-GCM test vectors extracted from - * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2 - */ -static crypto_test_reference_t aes_gcm_reference[] = { - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, - 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e, - 0x3b, 0x24, 0x4c, 0xfe }, - .length = 72, - .plaintext = { 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00, - 0x80, 0x11, 0x4d, 0xb7, 0xc0, 0xa8, 0x01, 0x02, - 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x9b, 0xf1, 0x56, - 0x38, 0xd3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x5f, 0x73, 0x69, - 0x70, 0x04, 0x5f, 0x75, 0x64, 0x70, 0x03, 0x73, - 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, 0x65, 0x72, - 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00, - 0x00, 0x21, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01 }, - .ciphertext = { 0xfe, 0xcf, 0x53, 0x7e, 0x72, 0x9d, 0x5b, 0x07, - 0xdc, 0x30, 0xdf, 0x52, 0x8d, 0xd2, 0x2b, 0x76, - 0x8d, 0x1b, 0x98, 0x73, 0x66, 0x96, 0xa6, 0xfd, - 0x34, 0x85, 0x09, 0xfa, 0x13, 0xce, 0xac, 0x34, - 0xcf, 0xa2, 0x43, 0x6f, 0x14, 0xa3, 0xf3, 0xcf, - 0x65, 0x92, 0x5b, 0xf1, 0xf4, 0xa1, 0x3c, 0x5d, - 0x15, 0xb2, 0x1e, 0x18, 0x84, 0xf5, 0xff, 0x62, - 0x47, 0xae, 0xab, 0xb7, 0x86, 0xb9, 0x3b, 0xce, - 0x61, 0xbc, 0x17, 0xd7, 0x68, 0xfd, 0x97, 0x32}, - .aad_length = 12, - .aad = { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, - 0x00, 0x00, 0x00, 0x00 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, - 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, - 0xde, 0xca, 0xf8, 0x88 }, - .length = 64, - .plaintext = { 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00, - 0x80, 0x11, 0x4d, 0xcc, 0xc0, 0xa8, 0x01, 0x02, - 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x98, 0x00, 0x35, - 0x00, 0x2a, 0x23, 0x43, 0xb2, 0xd0, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x73, 0x69, 0x70, 0x09, 0x63, 0x79, 0x62, - 0x65, 0x72, 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, - 0x6b, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }, - .ciphertext = { 0xde, 0xb2, 0x2c, 0xd9, 0xb0, 0x7c, 0x72, 0xc1, - 0x6e, 0x3a, 0x65, 0xbe, 0xeb, 0x8d, 0xf3, 0x04, - 0xa5, 0xa5, 0x89, 0x7d, 0x33, 0xae, 0x53, 0x0f, - 0x1b, 0xa7, 0x6d, 0x5d, 0x11, 0x4d, 0x2a, 0x5c, - 0x3d, 0xe8, 0x18, 0x27, 0xc1, 0x0e, 0x9a, 0x4f, - 0x51, 0x33, 0x0d, 0x0e, 0xec, 0x41, 0x66, 0x42, - 0xcf, 0xbb, 0x85, 0xa5, 0xb4, 0x7e, 0x48, 0xa4, - 0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1}, - .aad_length = 8, - .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, - 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, - .length = 64, - .plaintext = { 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00, - 0x80, 0x01, 0xcb, 0x7a, 0x40, 0x67, 0x93, 0x18, - 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x07, 0x5c, - 0x02, 0x00, 0x44, 0x00, 0x61, 0x62, 0x63, 0x64, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, - 0x66, 0x67, 0x68, 0x69, 0x01, 0x02, 0x02, 0x01 }, - .ciphertext = { 0x46, 0x88, 0xda, 0xf2, 0xf9, 0x73, 0xa3, 0x92, - 0x73, 0x29, 0x09, 0xc3, 0x31, 0xd5, 0x6d, 0x60, - 0xf6, 0x94, 0xab, 0xaa, 0x41, 0x4b, 0x5e, 0x7f, - 0xf5, 0xfd, 0xcd, 0xff, 0xf5, 0xe9, 0xa2, 0x84, - 0x45, 0x64, 0x76, 0x49, 0x27, 0x19, 0xff, 0xb6, - 0x4d, 0xe7, 0xd9, 0xdc, 0xa1, 0xe1, 0xd8, 0x94, - 0xbc, 0x3b, 0xd5, 0x78, 0x73, 0xed, 0x4d, 0x18, - 0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3}, - .aad_length = 8, - .aad = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, - 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, - 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, - 0xa2, 0xfc, 0xa1, 0xa3 }, - .length = 28, - .plaintext = { 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, - 0x80, 0x01, 0x44, 0x1f, 0x40, 0x67, 0x93, 0xb6, - 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff, - 0x01, 0x02, 0x02, 0x01 }, - .ciphertext = { 0xfb, 0xa2, 0xca, 0x84, 0x5e, 0x5d, 0xf9, 0xf0, - 0xf2, 0x2c, 0x3e, 0x6e, 0x86, 0xdd, 0x83, 0x1e, - 0x1f, 0xc6, 0x57, 0x92, 0xcd, 0x1a, 0xf9, 0x13, - 0x0e, 0x13, 0x79, 0xed }, - .aad_length = 12, - .aad = { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe, - 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 } - }, - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, - 0xde, 0xca, 0xf8, 0x88 }, - .length = 40, - .plaintext = { 0x45, 0x00, 0x00, 0x28, 0xa4, 0xad, 0x40, 0x00, - 0x40, 0x06, 0x78, 0x80, 0x0a, 0x01, 0x03, 0x8f, - 0x0a, 0x01, 0x06, 0x12, 0x80, 0x23, 0x06, 0xb8, - 0xcb, 0x71, 0x26, 0x02, 0xdd, 0x6b, 0xb0, 0x3e, - 0x50, 0x10, 0x16, 0xd0, 0x75, 0x68, 0x00, 0x01 }, - .ciphertext = { 0xa5, 0xb1, 0xf8, 0x06, 0x60, 0x29, 0xae, 0xa4, - 0x0e, 0x59, 0x8b, 0x81, 0x22, 0xde, 0x02, 0x42, - 0x09, 0x38, 0xb3, 0xab, 0x33, 0xf8, 0x28, 0xe6, - 0x87, 0xb8, 0x85, 0x8b, 0x5b, 0xfb, 0xdb, 0xd0, - 0x31, 0x5b, 0x27, 0x45, 0x21, 0x44, 0xcc, 0x77}, - .aad_length = 8, - .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0x95, 0x45, 0x7b, 0x96, 0x52, 0x03, 0x7f, 0x53, - 0x18, 0x02, 0x7b, 0x5b, 0x4c, 0xd7, 0xa6, 0x36 } - }, - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, - 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab, - 0xab, 0xbc, 0xcd, 0xde, 0xf0, 0x01, 0x12, 0x23, - 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x9a, 0xab}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0x11, 0x22, 0x33, 0x44, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08 }, - .length = 52, - .plaintext = { 0x45, 0x00, 0x00, 0x30, 0x69, 0xa6, 0x40, 0x00, - 0x80, 0x06, 0x26, 0x90, 0xc0, 0xa8, 0x01, 0x02, - 0x93, 0x89, 0x15, 0x5e, 0x0a, 0x9e, 0x00, 0x8b, - 0x2d, 0xc5, 0x7e, 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x02, 0x40, 0x00, 0x20, 0xbf, 0x00, 0x00, - 0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02, - 0x01, 0x02, 0x02, 0x01 }, - .ciphertext = { 0xff, 0x42, 0x5c, 0x9b, 0x72, 0x45, 0x99, 0xdf, - 0x7a, 0x3b, 0xcd, 0x51, 0x01, 0x94, 0xe0, 0x0d, - 0x6a, 0x78, 0x10, 0x7f, 0x1b, 0x0b, 0x1c, 0xbf, - 0x06, 0xef, 0xae, 0x9d, 0x65, 0xa5, 0xd7, 0x63, - 0x74, 0x8a, 0x63, 0x79, 0x85, 0x77, 0x1d, 0x34, - 0x7f, 0x05, 0x45, 0x65, 0x9f, 0x14, 0xe9, 0x9d, - 0xef, 0x84, 0x2d, 0x8e }, - .aad_length = 8, - .aad = { 0x4a, 0x2c, 0xbf, 0xe3, 0x00, 0x00, 0x00, 0x02 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0xb3, 0x35, 0xf4, 0xee, 0xcf, 0xdb, 0xf8, 0x31, - 0x82, 0x4b, 0x4c, 0x49, 0x15, 0x95, 0x6c, 0x96 } - } -}; - -static crypto_test_reference_t aes_ccm_reference[] = { - /* - * AES-CCM reference from RFC 3610 - */ - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf}, - .cipher_iv_length = 13, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0x58, 0x8c, 0x97, 0x9a, 0x61, 0xc6, 0x63, 0xd2, - 0xf0, 0x66, 0xd0, 0xc2, 0xc0, 0xf9, 0x89, 0x80, - 0x6d, 0x5f, 0x6b, 0x61, 0xda, 0xc3, 0x84 }, - .digest_length = 8, - .digest = { 0x17, 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0 } - }, - /* The rest of test vectors are generated manually, no "interesting" - * vectors for use cases in RFC 3610 or SP 800-38C. */ - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7}, - .cipher_iv_length = 13, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0x57, 0x9f, 0xb8, 0x6e, 0xdd, 0xb4, 0xa6, 0x4a, - 0xae, 0x5f, 0xe9, 0x6d, 0xbd, 0x75, 0x44, 0x05, - 0x33, 0xa9, 0xfc, 0x3a, 0x84, 0x57, 0x36 }, - .digest_length = 8, - .digest = { 0x67, 0xae, 0xc8, 0x0a, 0xc5, 0x88, 0xab, 0x16 } - }, - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf}, - .cipher_iv_length = 13, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3, 0xa4, 0xa5 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0x59, 0x61, 0x55, 0x10, 0xa7, 0xc4, 0x3b, 0xfb, - 0x12, 0x3d, 0x63, 0x6b, 0x46, 0x13, 0xc0, 0x3c, - 0x6c, 0xe2, 0x69, 0x07, 0x10, 0x2a, 0x3f }, - .digest_length = 8, - .digest = { 0xb5, 0x57, 0x2a, 0x17, 0x2d, 0x49, 0x16, 0xd5 } - }, - { - .cipher_key_length = AES128_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf}, - .cipher_iv_length = 11, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0xaa, 0x2d, 0x3e, 0xcb, 0xa6, 0x68, 0x63, 0x75, - 0x8f, 0x03, 0x01, 0x51, 0x16, 0xde, 0x30, 0xed, - 0x8a, 0xb5, 0x42, 0xdc, 0xfa, 0x72, 0xd0 }, - .digest_length = 8, - .digest = { 0x63, 0xe7, 0x01, 0x5c, 0x69, 0xaf, 0xb4, 0x0c } - }, - { - .cipher_key_length = AES192_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7}, - .cipher_iv_length = 11, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0xee, 0x99, 0x99, 0x1e, 0xc5, 0x8f, 0xd7, 0x7e, - 0x56, 0x71, 0x16, 0x39, 0x8e, 0xc4, 0x4f, 0xcc, - 0x14, 0x45, 0x57, 0x3e, 0x38, 0x76, 0x51 }, - .digest_length = 8, - .digest = { 0x31, 0x29, 0x47, 0xa4, 0x6d, 0x76, 0x34, 0xb4 } - }, - { - .cipher_key_length = AES256_KEY_LEN, - .cipher_key = { 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf}, - .cipher_iv_length = 11, - .cipher_iv = { 0x00, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0xa0, - 0xa1, 0xa2, 0xa3 }, - .aad_length = 8, - .aad = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }, - .length = 23, - .plaintext = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e }, - .ciphertext = { 0xfa, 0x07, 0x47, 0x5c, 0xe8, 0xc9, 0x37, 0x88, - 0x54, 0x64, 0xb8, 0xc3, 0x85, 0xbb, 0x76, 0x0b, - 0xf2, 0xc2, 0x4c, 0x4e, 0x31, 0x16, 0x77 }, - .digest_length = 8, - .digest = { 0x88, 0x56, 0x7e, 0x19, 0x84, 0x13, 0x29, 0xc4 } - }, -}; - -static crypto_test_reference_t aes_gmac_reference[] = { - { - .auth_key_length = AES128_KEY_LEN, - .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, - 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, - .auth_iv_length = AES_GCM_IV_LEN, - .auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, - .length = 68, - .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, - 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, - 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, - 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x01, 0x02, 0x02, 0x01 }, - .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, - 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, - 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, - 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x01, 0x02, 0x02, 0x01 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, 0x6a, - 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa } - }, - /* AES192-GMAC from DPDK 17.02 */ - { - .auth_key_length = AES192_KEY_LEN, - .auth_key = { 0xaa, 0x74, 0x0a, 0xbf, 0xad, 0xcd, 0xa7, 0x79, - 0x22, 0x0d, 0x3b, 0x40, 0x6c, 0x5d, 0x7e, 0xc0, - 0x9a, 0x77, 0xfe, 0x9d, 0x94, 0x10, 0x45, 0x39}, - .auth_iv_length = AES_GCM_IV_LEN, - .auth_iv = { 0xab, 0x22, 0x65, 0xb4, 0xc1, 0x68, 0x95, 0x55, - 0x61, 0xf0, 0x43, 0x15 }, - .length = 80, - .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}, - .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0xCF, 0x82, 0x80, 0x64, 0x02, 0x46, 0xF4, 0xFB, - 0x33, 0xAE, 0x1D, 0x90, 0xEA, 0x48, 0x83, 0xDB }, - }, - /* AES256-GMAC from DPDK 17.02 */ - { - .auth_key_length = AES256_KEY_LEN, - .auth_key = { 0xb5, 0x48, 0xe4, 0x93, 0x4f, 0x5c, 0x64, 0xd3, - 0xc0, 0xf0, 0xb7, 0x8f, 0x7b, 0x4d, 0x88, 0x24, - 0xaa, 0xc4, 0x6b, 0x3c, 0x8d, 0x2c, 0xc3, 0x5e, - 0xe4, 0xbf, 0xb2, 0x54, 0xe4, 0xfc, 0xba, 0xf7}, - .auth_iv_length = AES_GCM_IV_LEN, - .auth_iv = { 0x2e, 0xed, 0xe1, 0xdc, 0x64, 0x47, 0xc7, 0xaf, - 0xc4, 0x41, 0x53, 0x58 }, - .length = 65, - .plaintext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02 }, - .ciphertext = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - 0x01, 0x02 }, - .digest_length = AES_GCM_DIGEST_LEN, - .digest = { 0x77, 0x46, 0x0D, 0x6F, 0xB1, 0x87, 0xDB, 0xA9, - 0x46, 0xAD, 0xCD, 0xFB, 0xB7, 0xF9, 0x13, 0xA1 }, - } -}; - -/* - * Test vectors from SP800-38B / CSRC examples - * 12-byte vectors are just truncated 16-byte vectors - */ -static crypto_test_reference_t aes_cmac_reference[] = { - { - .auth_key_length = AES128_KEY_LEN, - .auth_key = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }, - .length = 16, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, - .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a - }, - .digest_length = 16, - .digest = { 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44, - 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c }, - }, - { - .copy_previous_vector = 1, - .digest_length = 12, - }, - { - .auth_key_length = AES192_KEY_LEN, - .auth_key = { 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, - 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, - 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b }, - .length = 16, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, - .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a - }, - .digest_length = 16, - .digest = { 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, - 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84 }, - }, - { - .copy_previous_vector = 1, - .digest_length = 12, - }, - { - .auth_key_length = AES256_KEY_LEN, - .auth_key = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, - 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, - 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, - 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 }, - .length = 16, - .plaintext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a}, - .ciphertext = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, - 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a - }, - .digest_length = 16, - .digest = { 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, - 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c }, - }, - { - .copy_previous_vector = 1, - .digest_length = 12, - }, -}; - -/* - * Test vector from RFC 7539, sections 2.8.2, A.5 - */ -static crypto_test_reference_t chacha20_poly1305_reference[] = { - { - .cipher_key_length = CHACHA20_POLY1305_KEY_LEN, - .cipher_key = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f}, - .cipher_iv_length = CHACHA20_POLY1305_IV_LEN, - .cipher_iv = { 0x07, 0x00, 0x00, 0x00, 0x40, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47 }, - .length = 114, - .plaintext = { 0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c, - 0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20, - 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73, - 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39, - 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63, - 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66, - 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f, - 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20, - 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20, - 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75, - 0x72, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x6e, 0x73, - 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, - 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, - 0x74, 0x2e }, - .ciphertext = { 0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb, - 0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2, - 0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe, - 0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6, - 0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12, - 0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b, - 0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29, - 0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36, - 0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c, - 0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58, - 0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94, - 0x55, 0x85, 0x80, 0x8b, 0x48, 0x31, 0xd7, 0xbc, - 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d, - 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b, - 0x61, 0x16 }, - .aad_length = 12, - .aad = { 0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, - 0xc5, 0xc6, 0xc7 }, - .digest_length = 16, - .digest = { 0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a, - 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91 } - }, - { - .cipher_key_length = CHACHA20_POLY1305_KEY_LEN, - .cipher_key = { 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, - 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, - 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, - 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0}, - .cipher_iv_length = CHACHA20_POLY1305_IV_LEN, - .cipher_iv = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08 }, - .length = 265, - .plaintext = { 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x73, 0x20, - 0x61, 0x72, 0x65, 0x20, 0x64, 0x72, 0x61, 0x66, - 0x74, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x20, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, - 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x20, - 0x6f, 0x66, 0x20, 0x73, 0x69, 0x78, 0x20, 0x6d, - 0x6f, 0x6e, 0x74, 0x68, 0x73, 0x20, 0x61, 0x6e, - 0x64, 0x20, 0x6d, 0x61, 0x79, 0x20, 0x62, 0x65, - 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, - 0x2c, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, - 0x65, 0x64, 0x2c, 0x20, 0x6f, 0x72, 0x20, 0x6f, - 0x62, 0x73, 0x6f, 0x6c, 0x65, 0x74, 0x65, 0x64, - 0x20, 0x62, 0x79, 0x20, 0x6f, 0x74, 0x68, 0x65, - 0x72, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x20, 0x61, 0x74, 0x20, 0x61, - 0x6e, 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x2e, - 0x20, 0x49, 0x74, 0x20, 0x69, 0x73, 0x20, 0x69, - 0x6e, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x70, 0x72, - 0x69, 0x61, 0x74, 0x65, 0x20, 0x74, 0x6f, 0x20, - 0x75, 0x73, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61, - 0x66, 0x74, 0x73, 0x20, 0x61, 0x73, 0x20, 0x72, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, - 0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x20, - 0x63, 0x69, 0x74, 0x65, 0x20, 0x74, 0x68, 0x65, - 0x6d, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x20, - 0x74, 0x68, 0x61, 0x6e, 0x20, 0x61, 0x73, 0x20, - 0x2f, 0xe2, 0x80, 0x9c, 0x77, 0x6f, 0x72, 0x6b, - 0x20, 0x69, 0x6e, 0x20, 0x70, 0x72, 0x6f, 0x67, - 0x72, 0x65, 0x73, 0x73, 0x2e, 0x2f, 0xe2, 0x80, - 0x9d }, - .ciphertext = { 0x64, 0xa0, 0x86, 0x15, 0x75, 0x86, 0x1a, 0xf4, - 0x60, 0xf0, 0x62, 0xc7, 0x9b, 0xe6, 0x43, 0xbd, - 0x5e, 0x80, 0x5c, 0xfd, 0x34, 0x5c, 0xf3, 0x89, - 0xf1, 0x08, 0x67, 0x0a, 0xc7, 0x6c, 0x8c, 0xb2, - 0x4c, 0x6c, 0xfc, 0x18, 0x75, 0x5d, 0x43, 0xee, - 0xa0, 0x9e, 0xe9, 0x4e, 0x38, 0x2d, 0x26, 0xb0, - 0xbd, 0xb7, 0xb7, 0x3c, 0x32, 0x1b, 0x01, 0x00, - 0xd4, 0xf0, 0x3b, 0x7f, 0x35, 0x58, 0x94, 0xcf, - 0x33, 0x2f, 0x83, 0x0e, 0x71, 0x0b, 0x97, 0xce, - 0x98, 0xc8, 0xa8, 0x4a, 0xbd, 0x0b, 0x94, 0x81, - 0x14, 0xad, 0x17, 0x6e, 0x00, 0x8d, 0x33, 0xbd, - 0x60, 0xf9, 0x82, 0xb1, 0xff, 0x37, 0xc8, 0x55, - 0x97, 0x97, 0xa0, 0x6e, 0xf4, 0xf0, 0xef, 0x61, - 0xc1, 0x86, 0x32, 0x4e, 0x2b, 0x35, 0x06, 0x38, - 0x36, 0x06, 0x90, 0x7b, 0x6a, 0x7c, 0x02, 0xb0, - 0xf9, 0xf6, 0x15, 0x7b, 0x53, 0xc8, 0x67, 0xe4, - 0xb9, 0x16, 0x6c, 0x76, 0x7b, 0x80, 0x4d, 0x46, - 0xa5, 0x9b, 0x52, 0x16, 0xcd, 0xe7, 0xa4, 0xe9, - 0x90, 0x40, 0xc5, 0xa4, 0x04, 0x33, 0x22, 0x5e, - 0xe2, 0x82, 0xa1, 0xb0, 0xa0, 0x6c, 0x52, 0x3e, - 0xaf, 0x45, 0x34, 0xd7, 0xf8, 0x3f, 0xa1, 0x15, - 0x5b, 0x00, 0x47, 0x71, 0x8c, 0xbc, 0x54, 0x6a, - 0x0d, 0x07, 0x2b, 0x04, 0xb3, 0x56, 0x4e, 0xea, - 0x1b, 0x42, 0x22, 0x73, 0xf5, 0x48, 0x27, 0x1a, - 0x0b, 0xb2, 0x31, 0x60, 0x53, 0xfa, 0x76, 0x99, - 0x19, 0x55, 0xeb, 0xd6, 0x31, 0x59, 0x43, 0x4e, - 0xce, 0xbb, 0x4e, 0x46, 0x6d, 0xae, 0x5a, 0x10, - 0x73, 0xa6, 0x72, 0x76, 0x27, 0x09, 0x7a, 0x10, - 0x49, 0xe6, 0x17, 0xd9, 0x1d, 0x36, 0x10, 0x94, - 0xfa, 0x68, 0xf0, 0xff, 0x77, 0x98, 0x71, 0x30, - 0x30, 0x5b, 0xea, 0xba, 0x2e, 0xda, 0x04, 0xdf, - 0x99, 0x7b, 0x71, 0x4d, 0x6c, 0x6f, 0x2c, 0x29, - 0xa6, 0xad, 0x5c, 0xb4, 0x02, 0x2b, 0x02, 0x70, - 0x9b }, - .aad_length = 12, - .aad = { 0xf3, 0x33, 0x88, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x4e, 0x91 }, - .digest_length = CHACHA20_POLY1305_CHECK_LEN, - .digest = { 0xee, 0xad, 0x9d, 0x67, 0x89, 0x0c, 0xbb, 0x22, - 0x39, 0x23, 0x36, 0xfe, 0xa1, 0x85, 0x1f, 0x38 } - }, -}; - -static crypto_test_reference_t hmac_md5_reference[] = { - { - .auth_key_length = HMAC_MD5_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_MD5_CHECK_LEN, - .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, - 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d }, - - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_MD5_96_CHECK_LEN, - }, - { - .auth_key_length = HMAC_MD5_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_MD5_CHECK_LEN, - .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, - 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 }, - - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_MD5_96_CHECK_LEN, - }, - { - .auth_key_length = HMAC_MD5_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_MD5_CHECK_LEN, - .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, - 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_MD5_96_CHECK_LEN, - }, -}; - -static crypto_test_reference_t hmac_sha1_reference[] = { - { - .auth_key_length = HMAC_SHA1_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_SHA1_CHECK_LEN, - .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64, - 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e, - 0xf1, 0x46, 0xbe, 0x00 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA1_96_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA1_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_SHA1_CHECK_LEN, - .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2, - 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c, - 0x25, 0x9a, 0x7c, 0x79 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA1_96_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA1_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_SHA1_CHECK_LEN, - .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd, - 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f, - 0x63, 0xf1, 0x75, 0xd3 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA1_96_CHECK_LEN, - }, -}; - -static crypto_test_reference_t hmac_sha224_reference[] = { - { - .auth_key_length = HMAC_SHA224_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_SHA224_CHECK_LEN, - .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19, - 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f, - 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f, - 0x53, 0x68, 0x4b, 0x22 } - }, - { - .auth_key_length = HMAC_SHA224_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_SHA224_CHECK_LEN, - .digest = { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf, - 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f, - 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00, - 0x8f, 0xd0, 0x5e, 0x44 } - }, - { - .auth_key_length = HMAC_SHA224_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_SHA224_CHECK_LEN, - .digest = { 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6, - 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64, - 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1, - 0xec, 0x83, 0x33, 0xea } - } -}; - -static crypto_test_reference_t hmac_sha256_reference[] = { - { - .auth_key_length = HMAC_SHA256_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_SHA256_CHECK_LEN, - .digest = { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, - 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, - 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, - 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA256_128_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA256_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_SHA256_CHECK_LEN, - .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, - 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, - 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, - 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA256_128_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA256_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_SHA256_CHECK_LEN, - .digest = { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, - 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, - 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, - 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA256_128_CHECK_LEN, - }, -}; - -static crypto_test_reference_t hmac_sha384_reference[] = { - { - .auth_key_length = HMAC_SHA384_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_SHA384_CHECK_LEN, - .digest = { 0xaf, 0xd0, 0x39, 0x44, 0xd8, 0x48, 0x95, 0x62, - 0x6b, 0x08, 0x25, 0xf4, 0xab, 0x46, 0x90, 0x7f, - 0x15, 0xf9, 0xda, 0xdb, 0xe4, 0x10, 0x1e, 0xc6, - 0x82, 0xaa, 0x03, 0x4c, 0x7c, 0xeb, 0xc5, 0x9c, - 0xfa, 0xea, 0x9e, 0xa9, 0x07, 0x6e, 0xde, 0x7f, - 0x4a, 0xf1, 0x52, 0xe8, 0xb2, 0xfa, 0x9c, 0xb6 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA384_192_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA384_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_SHA384_CHECK_LEN, - .digest = { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31, - 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b, - 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47, - 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e, - 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7, - 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA384_192_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA384_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_SHA384_CHECK_LEN, - .digest = {0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a, - 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f, - 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb, - 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b, - 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9, - 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA384_192_CHECK_LEN, - }, -}; - -static crypto_test_reference_t hmac_sha512_reference[] = { - { - .auth_key_length = HMAC_SHA512_KEY_LEN, - .auth_key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - .length = 8, - /* "Hi There" */ - .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .ciphertext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - .digest_length = HMAC_SHA512_CHECK_LEN, - .digest = { 0x87, 0xaa, 0x7c, 0xde, 0xa5, 0xef, 0x61, 0x9d, - 0x4f, 0xf0, 0xb4, 0x24, 0x1a, 0x1d, 0x6c, 0xb0, - 0x23, 0x79, 0xf4, 0xe2, 0xce, 0x4e, 0xc2, 0x78, - 0x7a, 0xd0, 0xb3, 0x05, 0x45, 0xe1, 0x7c, 0xde, - 0xda, 0xa8, 0x33, 0xb7, 0xd6, 0xb8, 0xa7, 0x02, - 0x03, 0x8b, 0x27, 0x4e, 0xae, 0xa3, 0xf4, 0xe4, - 0xbe, 0x9d, 0x91, 0x4e, 0xeb, 0x61, 0xf1, 0x70, - 0x2e, 0x69, 0x6c, 0x20, 0x3a, 0x12, 0x68, 0x54 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA512_256_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA512_KEY_LEN, - /* "Jefe" */ - .auth_key = { 0x4a, 0x65, 0x66, 0x65 }, - .length = 28, - /* what do ya want for nothing?*/ - .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .ciphertext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20, - 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, - 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68, - 0x69, 0x6e, 0x67, 0x3f }, - .digest_length = HMAC_SHA512_CHECK_LEN, - .digest = { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2, - 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3, - 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6, - 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54, - 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a, - 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd, - 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b, - 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA512_256_CHECK_LEN, - }, - { - .auth_key_length = HMAC_SHA512_KEY_LEN, - .auth_key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa }, - .length = 50, - .plaintext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .ciphertext = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd }, - .digest_length = HMAC_SHA512_CHECK_LEN, - .digest = { 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84, - 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9, - 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36, - 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39, - 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8, - 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07, - 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26, - 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb } - }, - { - .copy_previous_vector = 1, - .digest_length = HMAC_SHA512_256_CHECK_LEN, - }, -}; - -/* - * RFC 3566 - */ -static crypto_test_reference_t aes_xcbc_reference[] = { - /* Test Case #1 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, - .length = 0, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = {0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c, - 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29} - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #2 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 3, - .plaintext = { 0x00, 0x01, 0x02 }, - .ciphertext = { 0x00, 0x01, 0x02 }, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf, - 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f } - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #3 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 16, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7, - 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 } - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #4 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, - .length = 20, - .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13 }, - .ciphertext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13 }, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15, - 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 } - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #5 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, - .length = 32, - .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, - .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = {0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3, - 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4} - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #6 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, - .length = 34, - .plaintext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21}, - .ciphertext = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21}, - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = {0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3, - 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8} - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, - /* Test Case #7 */ - { - .auth_key_length = AES_XCBC_MAC_KEY_LEN, - .auth_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}, - .length = 1000, - /* Plaintext is 1000 zero bytes. No explicit init needed. */ - .digest_length = AES_XCBC_MAC_CHECK_LEN, - .digest = {0xf0, 0xda, 0xfe, 0xe8, 0x95, 0xdb, 0x30, 0x25, - 0x37, 0x61, 0x10, 0x3b, 0x5d, 0x84, 0x52, 0x8f} - }, - { - .copy_previous_vector = 1, - .digest_length = AES_XCBC_MAC_96_CHECK_LEN, - }, -}; - -/* - * Kasumi F8 and F9 test vectors are taken from - * 3GPP TS 35.203 V9.0.0 (2009-12) - * 3rd Generation Partnership Project; - * Technical Specification Group Services and System Aspects; - * 3G Security; - * Specification of the 3GPP Confidentiality - * and Integrity Algorithms; - * Document 3: Implementors' Test Data - * (Release 9) - */ -static crypto_test_reference_t kasumi_f8_reference[] = { - { - .cipher_key_length = KASUMI_F8_KEY_LEN, - .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20, - 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52}, - .cipher_iv_length = KASUMI_F8_IV_LEN, - .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00}, - .length = 120, /* 15 bytes */ - .is_length_in_bits = true, - .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4, - 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 }, - .ciphertext = { 0x9b, 0xc9, 0x2c, 0xa8, 0x03, 0xc6, 0x7b, 0x28, - 0xa1, 0x1a, 0x4b, 0xee, 0x5a, 0x0c, 0x25 } - } -}; - -static crypto_test_reference_t kasumi_f9_reference[] = { - { - .auth_key_length = KASUMI_F9_KEY_LEN, - .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9, - 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e }, - .auth_iv_length = KASUMI_F9_IV_LEN, - .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd, - 0x01, }, - .length = 384, /* 48 bytes */ - .is_length_in_bits = true, - .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, - 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, - 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, - 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, - 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, - 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, - .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, - 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, - 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, - 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, - 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, - 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, - .digest_length = KASUMI_F9_DIGEST_LEN, - .digest = { 0xdd, 0x7d, 0xfa, 0xdd }, - } -}; - -/* - * Snow3G UEA2 & UIA2 test vectors are taken from - * Specification of the 3GPP Confidentiality and - * Integrity Algorithms UEA2 & UIA2 - * Document 3: Implementors’ Test Data - * Version: 1.1 - * Date: 25 th October 2012 - */ -static crypto_test_reference_t snow3g_uea2_reference[] = { - { - .cipher_key_length = SNOW3G_UEA2_KEY_LEN, - .cipher_key = { 0x5a, 0xcb, 0x1d, 0x64, 0x4c, 0x0d, 0x51, 0x20, - 0x4e, 0xa5, 0xf1, 0x45, 0x10, 0x10, 0xd8, 0x52}, - .cipher_iv_length = SNOW3G_UEA2_IV_LEN, - .cipher_iv = { 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00, - 0xfa, 0x55, 0x6b, 0x26, 0x1c, 0x00, 0x00, 0x00}, - .length = 120, /* 15 bytes */ - .is_length_in_bits = true, - .plaintext = { 0xad, 0x9c, 0x44, 0x1f, 0x89, 0x0b, 0x38, 0xc4, - 0x57, 0xa4, 0x9d, 0x42, 0x14, 0x07, 0xe8 }, - .ciphertext = { 0xba, 0x0f, 0x31, 0x30, 0x03, 0x34, 0xc5, 0x6b, - 0x52, 0xa7, 0x49, 0x7c, 0xba, 0xc0, 0x46 } - } -}; - -static crypto_test_reference_t snow3g_uia2_reference[] = { - { - .auth_key_length = SNOW3G_UIA2_KEY_LEN, - .auth_key = { 0xc7, 0x36, 0xc6, 0xaa, 0xb2, 0x2b, 0xff, 0xf9, - 0x1e, 0x26, 0x98, 0xd2, 0xe2, 0x2a, 0xd5, 0x7e}, - .auth_iv_length = SNOW3G_UIA2_IV_LEN, - .auth_iv = { 0x14, 0x79, 0x3e, 0x41, 0x03, 0x97, 0xe8, 0xfd, - 0x94, 0x79, 0x3e, 0x41, 0x03, 0x97, 0x68, 0xfd }, - .length = 384, /* 48 bytes */ - .is_length_in_bits = true, - .plaintext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, - 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, - 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, - 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, - 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, - 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, - .ciphertext = { 0xd0, 0xa7, 0xd4, 0x63, 0xdf, 0x9f, 0xb2, 0xb2, - 0x78, 0x83, 0x3f, 0xa0, 0x2e, 0x23, 0x5a, 0xa1, - 0x72, 0xbd, 0x97, 0x0c, 0x14, 0x73, 0xe1, 0x29, - 0x07, 0xfb, 0x64, 0x8b, 0x65, 0x99, 0xaa, 0xa0, - 0xb2, 0x4a, 0x03, 0x86, 0x65, 0x42, 0x2b, 0x20, - 0xa4, 0x99, 0x27, 0x6a, 0x50, 0x42, 0x70, 0x09}, - .digest_length = SNOW3G_UIA2_DIGEST_LEN, - .digest = { 0x38, 0xb5, 0x54, 0xc0 } - } -}; - -/* - * AES EEA2 and AES EIA2 test vectors from - * Specification of the 3GPP Confidentiality and Integrity - * Algorithms 128-EEA2 & 128-EIA2 - */ -static crypto_test_reference_t aes_eea2_reference[] = { - { - .cipher_key_length = AES_EEA2_KEY_LEN, - .cipher_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, - 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1}, - .cipher_iv_length = AES_EEA2_IV_LEN, - .cipher_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xac, }, - .length = 253, - .is_length_in_bits = true, - .plaintext = { 0x98, 0x1B, 0xA6, 0x82, 0x4C, 0x1B, 0xFB, 0x1A, - 0xB4, 0x85, 0x47, 0x20, 0x29, 0xB7, 0x1D, 0x80, - 0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC, - 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF0 }, - .ciphertext = { 0xE9, 0xFE, 0xD8, 0xA6, 0x3D, 0x15, 0x53, 0x04, - 0xD7, 0x1D, 0xF2, 0x0B, 0xF3, 0xE8, 0x22, 0x14, - 0xB2, 0x0E, 0xD7, 0xDA, 0xD2, 0xF2, 0x33, 0xDC, - 0x3C, 0x22, 0xD7, 0xBD, 0xEE, 0xED, 0x8E, 0x78} - }, - { - .cipher_key_length = AES_EEA2_KEY_LEN, - .cipher_key = { 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC4, 0x40, 0xE0, - 0x95, 0x2C, 0x49, 0x10, 0x48, 0x05, 0xFF, 0x48}, - .cipher_iv_length = AES_EEA2_IV_LEN, - .cipher_iv = { 0xc6, 0x75, 0xa6, 0x4b, 0x64, }, - .length = 798, - .is_length_in_bits = true, - .plaintext = { 0x7E, 0xC6, 0x12, 0x72, 0x74, 0x3B, 0xF1, 0x61, - 0x47, 0x26, 0x44, 0x6A, 0x6C, 0x38, 0xCE, 0xD1, - 0x66, 0xF6, 0xCA, 0x76, 0xEB, 0x54, 0x30, 0x04, - 0x42, 0x86, 0x34, 0x6C, 0xEF, 0x13, 0x0F, 0x92, - 0x92, 0x2B, 0x03, 0x45, 0x0D, 0x3A, 0x99, 0x75, - 0xE5, 0xBD, 0x2E, 0xA0, 0xEB, 0x55, 0xAD, 0x8E, - 0x1B, 0x19, 0x9E, 0x3E, 0xC4, 0x31, 0x60, 0x20, - 0xE9, 0xA1, 0xB2, 0x85, 0xE7, 0x62, 0x79, 0x53, - 0x59, 0xB7, 0xBD, 0xFD, 0x39, 0xBE, 0xF4, 0xB2, - 0x48, 0x45, 0x83, 0xD5, 0xAF, 0xE0, 0x82, 0xAE, - 0xE6, 0x38, 0xBF, 0x5F, 0xD5, 0xA6, 0x06, 0x19, - 0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB, - 0x9B, 0x13, 0x48, 0x80 }, - .ciphertext = { 0x59, 0x61, 0x60, 0x53, 0x53, 0xC6, 0x4B, 0xDC, - 0xA1, 0x5B, 0x19, 0x5E, 0x28, 0x85, 0x53, 0xA9, - 0x10, 0x63, 0x25, 0x06, 0xD6, 0x20, 0x0A, 0xA7, - 0x90, 0xC4, 0xC8, 0x06, 0xC9, 0x99, 0x04, 0xCF, - 0x24, 0x45, 0xCC, 0x50, 0xBB, 0x1C, 0xF1, 0x68, - 0xA4, 0x96, 0x73, 0x73, 0x4E, 0x08, 0x1B, 0x57, - 0xE3, 0x24, 0xCE, 0x52, 0x59, 0xC0, 0xE7, 0x8D, - 0x4C, 0xD9, 0x7B, 0x87, 0x09, 0x76, 0x50, 0x3C, - 0x09, 0x43, 0xF2, 0xCB, 0x5A, 0xE8, 0xF0, 0x52, - 0xC7, 0xB7, 0xD3, 0x92, 0x23, 0x95, 0x87, 0xB8, - 0x95, 0x60, 0x86, 0xBC, 0xAB, 0x18, 0x83, 0x60, - 0x42, 0xE2, 0xE6, 0xCE, 0x42, 0x43, 0x2A, 0x17, - 0x10, 0x5C, 0x53, 0xD0 } - }, -}; - -static crypto_test_reference_t aes_eia2_reference[] = { - /* 3GPP TS 33.401, C.2.1 */ - { - .auth_key_length = AES_EIA2_KEY_LEN, - .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, - 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 }, - .auth_iv_length = AES_EIA2_IV_LEN, - .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0xc0 }, - .length = 58, - .is_length_in_bits = true, - .plaintext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 }, - .ciphertext = { 0x33, 0x32, 0x34, 0x62, 0x63, 0x39, 0x38, 0x40 }, - .digest_length = AES_EIA2_DIGEST_LEN, - .digest = { 0x11, 0x8c, 0x6e, 0xb8 } - }, - /* 3GPP TS 33.401, C.2.2. */ - { - .auth_key_length = AES_EIA2_KEY_LEN, - .auth_key = { 0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, - 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1 }, - .auth_iv_length = AES_EIA2_IV_LEN, - .auth_iv = { 0x39, 0x8a, 0x59, 0xb4, 0xd4, }, - .length = 64, /* 8 bytes */ - .is_length_in_bits = true, - .plaintext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae }, - .ciphertext = { 0x48, 0x45, 0x83, 0xd5, 0xaf, 0xe0, 0x82, 0xae}, - .digest_length = AES_EIA2_DIGEST_LEN, - .digest = { 0xb9, 0x37, 0x87, 0xe6 } - }, - /* 3GPP TS 33.401, C.2.5 */ - { - .auth_key_length = AES_EIA2_KEY_LEN, - .auth_key = { 0x83, 0xfd, 0x23, 0xa2, 0x44, 0xa7, 0x4c, 0xf3, - 0x58, 0xda, 0x30, 0x19, 0xf1, 0x72, 0x26, 0x35 }, - .auth_iv_length = AES_EIA2_IV_LEN, - .auth_iv = { 0x36, 0xaf, 0x61, 0x44, 0x7c }, - .length = 768, /* 96 bytes */ - .is_length_in_bits = true, - .plaintext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb, - 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11, - 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39, - 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39, - 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5, - 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef, - 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1, - 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72, - 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf, - 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef, - 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6, - 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a }, - .ciphertext = { 0x35, 0xc6, 0x87, 0x16, 0x63, 0x3c, 0x66, 0xfb, - 0x75, 0x0c, 0x26, 0x68, 0x65, 0xd5, 0x3c, 0x11, - 0xea, 0x05, 0xb1, 0xe9, 0xfa, 0x49, 0xc8, 0x39, - 0x8d, 0x48, 0xe1, 0xef, 0xa5, 0x90, 0x9d, 0x39, - 0x47, 0x90, 0x28, 0x37, 0xf5, 0xae, 0x96, 0xd5, - 0xa0, 0x5b, 0xc8, 0xd6, 0x1c, 0xa8, 0xdb, 0xef, - 0x1b, 0x13, 0xa4, 0xb4, 0xab, 0xfe, 0x4f, 0xb1, - 0x00, 0x60, 0x45, 0xb6, 0x74, 0xbb, 0x54, 0x72, - 0x93, 0x04, 0xc3, 0x82, 0xbe, 0x53, 0xa5, 0xaf, - 0x05, 0x55, 0x61, 0x76, 0xf6, 0xea, 0xa2, 0xef, - 0x1d, 0x05, 0xe4, 0xb0, 0x83, 0x18, 0x1e, 0xe6, - 0x74, 0xcd, 0xa5, 0xa4, 0x85, 0xf7, 0x4d, 0x7a }, - .digest_length = AES_EIA2_DIGEST_LEN, - .digest = { 0xe6, 0x57, 0xe1, 0x82 } - }, -}; - -/* - * ZUC EEA3 and EIA3 test vectors from - * Specification of the 3GPP Confidentiality and Integrity - * Algorithms 128-EEA3 & 128-EIA3 - * Document 3: Implementor’s Test Data - * Version: 1.1 - * Date: 4 th Jan. 2011 - */ -static crypto_test_reference_t zuc_eea3_reference[] = { - { - .cipher_key_length = ZUC_EEA3_KEY_LEN, - .cipher_key = { 0xe5, 0xbd, 0x3e, 0xa0, 0xeb, 0x55, 0xad, 0xe8, - 0x66, 0xc6, 0xac, 0x58, 0xbd, 0x54, 0x30, 0x2a}, - .cipher_iv_length = ZUC_EEA3_IV_LEN, - .cipher_iv = { 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x68, 0x23, 0xc4, 0x00, 0x00, 0x00 }, - .length = 800, /* 100 bytes */ - .is_length_in_bits = true, - .plaintext = { 0x14, 0xa8, 0xef, 0x69, 0x3d, 0x67, 0x85, 0x07, - 0xbb, 0xe7, 0x27, 0x0a, 0x7f, 0x67, 0xff, 0x50, - 0x06, 0xc3, 0x52, 0x5b, 0x98, 0x07, 0xe4, 0x67, - 0xc4, 0xe5, 0x60, 0x00, 0xba, 0x33, 0x8f, 0x5d, - 0x42, 0x95, 0x59, 0x03, 0x67, 0x51, 0x82, 0x22, - 0x46, 0xc8, 0x0d, 0x3b, 0x38, 0xf0, 0x7f, 0x4b, - 0xe2, 0xd8, 0xff, 0x58, 0x05, 0xf5, 0x13, 0x22, - 0x29, 0xbd, 0xe9, 0x3b, 0xbb, 0xdc, 0xaf, 0x38, - 0x2b, 0xf1, 0xee, 0x97, 0x2f, 0xbf, 0x99, 0x77, - 0xba, 0xda, 0x89, 0x45, 0x84, 0x7a, 0x2a, 0x6c, - 0x9a, 0xd3, 0x4a, 0x66, 0x75, 0x54, 0xe0, 0x4d, - 0x1f, 0x7f, 0xa2, 0xc3, 0x32, 0x41, 0xbd, 0x8f, - 0x01, 0xba, 0x22, 0x0d }, - .ciphertext = { 0x13, 0x1d, 0x43, 0xe0, 0xde, 0xa1, 0xbe, 0x5c, - 0x5a, 0x1b, 0xfd, 0x97, 0x1d, 0x85, 0x2c, 0xbf, - 0x71, 0x2d, 0x7b, 0x4f, 0x57, 0x96, 0x1f, 0xea, - 0x32, 0x08, 0xaf, 0xa8, 0xbc, 0xa4, 0x33, 0xf4, - 0x56, 0xad, 0x09, 0xc7, 0x41, 0x7e, 0x58, 0xbc, - 0x69, 0xcf, 0x88, 0x66, 0xd1, 0x35, 0x3f, 0x74, - 0x86, 0x5e, 0x80, 0x78, 0x1d, 0x20, 0x2d, 0xfb, - 0x3e, 0xcf, 0xf7, 0xfc, 0xbc, 0x3b, 0x19, 0x0f, - 0xe8, 0x2a, 0x20, 0x4e, 0xd0, 0xe3, 0x50, 0xfc, - 0x0f, 0x6f, 0x26, 0x13, 0xb2, 0xf2, 0xbc, 0xa6, - 0xdf, 0x5a, 0x47, 0x3a, 0x57, 0xa4, 0xa0, 0x0d, - 0x98, 0x5e, 0xba, 0xd8, 0x80, 0xd6, 0xf2, 0x38, - 0x64, 0xa0, 0x7b, 0x01 } - }, - - /* Privately generated test data */ - { - .cipher_key_length = ZUC_EEA3_256_KEY_LEN, - .cipher_key = { 0xf7, 0xb4, 0x04, 0x5a, 0x81, 0x5c, 0x1b, 0x01, - 0x82, 0xf9, 0xf4, 0x26, 0x80, 0xd4, 0x56, 0x26, - 0xd5, 0xf7, 0x4b, 0x68, 0x48, 0x6b, 0x92, 0x6a, - 0x34, 0x1f, 0x86, 0x66, 0x60, 0x0a, 0xfc, 0x57}, - .cipher_iv_length = ZUC_EEA3_256_IV_LEN, - .cipher_iv = { 0x8e, 0x5d, 0xbc, 0x3f, 0xb9, 0xae, 0x66, 0xa3, - 0xb9, 0x5c, 0x12, 0x14, 0xdb, 0xc5, 0xbc, 0x18, - 0x48, 0x12, 0x09, 0x06, 0x25, 0x33, 0x2e, 0x12, - 0x12 }, - .length = 1024, - .is_length_in_bits = true, - .plaintext = { 0x36, 0xdb, 0x63, 0x68, 0xb5, 0x1f, 0x4e, 0x92, - 0x46, 0x1f, 0xde, 0xdb, 0xc2, 0xec, 0xfa, 0x7e, - 0x49, 0x85, 0x77, 0xaa, 0x46, 0x98, 0x30, 0x2d, - 0x3b, 0xc4, 0x11, 0x24, 0x98, 0x20, 0xa9, 0xce, - 0xfb, 0x0d, 0x36, 0xb0, 0x2c, 0x85, 0x42, 0x72, - 0xa4, 0x21, 0x4e, 0x66, 0x0d, 0x48, 0xe4, 0x57, - 0xce, 0x5b, 0x01, 0x14, 0xf3, 0x31, 0x42, 0x2e, - 0xf5, 0x53, 0x52, 0x8d, 0x73, 0xfc, 0x5c, 0x6e, - 0x09, 0x92, 0x1e, 0x35, 0x17, 0x60, 0xa8, 0xbb, - 0x81, 0xf6, 0x21, 0x8f, 0x3e, 0x05, 0xe6, 0x0c, - 0x60, 0xe7, 0x21, 0x53, 0x18, 0x63, 0x81, 0x0d, - 0xb6, 0xd4, 0x9a, 0x29, 0xd0, 0xf6, 0x97, 0xd9, - 0x89, 0xb5, 0x0e, 0xa0, 0x15, 0xb6, 0x5c, 0x97, - 0xac, 0x7d, 0x26, 0xeb, 0x83, 0x0c, 0xf7, 0xe3, - 0xf3, 0x18, 0x37, 0x0b, 0x7b, 0xb8, 0x18, 0x31, - 0x8c, 0xb2, 0x5a, 0x5c, 0xa9, 0xf1, 0x35, 0x32 }, - .ciphertext = { 0xa6, 0xe5, 0x71, 0x58, 0x5c, 0xcf, 0x5d, 0x0d, - 0x59, 0xb5, 0x51, 0xab, 0xf5, 0xfa, 0x31, 0xf9, - 0x8d, 0x4f, 0xf0, 0x3c, 0x7d, 0x61, 0x8d, 0x7a, - 0x6b, 0xcb, 0x2c, 0x79, 0xca, 0x99, 0x06, 0x6f, - 0xff, 0x5d, 0x12, 0x5f, 0x0e, 0x7a, 0x33, 0x6b, - 0x51, 0xbc, 0x58, 0x53, 0xff, 0xbd, 0x85, 0xc9, - 0xac, 0x5f, 0x33, 0xc2, 0xa2, 0xf1, 0x17, 0x7a, - 0xd9, 0x3f, 0x81, 0x82, 0x2f, 0x0a, 0xb0, 0xaf, - 0xb9, 0x19, 0x3b, 0xfa, 0xcd, 0xa4, 0x06, 0x81, - 0x2a, 0x7a, 0xbf, 0x2c, 0x07, 0xde, 0xc1, 0xa4, - 0x8c, 0x15, 0x85, 0x81, 0xa6, 0xd3, 0x73, 0x1c, - 0x29, 0x0b, 0xee, 0x3c, 0x57, 0xfa, 0x82, 0xad, - 0x6f, 0xe0, 0xa1, 0x54, 0x8d, 0xa4, 0x92, 0x29, - 0xf4, 0xfa, 0x6d, 0x01, 0xe3, 0x6c, 0xb9, 0x76, - 0x80, 0x53, 0xbb, 0x27, 0xb8, 0x18, 0x47, 0x6c, - 0xae, 0xb5, 0x44, 0x60, 0x43, 0x9d, 0xa7, 0x3f } - }, - /* Privately generated test data */ - { - .cipher_key_length = ZUC_EEA3_256_KEY_LEN, - .cipher_key = { 0x1d, 0x0f, 0x0e, 0x75, 0x86, 0xb3, 0xfc, 0x65, - 0x94, 0xbf, 0xaa, 0xa8, 0xf5, 0xd0, 0x0f, 0xe8, - 0x14, 0x7a, 0x96, 0x61, 0x15, 0x49, 0x79, 0x71, - 0x13, 0x82, 0xb4, 0xae, 0x34, 0x04, 0x75, 0x51 }, - .cipher_iv_length = ZUC_EEA3_256_IV_LEN, - .cipher_iv = { 0x98, 0xcc, 0x89, 0x9f, 0xaf, 0x6d, 0x64, 0xb6, - 0xb1, 0xe8, 0x21, 0x72, 0xee, 0xb6, 0xcc, 0xe3, - 0xcf, 0x32, 0x28, 0x21, 0x21, 0x0d, 0x1e, 0x1c, - 0x34 }, - .length = 1928, - .is_length_in_bits = true, - .plaintext = { 0xa4, 0xcb, 0x6e, 0x76, 0x99, 0xfb, 0x0c, 0xab, - 0x6d, 0x57, 0xb1, 0x69, 0xc0, 0x47, 0x80, 0x63, - 0x00, 0xe1, 0xf9, 0x51, 0x10, 0xbe, 0xc0, 0x0f, - 0x99, 0x62, 0x2d, 0x71, 0xca, 0x75, 0xa0, 0x6e, - 0x41, 0x0e, 0xe4, 0xda, 0x09, 0xf1, 0x86, 0x76, - 0x48, 0x37, 0xe0, 0x08, 0x7e, 0x60, 0x6c, 0x7f, - 0x41, 0x65, 0xd0, 0x51, 0x24, 0x91, 0x61, 0xbd, - 0xf3, 0x8e, 0x2e, 0xbd, 0x04, 0xce, 0x2b, 0x45, - 0xdc, 0x0f, 0x1f, 0xe5, 0x00, 0xa5, 0x5c, 0x48, - 0xdd, 0x3c, 0x51, 0x5b, 0x9c, 0xbd, 0xda, 0xde, - 0x22, 0xab, 0x2f, 0x46, 0x3c, 0x90, 0x03, 0x2f, - 0x1f, 0x31, 0xec, 0x23, 0xff, 0x17, 0x68, 0xdb, - 0x26, 0x87, 0xc1, 0x27, 0x2d, 0x1d, 0x6f, 0x0a, - 0x59, 0xc0, 0x65, 0xf5, 0x7d, 0x40, 0xd3, 0xa0, - 0xeb, 0x03, 0xe6, 0x27, 0x93, 0xea, 0x56, 0xb2, - 0x1b, 0x42, 0xd5, 0x1b, 0x59, 0x3d, 0xf6, 0x7f, - 0xc5, 0xb7, 0xa6, 0xf2, 0xd4, 0x16, 0xfc, 0x2d, - 0xd6, 0x61, 0x23, 0x54, 0xa1, 0xf6, 0xf4, 0x8c, - 0xf9, 0xda, 0xb3, 0x8d, 0xc4, 0x09, 0x3f, 0xe0, - 0x4b, 0x15, 0xfb, 0xa4, 0x52, 0xf1, 0x24, 0x17, - 0xa9, 0xca, 0x09, 0x7d, 0xe0, 0x05, 0xab, 0xb7, - 0x67, 0xce, 0x0b, 0x08, 0xc4, 0xff, 0x95, 0xbe, - 0xd9, 0x48, 0x4b, 0x9e, 0x52, 0x8a, 0x7e, 0x9d, - 0x9f, 0x79, 0x42, 0xf2, 0x6a, 0x66, 0x09, 0x13, - 0x30, 0x13, 0x91, 0x11, 0x18, 0x3c, 0xc8, 0x7f, - 0x0a, 0xd3, 0x88, 0xce, 0xd2, 0x1d, 0x8c, 0xab, - 0x65, 0xd7, 0x49, 0xb7, 0x62, 0xc7, 0x55, 0x01, - 0x40, 0x97, 0xf3, 0xab, 0xfd, 0xfd, 0xbe, 0x2d, - 0x10, 0x4f, 0x3e, 0x28, 0x8b, 0x06, 0xa8, 0x95, - 0xd9, 0x30, 0x64, 0xab, 0x4d, 0xf0, 0x57, 0xb2, - 0xc8 }, - .ciphertext = { 0xd0, 0xf9, 0xff, 0xce, 0x03, 0x81, 0x14, 0x9c, - 0xd5, 0xf2, 0xbf, 0xe5, 0xff, 0xc8, 0x15, 0x4a, - 0x9c, 0x06, 0x2b, 0x17, 0x99, 0xe3, 0x48, 0x70, - 0x37, 0x01, 0x5e, 0x24, 0x80, 0x9a, 0x46, 0x4e, - 0xa8, 0xc0, 0x59, 0xd7, 0x03, 0x74, 0x28, 0x91, - 0x79, 0xb4, 0xb5, 0xd6, 0x52, 0x92, 0x04, 0x77, - 0x5b, 0x4f, 0x34, 0xd1, 0xbe, 0xaa, 0x74, 0xd9, - 0x01, 0x40, 0x24, 0xc7, 0x8c, 0x62, 0x2a, 0x51, - 0x5a, 0x58, 0x0e, 0xc8, 0x70, 0x12, 0x06, 0x1c, - 0x62, 0x7f, 0xf5, 0x23, 0xcb, 0x3c, 0xc1, 0xbe, - 0x8b, 0x7f, 0x9d, 0x12, 0xb8, 0x26, 0xc8, 0xa3, - 0x77, 0x7e, 0x83, 0xda, 0x83, 0xe1, 0x9f, 0xef, - 0x33, 0x62, 0x17, 0xa7, 0x74, 0x68, 0x34, 0x5e, - 0x16, 0xcc, 0xbc, 0x6c, 0x33, 0x2f, 0x73, 0xf0, - 0xfc, 0xe5, 0x2c, 0x2d, 0xfb, 0x81, 0xbe, 0x1e, - 0x6e, 0x4f, 0xf4, 0x14, 0x37, 0x7c, 0x97, 0xac, - 0xa9, 0xac, 0x68, 0x95, 0xf3, 0x55, 0xb3, 0xfb, - 0xf6, 0x64, 0xd9, 0x1b, 0xe1, 0x54, 0x79, 0x6e, - 0xfa, 0x21, 0xa4, 0x19, 0x9f, 0xb4, 0x4b, 0xb7, - 0xef, 0x52, 0xd8, 0x44, 0x75, 0x99, 0x07, 0x6d, - 0xa9, 0xcf, 0x32, 0xc5, 0xc1, 0x31, 0x0c, 0xa8, - 0x86, 0x40, 0x75, 0xeb, 0x12, 0xcf, 0x26, 0x5c, - 0x5f, 0xa3, 0x3c, 0xb6, 0x12, 0x45, 0xf3, 0x0a, - 0x38, 0x09, 0xa8, 0x36, 0x32, 0x4a, 0x2f, 0xad, - 0x50, 0x11, 0x38, 0xba, 0x8f, 0xdd, 0xd1, 0x58, - 0xd7, 0x3d, 0x3a, 0x40, 0x7c, 0x3f, 0xa7, 0x98, - 0xf3, 0x12, 0x7f, 0x9f, 0x89, 0xcf, 0x48, 0x58, - 0x01, 0xeb, 0x98, 0x7c, 0x59, 0x11, 0x9f, 0x57, - 0x74, 0x5f, 0x70, 0x72, 0x74, 0xa4, 0x82, 0x3c, - 0x36, 0xe6, 0x31, 0x9e, 0xba, 0x7b, 0x53, 0xfc, - 0x56 } - }, -}; - -static crypto_test_reference_t zuc_eia3_reference[] = { - { - .auth_key_length = ZUC_EIA3_KEY_LEN, - .auth_key = { 0xc9, 0xe6, 0xce, 0xc4, 0x60, 0x7c, 0x72, 0xdb, - 0x00, 0x0a, 0xef, 0xa8, 0x83, 0x85, 0xab, 0x0a }, - .auth_iv_length = ZUC_EIA3_IV_LEN, - .auth_iv = { 0xa9, 0x40, 0x59, 0xda, 0x50, 0x00, 0x00, 0x00, - 0x29, 0x40, 0x59, 0xda, 0x50, 0x00, 0x80, 0x00 }, - .length = 584, /* 73 bytes */ - .is_length_in_bits = true, - .plaintext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e, - 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1, - 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83, - 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0, - 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9, - 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9, - 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d, - 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c, - 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81, - 0x00, 0x00, 0x00, 0x00 }, - .ciphertext = { 0x98, 0x3b, 0x41, 0xd4, 0x7d, 0x78, 0x0c, 0x9e, - 0x1a, 0xd1, 0x1d, 0x7e, 0xb7, 0x03, 0x91, 0xb1, - 0xde, 0x0b, 0x35, 0xda, 0x2d, 0xc6, 0x2f, 0x83, - 0xe7, 0xb7, 0x8d, 0x63, 0x06, 0xca, 0x0e, 0xa0, - 0x7e, 0x94, 0x1b, 0x7b, 0xe9, 0x13, 0x48, 0xf9, - 0xfc, 0xb1, 0x70, 0xe2, 0x21, 0x7f, 0xec, 0xd9, - 0x7f, 0x9f, 0x68, 0xad, 0xb1, 0x6e, 0x5d, 0x7d, - 0x21, 0xe5, 0x69, 0xd2, 0x80, 0xed, 0x77, 0x5c, - 0xeb, 0xde, 0x3f, 0x40, 0x93, 0xc5, 0x38, 0x81, - 0x00, 0x00, 0x00, 0x00 }, - .digest_length = ZUC_EIA3_DIGEST_LEN, - .digest = { 0x24, 0xa8, 0x42, 0xb3 } - }, - /* Privately generated test data */ - { - .auth_key_length = ZUC_EIA3_256_KEY_LEN, - .auth_key = { 0xe3, 0x8e, 0xaf, 0x08, 0xde, 0x8c, 0x08, 0x41, - 0x7f, 0x2b, 0x97, 0x20, 0x10, 0x87, 0xc7, 0xf7, - 0xbe, 0x3c, 0xd2, 0x68, 0x80, 0x10, 0x1e, 0x71, - 0xfd, 0xb2, 0xbb, 0xad, 0x25, 0x0f, 0x06, 0x08 }, - .auth_iv_length = ZUC_EIA3_256_IV_LEN, - .auth_iv = { 0xf5, 0x8d, 0x08, 0x26, 0x94, 0x14, 0xc7, 0x4d, - 0xf5, 0x7c, 0x9c, 0xaa, 0x45, 0x53, 0xfd, 0x85, - 0x23, 0x0b, 0x00, 0x0e, 0x26, 0x2b, 0x0f, 0x01, - 0x26 }, - .length = 360, - .is_length_in_bits = true, - .plaintext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf, - 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87, - 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46, - 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f, - 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7, - 0xca, 0x86, 0x93, 0x6d, 0xee }, - .ciphertext = { 0x08, 0xba, 0x8d, 0xf1, 0xf8, 0x62, 0xa6, 0xaf, - 0xf9, 0x03, 0x88, 0x9c, 0xa3, 0x68, 0x6b, 0x87, - 0xb6, 0x92, 0xd1, 0x47, 0x3e, 0x54, 0xaf, 0x46, - 0x07, 0x8f, 0x89, 0xea, 0x26, 0x9d, 0x0e, 0x2f, - 0x57, 0x9b, 0x20, 0x4f, 0xfe, 0xc7, 0xfe, 0xf7, - 0xca, 0x86, 0x93, 0x6d, 0xee }, - .digest_length = ZUC_EIA3_DIGEST_LEN, - .digest = {0x58, 0x19, 0xab, 0xa5} - }, - /* Privately generated test data */ - { - .auth_key_length = ZUC_EIA3_256_KEY_LEN, - .auth_key = { 0x6a, 0x7e, 0x4c, 0x7e, 0x51, 0x25, 0xb3, 0x48, - 0x84, 0x53, 0x3a, 0x94, 0xfb, 0x31, 0x99, 0x90, - 0x32, 0x57, 0x44, 0xee, 0x9b, 0xbc, 0xe9, 0xe5, - 0x25, 0xcf, 0x08, 0xf5, 0xe9, 0xe2, 0x5e, 0x53 }, - .auth_iv_length = ZUC_EIA3_256_IV_LEN, - .auth_iv = { 0x60, 0xaa, 0xd2, 0xb2, 0xd0, 0x85, 0xfa, 0x54, - 0xd8, 0x35, 0xe8, 0xd4, 0x66, 0x82, 0x64, 0x98, - 0xd9, 0x2a, 0x08, 0x1d, 0x35, 0x19, 0x17, 0x01, - 0x1A }, - .length = 2872, - .is_length_in_bits = true, - .plaintext = { 0xc6, 0x69, 0x73, 0x51, 0xff, 0x4a, 0xec, 0x29, - 0xcd, 0xba, 0xab, 0xf2, 0xfb, 0xe3, 0x46, 0x7c, - 0xc2, 0x54, 0xf8, 0x1b, 0xe8, 0xe7, 0x8d, 0x76, - 0x5a, 0x2e, 0x63, 0x33, 0x9f, 0xc9, 0x9a, 0x66, - 0x32, 0x0d, 0xb7, 0x31, 0x58, 0xa3, 0x5a, 0x25, - 0x5d, 0x05, 0x17, 0x58, 0xe9, 0x5e, 0xd4, 0xab, - 0xb2, 0xcd, 0xc6, 0x9b, 0xb4, 0x54, 0x11, 0x0e, - 0x82, 0x74, 0x41, 0x21, 0x3d, 0xdc, 0x87, 0x70, - 0xe9, 0x3e, 0xa1, 0x41, 0xe1, 0xfc, 0x67, 0x3e, - 0x01, 0x7e, 0x97, 0xea, 0xdc, 0x6b, 0x96, 0x8f, - 0x38, 0x5c, 0x2a, 0xec, 0xb0, 0x3b, 0xfb, 0x32, - 0xaf, 0x3c, 0x54, 0xec, 0x18, 0xdb, 0x5c, 0x02, - 0x1a, 0xfe, 0x43, 0xfb, 0xfa, 0xaa, 0x3a, 0xfb, - 0x29, 0xd1, 0xe6, 0x05, 0x3c, 0x7c, 0x94, 0x75, - 0xd8, 0xbe, 0x61, 0x89, 0xf9, 0x5c, 0xbb, 0xa8, - 0x99, 0x0f, 0x95, 0xb1, 0xeb, 0xf1, 0xb3, 0x05, - 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5, 0xca, - 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd, 0x1f, - 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5, 0x14, - 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63, 0x3b, - 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc, 0xaa, - 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b, 0x33, - 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c, 0xbb, - 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5, 0x0b, - 0xe1, 0x1a, 0x1c, 0x7f, 0x23, 0xf8, 0x29, 0xf8, - 0xa4, 0x1b, 0x13, 0xb5, 0xca, 0x4e, 0xe8, 0x98, - 0x32, 0x38, 0xe0, 0x79, 0x4d, 0x3d, 0x34, 0xbc, - 0x5f, 0x4e, 0x77, 0xfa, 0xcb, 0x6c, 0x05, 0xac, - 0x86, 0x21, 0x2b, 0xaa, 0x1a, 0x55, 0xa2, 0xbe, - 0x70, 0xb5, 0x73, 0x3b, 0x04, 0x5c, 0xd3, 0x36, - 0x94, 0xb3, 0xaf, 0xe2, 0xf0, 0xe4, 0x9e, 0x4f, - 0x32, 0x15, 0x49, 0xfd, 0x82, 0x4e, 0xa9, 0x08, - 0x70, 0xd4, 0xb2, 0x8a, 0x29, 0x54, 0x48, 0x9a, - 0x0a, 0xbc, 0xd5, 0x0e, 0x18, 0xa8, 0x44, 0xac, - 0x5b, 0xf3, 0x8e, 0x4c, 0xd7, 0x2d, 0x9b, 0x09, - 0x42, 0xe5, 0x06, 0xc4, 0x33, 0xaf, 0xcd, 0xa3, - 0x84, 0x7f, 0x2d, 0xad, 0xd4, 0x76, 0x47, 0xde, - 0x32, 0x1c, 0xec, 0x4a, 0xc4, 0x30, 0xf6, 0x20, - 0x23, 0x85, 0x6c, 0xfb, 0xb2, 0x07, 0x04, 0xf4, - 0xec, 0x0b, 0xb9, 0x20, 0xba, 0x86, 0xc3, 0x3e, - 0x05, 0xf1, 0xec, 0xd9, 0x67, 0x33, 0xb7, 0x99, - 0x50, 0xa3, 0xe3, 0x14, 0xd3, 0xd9, 0x34, 0xf7, - 0x5e, 0xa0, 0xf2, 0x10, 0xa8, 0xf6, 0x05, 0x94, - 0x01, 0xbe, 0xb4, 0xbc, 0x44, 0x78, 0xfa, 0x49, - 0x69, 0xe6, 0x23, 0xd0, 0x1a, 0xda, 0x69 }, - .ciphertext = { 0xc6, 0x69, 0x73, 0x51, 0xff, 0x4a, 0xec, 0x29, - 0xcd, 0xba, 0xab, 0xf2, 0xfb, 0xe3, 0x46, 0x7c, - 0xc2, 0x54, 0xf8, 0x1b, 0xe8, 0xe7, 0x8d, 0x76, - 0x5a, 0x2e, 0x63, 0x33, 0x9f, 0xc9, 0x9a, 0x66, - 0x32, 0x0d, 0xb7, 0x31, 0x58, 0xa3, 0x5a, 0x25, - 0x5d, 0x05, 0x17, 0x58, 0xe9, 0x5e, 0xd4, 0xab, - 0xb2, 0xcd, 0xc6, 0x9b, 0xb4, 0x54, 0x11, 0x0e, - 0x82, 0x74, 0x41, 0x21, 0x3d, 0xdc, 0x87, 0x70, - 0xe9, 0x3e, 0xa1, 0x41, 0xe1, 0xfc, 0x67, 0x3e, - 0x01, 0x7e, 0x97, 0xea, 0xdc, 0x6b, 0x96, 0x8f, - 0x38, 0x5c, 0x2a, 0xec, 0xb0, 0x3b, 0xfb, 0x32, - 0xaf, 0x3c, 0x54, 0xec, 0x18, 0xdb, 0x5c, 0x02, - 0x1a, 0xfe, 0x43, 0xfb, 0xfa, 0xaa, 0x3a, 0xfb, - 0x29, 0xd1, 0xe6, 0x05, 0x3c, 0x7c, 0x94, 0x75, - 0xd8, 0xbe, 0x61, 0x89, 0xf9, 0x5c, 0xbb, 0xa8, - 0x99, 0x0f, 0x95, 0xb1, 0xeb, 0xf1, 0xb3, 0x05, - 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5, 0xca, - 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd, 0x1f, - 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5, 0x14, - 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63, 0x3b, - 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc, 0xaa, - 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b, 0x33, - 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c, 0xbb, - 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5, 0x0b, - 0xe1, 0x1a, 0x1c, 0x7f, 0x23, 0xf8, 0x29, 0xf8, - 0xa4, 0x1b, 0x13, 0xb5, 0xca, 0x4e, 0xe8, 0x98, - 0x32, 0x38, 0xe0, 0x79, 0x4d, 0x3d, 0x34, 0xbc, - 0x5f, 0x4e, 0x77, 0xfa, 0xcb, 0x6c, 0x05, 0xac, - 0x86, 0x21, 0x2b, 0xaa, 0x1a, 0x55, 0xa2, 0xbe, - 0x70, 0xb5, 0x73, 0x3b, 0x04, 0x5c, 0xd3, 0x36, - 0x94, 0xb3, 0xaf, 0xe2, 0xf0, 0xe4, 0x9e, 0x4f, - 0x32, 0x15, 0x49, 0xfd, 0x82, 0x4e, 0xa9, 0x08, - 0x70, 0xd4, 0xb2, 0x8a, 0x29, 0x54, 0x48, 0x9a, - 0x0a, 0xbc, 0xd5, 0x0e, 0x18, 0xa8, 0x44, 0xac, - 0x5b, 0xf3, 0x8e, 0x4c, 0xd7, 0x2d, 0x9b, 0x09, - 0x42, 0xe5, 0x06, 0xc4, 0x33, 0xaf, 0xcd, 0xa3, - 0x84, 0x7f, 0x2d, 0xad, 0xd4, 0x76, 0x47, 0xde, - 0x32, 0x1c, 0xec, 0x4a, 0xc4, 0x30, 0xf6, 0x20, - 0x23, 0x85, 0x6c, 0xfb, 0xb2, 0x07, 0x04, 0xf4, - 0xec, 0x0b, 0xb9, 0x20, 0xba, 0x86, 0xc3, 0x3e, - 0x05, 0xf1, 0xec, 0xd9, 0x67, 0x33, 0xb7, 0x99, - 0x50, 0xa3, 0xe3, 0x14, 0xd3, 0xd9, 0x34, 0xf7, - 0x5e, 0xa0, 0xf2, 0x10, 0xa8, 0xf6, 0x05, 0x94, - 0x01, 0xbe, 0xb4, 0xbc, 0x44, 0x78, 0xfa, 0x49, - 0x69, 0xe6, 0x23, 0xd0, 0x1a, 0xda, 0x69 }, - .digest_length = ZUC_EIA3_DIGEST_LEN, - .digest = {0xd1, 0x1e, 0x33, 0xf6} - }, -}; - -/* - * MD5 test vectors from RFC 1321 - */ -static crypto_test_reference_t md5_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = MD5_DIGEST_LEN, - .digest = { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, - 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72} - }, - { - .length = 62, - .plaintext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, - 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, - 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }, - .ciphertext = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, - 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, - 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 }, - .digest_length = MD5_DIGEST_LEN, - .digest = { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, - 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f}, - } -}; - -/* - * SHA test vectors from Crypto++ - */ -static crypto_test_reference_t sha1_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = SHA1_DIGEST_LEN, - .digest = { 0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, - 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, - 0x9C, 0xD0, 0xD8, 0x9D}, - }, - { - .length = 56, - .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .digest_length = SHA1_DIGEST_LEN, - .digest = { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, - 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, - 0xE5, 0x46, 0x70, 0xF1}, - } -}; - -static crypto_test_reference_t sha224_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = SHA224_DIGEST_LEN, - .digest = { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22, - 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3, - 0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7, - 0xe3, 0x6c, 0x9d, 0xa7 }, - }, - { - .length = 56, - .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .digest_length = SHA224_DIGEST_LEN, - .digest = { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc, - 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50, - 0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19, - 0x52, 0x52, 0x25, 0x25}, - } -}; - -static crypto_test_reference_t sha256_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = SHA256_DIGEST_LEN, - .digest = { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, - 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, - 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, - 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad}, - }, - { - .length = 56, - .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x62, 0x63, 0x64, 0x65, - 0x63, 0x64, 0x65, 0x66, 0x64, 0x65, 0x66, 0x67, - 0x65, 0x66, 0x67, 0x68, 0x66, 0x67, 0x68, 0x69, - 0x67, 0x68, 0x69, 0x6a, 0x68, 0x69, 0x6a, 0x6b, - 0x69, 0x6a, 0x6b, 0x6c, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6c, 0x6d, 0x6e, 0x6f, - 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71}, - .digest_length = SHA256_DIGEST_LEN, - .digest = { 0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, - 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, - 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, - 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1}, - } -}; - -static crypto_test_reference_t sha384_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = SHA384_DIGEST_LEN, - .digest = { 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, - 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, - 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, - 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, - 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, - 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7}, - }, - { - .length = 112, - .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, - .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, - .digest_length = SHA384_DIGEST_LEN, - .digest = { 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, - 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, - 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, - 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, - 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, - 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39}, - } -}; - -static crypto_test_reference_t sha512_reference[] = { - { - .length = 3, - .plaintext = { 0x61, 0x62, 0x63 }, - .ciphertext = { 0x61, 0x62, 0x63 }, - .digest_length = SHA512_DIGEST_LEN, - .digest = { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, - 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, - 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, - 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a, - 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, - 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, - 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, - 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f}, - }, - { - .length = 112, - .plaintext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, - .ciphertext = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75}, - .digest_length = SHA512_DIGEST_LEN, - .digest = { 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, - 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, - 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, - 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, - 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, - 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, - 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, - 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09}, - } -}; - -static void init_reference(crypto_test_reference_t *ref, int size) +static inline void init_reference(crypto_test_reference_t *ref, int size) { int n; crypto_test_reference_t *prev = NULL; diff --git a/test/validation/api/crypto/util.c b/test/validation/api/crypto/util.c new file mode 100644 index 000000000..557e5e951 --- /dev/null +++ b/test/validation/api/crypto/util.c @@ -0,0 +1,310 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <string.h> +#include <stdio.h> +#include <stdint.h> +#include <odp_api.h> +#include <odp_cunit_common.h> +#include <odp/helper/odph_api.h> +#include "util.h" + +struct suite_context_s suite_context; + +const char *auth_alg_name(odp_auth_alg_t auth) +{ + switch (auth) { + case ODP_AUTH_ALG_NULL: + return "ODP_AUTH_ALG_NULL"; + case ODP_AUTH_ALG_MD5_HMAC: + return "ODP_AUTH_ALG_MD5_HMAC"; + case ODP_AUTH_ALG_SHA1_HMAC: + return "ODP_AUTH_ALG_SHA1_HMAC"; + case ODP_AUTH_ALG_SHA224_HMAC: + return "ODP_AUTH_ALG_SHA224_HMAC"; + case ODP_AUTH_ALG_SHA256_HMAC: + return "ODP_AUTH_ALG_SHA256_HMAC"; + case ODP_AUTH_ALG_SHA384_HMAC: + return "ODP_AUTH_ALG_SHA384_HMAC"; + case ODP_AUTH_ALG_SHA512_HMAC: + return "ODP_AUTH_ALG_SHA512_HMAC"; + case ODP_AUTH_ALG_AES_XCBC_MAC: + return "ODP_AUTH_ALG_AES_XCBC_MAC"; + case ODP_AUTH_ALG_AES_GCM: + return "ODP_AUTH_ALG_AES_GCM"; + case ODP_AUTH_ALG_AES_GMAC: + return "ODP_AUTH_ALG_AES_GMAC"; + case ODP_AUTH_ALG_AES_CCM: + return "ODP_AUTH_ALG_AES_CCM"; + case ODP_AUTH_ALG_AES_CMAC: + return "ODP_AUTH_ALG_AES_CMAC"; + case ODP_AUTH_ALG_CHACHA20_POLY1305: + return "ODP_AUTH_ALG_CHACHA20_POLY1305"; + case ODP_AUTH_ALG_KASUMI_F9: + return "ODP_AUTH_ALG_KASUMI_F9"; + case ODP_AUTH_ALG_SNOW3G_UIA2: + return "ODP_AUTH_ALG_SNOW3G_UIA2"; + case ODP_AUTH_ALG_AES_EIA2: + return "ODP_AUTH_ALG_AES_EIA2"; + case ODP_AUTH_ALG_ZUC_EIA3: + return "ODP_AUTH_ALG_ZUC_EIA3"; + case ODP_AUTH_ALG_MD5: + return "ODP_AUTH_ALG_MD5"; + case ODP_AUTH_ALG_SHA1: + return "ODP_AUTH_ALG_SHA1"; + case ODP_AUTH_ALG_SHA224: + return "ODP_AUTH_ALG_SHA224"; + case ODP_AUTH_ALG_SHA256: + return "ODP_AUTH_ALG_SHA256"; + case ODP_AUTH_ALG_SHA384: + return "ODP_AUTH_ALG_SHA384"; + case ODP_AUTH_ALG_SHA512: + return "ODP_AUTH_ALG_SHA512"; + default: + return "Unknown"; + } +} + +const char *cipher_alg_name(odp_cipher_alg_t cipher) +{ + switch (cipher) { + case ODP_CIPHER_ALG_NULL: + return "ODP_CIPHER_ALG_NULL"; + case ODP_CIPHER_ALG_DES: + return "ODP_CIPHER_ALG_DES"; + case ODP_CIPHER_ALG_3DES_CBC: + return "ODP_CIPHER_ALG_3DES_CBC"; + case ODP_CIPHER_ALG_3DES_ECB: + return "ODP_CIPHER_ALG_3DES_ECB"; + case ODP_CIPHER_ALG_AES_CBC: + return "ODP_CIPHER_ALG_AES_CBC"; + case ODP_CIPHER_ALG_AES_CTR: + return "ODP_CIPHER_ALG_AES_CTR"; + case ODP_CIPHER_ALG_AES_ECB: + return "ODP_CIPHER_ALG_AES_ECB"; + case ODP_CIPHER_ALG_AES_CFB128: + return "ODP_CIPHER_ALG_AES_CFB128"; + case ODP_CIPHER_ALG_AES_XTS: + return "ODP_CIPHER_ALG_AES_XTS"; + case ODP_CIPHER_ALG_AES_GCM: + return "ODP_CIPHER_ALG_AES_GCM"; + case ODP_CIPHER_ALG_AES_CCM: + return "ODP_CIPHER_ALG_AES_CCM"; + case ODP_CIPHER_ALG_CHACHA20_POLY1305: + return "ODP_CIPHER_ALG_CHACHA20_POLY1305"; + case ODP_CIPHER_ALG_KASUMI_F8: + return "ODP_CIPHER_ALG_KASUMI_F8"; + case ODP_CIPHER_ALG_SNOW3G_UEA2: + return "ODP_CIPHER_ALG_SNOW3G_UEA2"; + case ODP_CIPHER_ALG_AES_EEA2: + return "ODP_CIPHER_ALG_AES_EEA2"; + case ODP_CIPHER_ALG_ZUC_EEA3: + return "ODP_CIPHER_ALG_ZUC_EEA3"; + default: + return "Unknown"; + } +} + +int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) +{ + odp_crypto_capability_t capability; + + memset(&capability, 0, sizeof(odp_crypto_capability_t)); + if (odp_crypto_capability(&capability)) { + ODPH_ERR("odp_crypto_capability() failed\n"); + return ODP_TEST_INACTIVE; + } + + if (suite_context.queue != ODP_QUEUE_INVALID) { + if (suite_context.q_type == ODP_QUEUE_TYPE_PLAIN && + capability.queue_type_plain == 0) + return ODP_TEST_INACTIVE; + if (suite_context.q_type == ODP_QUEUE_TYPE_SCHED && + capability.queue_type_sched == 0) + return ODP_TEST_INACTIVE; + } + + if (suite_context.op_mode == ODP_CRYPTO_SYNC && + capability.sync_mode == ODP_SUPPORT_NO) + return ODP_TEST_INACTIVE; + if (suite_context.op_mode == ODP_CRYPTO_ASYNC && + capability.async_mode == ODP_SUPPORT_NO) + return ODP_TEST_INACTIVE; + + /* Cipher algorithms */ + switch (cipher) { + case ODP_CIPHER_ALG_NULL: + if (!capability.ciphers.bit.null) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_DES: + if (!capability.ciphers.bit.des) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_3DES_CBC: + if (!capability.ciphers.bit.trides_cbc) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_3DES_ECB: + if (!capability.ciphers.bit.trides_ecb) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_CBC: + if (!capability.ciphers.bit.aes_cbc) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_CTR: + if (!capability.ciphers.bit.aes_ctr) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_ECB: + if (!capability.ciphers.bit.aes_ecb) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_CFB128: + if (!capability.ciphers.bit.aes_cfb128) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_XTS: + if (!capability.ciphers.bit.aes_xts) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_GCM: + if (!capability.ciphers.bit.aes_gcm) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_CCM: + if (!capability.ciphers.bit.aes_ccm) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_CHACHA20_POLY1305: + if (!capability.ciphers.bit.chacha20_poly1305) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_KASUMI_F8: + if (!capability.ciphers.bit.kasumi_f8) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_SNOW3G_UEA2: + if (!capability.ciphers.bit.snow3g_uea2) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_AES_EEA2: + if (!capability.ciphers.bit.aes_eea2) + return ODP_TEST_INACTIVE; + break; + case ODP_CIPHER_ALG_ZUC_EEA3: + if (!capability.ciphers.bit.zuc_eea3) + return ODP_TEST_INACTIVE; + break; + default: + ODPH_ERR("Unsupported cipher algorithm\n"); + return ODP_TEST_INACTIVE; + } + + /* Authentication algorithms */ + switch (auth) { + case ODP_AUTH_ALG_NULL: + if (!capability.auths.bit.null) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_MD5_HMAC: + if (!capability.auths.bit.md5_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA1_HMAC: + if (!capability.auths.bit.sha1_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA224_HMAC: + if (!capability.auths.bit.sha224_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA256_HMAC: + if (!capability.auths.bit.sha256_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA384_HMAC: + if (!capability.auths.bit.sha384_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA512_HMAC: + if (!capability.auths.bit.sha512_hmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_XCBC_MAC: + if (!capability.auths.bit.aes_xcbc_mac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_GCM: + if (!capability.auths.bit.aes_gcm) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_GMAC: + if (!capability.auths.bit.aes_gmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_CCM: + if (!capability.auths.bit.aes_ccm) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_CMAC: + if (!capability.auths.bit.aes_cmac) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_CHACHA20_POLY1305: + if (!capability.auths.bit.chacha20_poly1305) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_KASUMI_F9: + if (!capability.auths.bit.kasumi_f9) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SNOW3G_UIA2: + if (!capability.auths.bit.snow3g_uia2) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_AES_EIA2: + if (!capability.auths.bit.aes_eia2) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_ZUC_EIA3: + if (!capability.auths.bit.zuc_eia3) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_MD5: + if (!capability.auths.bit.md5) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA1: + if (!capability.auths.bit.sha1) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA224: + if (!capability.auths.bit.sha224) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA256: + if (!capability.auths.bit.sha256) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA384: + if (!capability.auths.bit.sha384) + return ODP_TEST_INACTIVE; + break; + case ODP_AUTH_ALG_SHA512: + if (!capability.auths.bit.sha512) + return ODP_TEST_INACTIVE; + break; + default: + ODPH_ERR("Unsupported authentication algorithm\n"); + return ODP_TEST_INACTIVE; + } + + return ODP_TEST_ACTIVE; +} + diff --git a/test/validation/api/crypto/util.h b/test/validation/api/crypto/util.h new file mode 100644 index 000000000..a81a56820 --- /dev/null +++ b/test/validation/api/crypto/util.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef UTIL_H +#define UTIL_H + +#include <stdint.h> +#include <odp_api.h> +#include <odp_cunit_common.h> + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +struct suite_context_s { + odp_crypto_op_mode_t op_mode; + odp_pool_t pool; + odp_queue_t queue; + odp_queue_type_t q_type; + odp_event_t (*compl_queue_deq)(void); +}; + +extern struct suite_context_s suite_context; + +const char *auth_alg_name(odp_auth_alg_t auth); + +const char *cipher_alg_name(odp_cipher_alg_t cipher); + +/* + * Check if given cipher and authentication algorithms are supported + * + * cipher Cipher algorithm + * auth Authentication algorithm + * + * returns ODP_TEST_ACTIVE when both algorithms are supported or + * ODP_TEST_INACTIVE when either algorithm is not supported + */ +int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth); + +static inline void fill_with_pattern(uint8_t *buf, uint32_t len) +{ + static uint8_t value; + + for (uint32_t n = 0; n < len; n++) + buf[n] = value++; +} + +#endif diff --git a/test/validation/api/dma/dma.c b/test/validation/api/dma/dma.c index ad42c9bb3..6c8eeb00c 100644 --- a/test/validation/api/dma/dma.c +++ b/test/validation/api/dma/dma.c @@ -101,7 +101,7 @@ static int dma_suite_init(void) pkt_len = MIN(pkt_len, global.dma_capa.max_seg_len); odp_pool_param_init(&pool_param); pool_param.type = ODP_POOL_PACKET; - pool_param.pkt.num = 4; + pool_param.pkt.num = global.dma_capa.max_src_segs + global.dma_capa.max_dst_segs; pool_param.pkt.len = pkt_len; pool_param.pkt.max_len = pkt_len; @@ -173,7 +173,7 @@ static int dma_suite_term(void) return -1; } - return 0; + return odp_cunit_print_inactive(); } static void test_dma_capability(void) @@ -234,6 +234,7 @@ static void test_dma_param(uint8_t fill) memset(&dma_pool_param, fill, sizeof(dma_pool_param)); odp_dma_pool_param_init(&dma_pool_param); + CU_ASSERT(dma_pool_param.uarea_size == 0); CU_ASSERT(dma_pool_param.cache_size <= global.dma_capa.pool.max_cache_size); CU_ASSERT(dma_pool_param.cache_size >= global.dma_capa.pool.min_cache_size); } @@ -269,6 +270,54 @@ static void test_dma_debug(void) CU_ASSERT(odp_dma_destroy(dma) == 0); } +static void test_dma_same_name_null(void) +{ + odp_dma_param_t dma_param; + odp_dma_t dma_a, dma_b; + + odp_dma_param_init(&dma_param); + dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC; + dma_a = odp_dma_create(NULL, &dma_param); + + CU_ASSERT_FATAL(dma_a != ODP_DMA_INVALID); + + dma_b = odp_dma_create(NULL, &dma_param); + + CU_ASSERT_FATAL(dma_b != ODP_DMA_INVALID); + CU_ASSERT(odp_dma_to_u64(dma_a) != odp_dma_to_u64(dma_b)); + CU_ASSERT(odp_dma_destroy(dma_a) == 0); + CU_ASSERT(odp_dma_destroy(dma_b) == 0); +} + +static void test_dma_same_name_named(void) +{ + odp_dma_param_t dma_param; + const char *name = "DMA session"; + odp_dma_t dma, dma_a, dma_b; + + odp_dma_param_init(&dma_param); + dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC; + dma_a = odp_dma_create(name, &dma_param); + + CU_ASSERT_FATAL(dma_a != ODP_DMA_INVALID); + + dma = odp_dma_lookup(name); + + CU_ASSERT(odp_dma_to_u64(dma) == odp_dma_to_u64(dma_a)); + + dma_b = odp_dma_create(name, &dma_param); + + CU_ASSERT_FATAL(dma_b != ODP_DMA_INVALID); + + dma = odp_dma_lookup(name); + + CU_ASSERT(odp_dma_to_u64(dma) == odp_dma_to_u64(dma_a) || + odp_dma_to_u64(dma) == odp_dma_to_u64(dma_b)); + CU_ASSERT(odp_dma_to_u64(dma_a) != odp_dma_to_u64(dma_b)); + CU_ASSERT(odp_dma_destroy(dma_a) == 0); + CU_ASSERT(odp_dma_destroy(dma_b) == 0); +} + static void test_dma_compl_pool(void) { odp_pool_t pool; @@ -291,6 +340,7 @@ static void test_dma_compl_pool(void) CU_ASSERT(pool_info.pool_ext == 0); CU_ASSERT(pool_info.type == ODP_POOL_DMA_COMPL); CU_ASSERT(pool_info.dma_pool_param.num == global.dma_capa.max_transfers); + CU_ASSERT(pool_info.dma_pool_param.uarea_size == 0); CU_ASSERT(pool_info.dma_pool_param.cache_size == global.cache_size); for (i = 0; i < global.dma_capa.max_transfers; i++) { @@ -364,6 +414,50 @@ static void test_dma_compl_pool_max_pools(void) } } +static void test_dma_compl_user_area(void) +{ + odp_dma_pool_param_t dma_pool_param; + uint32_t num = MIN(10, global.dma_capa.pool.max_num), + size = global.dma_capa.pool.max_uarea_size, i; + odp_pool_t pool; + odp_dma_compl_t compl_evs[num]; + void *addr, *prev = NULL; + + odp_dma_pool_param_init(&dma_pool_param); + dma_pool_param.num = num; + dma_pool_param.uarea_size = size; + pool = odp_dma_pool_create(NULL, &dma_pool_param); + + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + for (i = 0; i < num; i++) { + odp_event_t ev; + + compl_evs[i] = odp_dma_compl_alloc(pool); + + if (compl_evs[i] == ODP_DMA_COMPL_INVALID) + break; + + addr = odp_dma_compl_user_area(compl_evs[i]); + + CU_ASSERT_FATAL(addr != NULL); + CU_ASSERT(prev != addr); + + ev = odp_dma_compl_to_event(compl_evs[i]); + CU_ASSERT(odp_event_user_area(ev) == addr); + + prev = addr; + memset(addr, 0, size); + } + + CU_ASSERT(i == num); + + for (uint32_t j = 0; j < i; j++) + odp_dma_compl_free(compl_evs[j]); + + CU_ASSERT(odp_pool_destroy(pool) == 0); +} + static void init_source(uint8_t *src, uint32_t len) { uint32_t i; @@ -1043,6 +1137,17 @@ static int check_sync(void) return ODP_TEST_ACTIVE; } +static int check_session_count(void) +{ + if (global.disabled) + return ODP_TEST_INACTIVE; + + if (global.dma_capa.max_sessions > 1) + return ODP_TEST_ACTIVE; + + return ODP_TEST_INACTIVE; +} + static int check_event(void) { if (global.disabled) @@ -1054,6 +1159,18 @@ static int check_event(void) return ODP_TEST_INACTIVE; } +static int check_event_user_area(void) +{ + if (global.disabled) + return ODP_TEST_INACTIVE; + + if ((global.dma_capa.compl_mode_mask & ODP_DMA_COMPL_EVENT) && + global.dma_capa.pool.max_uarea_size > 0) + return ODP_TEST_ACTIVE; + + return ODP_TEST_INACTIVE; +} + static int check_scheduled(void) { if (global.disabled) @@ -1126,6 +1243,72 @@ static void test_dma_addr_to_addr_sync_res(void) test_dma_addr_to_addr(ODP_DMA_COMPL_SYNC, 1, 0, RESULT); } +static void get_seg_lens(uint32_t max_len, uint32_t *src, uint32_t *dst) +{ + uint32_t src_segs = *src, dst_segs = *dst; + + *src = max_len / src_segs; + *dst = *src * src_segs / dst_segs + *src * src_segs % dst_segs; +} + +static void test_dma_addr_to_addr_sync_max_seg(void) +{ + odp_dma_param_t dma_param; + odp_dma_transfer_param_t trs_param; + odp_dma_t dma; + odp_dma_seg_t src_seg[global.dma_capa.max_src_segs]; + odp_dma_seg_t dst_seg[global.dma_capa.max_dst_segs]; + uint32_t src_len = global.dma_capa.max_src_segs, dst_len = global.dma_capa.max_dst_segs, + len; + int ret; + + init_source(global.src_addr, global.data_size); + memset(global.dst_addr, 0, global.data_size); + odp_dma_param_init(&dma_param); + dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC; + dma = odp_dma_create("addr_to_addr_max_seg", &dma_param); + + CU_ASSERT_FATAL(dma != ODP_DMA_INVALID); + + get_seg_lens(global.len, &src_len, &dst_len); + + for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) { + uint8_t *addr = global.src_addr + i * src_len; + + memset(&src_seg[i], 0, sizeof(odp_dma_seg_t)); + src_seg[i].addr = addr; + src_seg[i].len = src_len; + } + + len = src_len * global.dma_capa.max_src_segs; + + for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) { + uint8_t *addr = global.dst_addr + i * dst_len; + + memset(&dst_seg[i], 0, sizeof(odp_dma_seg_t)); + dst_seg[i].addr = addr; + dst_seg[i].len = MIN(len, dst_len); + len -= dst_len; + } + + odp_dma_transfer_param_init(&trs_param); + trs_param.src_format = ODP_DMA_FORMAT_ADDR; + trs_param.dst_format = ODP_DMA_FORMAT_ADDR; + trs_param.num_src = global.dma_capa.max_src_segs; + trs_param.num_dst = global.dma_capa.max_dst_segs; + trs_param.src_seg = src_seg; + trs_param.dst_seg = dst_seg; + ret = do_transfer(dma, &trs_param, 0, 0); + + if (ret > 0) { + len = src_len * global.dma_capa.max_src_segs; + + CU_ASSERT(check_equal(global.src_addr, global.dst_addr, len) == 0); + } + + CU_ASSERT(odp_dma_destroy(dma) == 0); +} + static void test_dma_addr_to_pkt_sync(void) { test_dma_addr_to_pkt(ODP_DMA_COMPL_SYNC, 0); @@ -1141,6 +1324,87 @@ static void test_dma_pkt_to_pkt_sync(void) test_dma_pkt_to_pkt(ODP_DMA_COMPL_SYNC, 0); } +static void test_dma_pkt_to_pkt_sync_max_seg(void) +{ + odp_dma_param_t dma_param; + odp_dma_transfer_param_t trs_param; + odp_dma_t dma; + odp_packet_t pkt; + odp_dma_seg_t src_seg[global.dma_capa.max_src_segs]; + odp_dma_seg_t dst_seg[global.dma_capa.max_dst_segs]; + uint32_t src_len = global.dma_capa.max_src_segs, dst_len = global.dma_capa.max_dst_segs, + len; + int ret; + + odp_dma_param_init(&dma_param); + dma_param.compl_mode_mask = ODP_DMA_COMPL_SYNC; + dma = odp_dma_create("pkt_to_pkt_max_seg", &dma_param); + + CU_ASSERT_FATAL(dma != ODP_DMA_INVALID); + + pkt = odp_packet_alloc(global.pkt_pool, global.pkt_len); + + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + get_seg_lens(odp_packet_seg_len(pkt), &src_len, &dst_len); + odp_packet_free(pkt); + + for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) { + pkt = odp_packet_alloc(global.pkt_pool, src_len); + + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + init_source(odp_packet_data(pkt), src_len); + memset(&src_seg[i], 0, sizeof(odp_dma_seg_t)); + src_seg[i].packet = pkt; + src_seg[i].len = src_len; + } + + len = src_len * global.dma_capa.max_src_segs; + + for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) { + pkt = odp_packet_alloc(global.pkt_pool, dst_len); + + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + + memset(odp_packet_data(pkt), 0, dst_len); + memset(&dst_seg[i], 0, sizeof(odp_dma_seg_t)); + dst_seg[i].packet = pkt; + dst_seg[i].len = MIN(len, dst_len); + len -= dst_len; + } + + odp_dma_transfer_param_init(&trs_param); + trs_param.src_format = ODP_DMA_FORMAT_PACKET; + trs_param.dst_format = ODP_DMA_FORMAT_PACKET; + trs_param.num_src = global.dma_capa.max_src_segs; + trs_param.num_dst = global.dma_capa.max_dst_segs; + trs_param.src_seg = src_seg; + trs_param.dst_seg = dst_seg; + ret = do_transfer(dma, &trs_param, 0, 0); + + if (ret > 0) { + len = src_len * global.dma_capa.max_src_segs; + uint8_t src[len], dst[len]; + + for (uint32_t i = 0; i < global.dma_capa.max_src_segs; i++) { + memcpy(src + i * src_len, odp_packet_data(src_seg[i].packet), + src_seg[i].len); + odp_packet_free(src_seg[i].packet); + } + + for (uint32_t i = 0; i < global.dma_capa.max_dst_segs; i++) { + memcpy(dst + i * dst_len, odp_packet_data(dst_seg[i].packet), + dst_seg[i].len); + odp_packet_free(dst_seg[i].packet); + } + + CU_ASSERT(check_equal(src, dst, len) == 0); + } + + CU_ASSERT(odp_dma_destroy(dma) == 0); +} + static void test_dma_addr_to_addr_poll(void) { test_dma_addr_to_addr(ODP_DMA_COMPL_POLL, 1, 0, 0); @@ -1298,16 +1562,21 @@ odp_testinfo_t dma_suite[] = { ODP_TEST_INFO(test_dma_capability), ODP_TEST_INFO_CONDITIONAL(test_dma_param_init, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_debug, check_sync), + ODP_TEST_INFO_CONDITIONAL(test_dma_same_name_null, check_session_count), + ODP_TEST_INFO_CONDITIONAL(test_dma_same_name_named, check_session_count), ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool, check_event), ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool_same_name, check_event), ODP_TEST_INFO_CONDITIONAL(test_dma_compl_pool_max_pools, check_event), + ODP_TEST_INFO_CONDITIONAL(test_dma_compl_user_area, check_event_user_area), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mtrs, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_mseg, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_res, check_sync), + ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_sync_max_seg, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_pkt_sync, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_addr_sync, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_pkt_sync, check_sync), + ODP_TEST_INFO_CONDITIONAL(test_dma_pkt_to_pkt_sync_max_seg, check_sync), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll, check_poll), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll_mtrs, check_poll), ODP_TEST_INFO_CONDITIONAL(test_dma_addr_to_addr_poll_mseg, check_poll), diff --git a/test/validation/api/init/.gitignore b/test/validation/api/init/.gitignore index e312d2cf6..4e14eb040 100644 --- a/test/validation/api/init/.gitignore +++ b/test/validation/api/init/.gitignore @@ -6,3 +6,4 @@ init_num_thr init_feature_enabled init_feature_disabled init_test_param_init +init_test_term_abnormal diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am index 1ddf1dd0d..8226b87ce 100644 --- a/test/validation/api/init/Makefile.am +++ b/test/validation/api/init/Makefile.am @@ -4,7 +4,7 @@ include ../Makefile.inc # the same application process to call odp_init_global() multiple times. test_PROGRAMS = init_defaults init_abort init_log init_num_thr \ init_feature_enabled init_feature_disabled init_log_thread \ - init_test_param_init + init_test_param_init init_test_term_abnormal init_defaults_CPPFLAGS = -DINIT_TEST=0 $(AM_CPPFLAGS) init_abort_CPPFLAGS = -DINIT_TEST=1 $(AM_CPPFLAGS) @@ -14,6 +14,7 @@ init_feature_enabled_CPPFLAGS = -DINIT_TEST=4 $(AM_CPPFLAGS) init_feature_disabled_CPPFLAGS = -DINIT_TEST=5 $(AM_CPPFLAGS) init_log_thread_CPPFLAGS = -DINIT_TEST=6 $(AM_CPPFLAGS) init_test_param_init_CPPFLAGS = -DINIT_TEST=7 $(AM_CPPFLAGS) +init_test_term_abnormal_CPPFLAGS = -DINIT_TEST=8 $(AM_CPPFLAGS) init_defaults_SOURCES = init_main.c init_abort_SOURCES = init_main.c @@ -23,3 +24,4 @@ init_feature_enabled_SOURCES = init_main.c init_feature_disabled_SOURCES = init_main.c init_log_thread_SOURCES = init_main.c init_test_param_init_SOURCES = init_main.c +init_test_term_abnormal_SOURCES = init_main.c diff --git a/test/validation/api/init/init_main.c b/test/validation/api/init/init_main.c index 5cbaf72eb..c3dba105e 100644 --- a/test/validation/api/init/init_main.c +++ b/test/validation/api/init/init_main.c @@ -1,11 +1,12 @@ /* Copyright (c) 2015-2018, Linaro Limited - * Copyright (c) 2019-2022, Nokia + * Copyright (c) 2019-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include <odp_api.h> +#include <odp/helper/odph_api.h> #include <odp_cunit_common.h> #include <stdarg.h> @@ -241,6 +242,24 @@ static void init_test_feature_disabled(void) init_test_feature(1); } +static void init_test_term_abnormal(void) +{ + int ret; + odp_instance_t instance; + + ret = odp_init_global(&instance, NULL, NULL); + CU_ASSERT_FATAL(ret == 0); + + ret = odp_init_local(instance, ODP_THREAD_WORKER); + CU_ASSERT_FATAL(ret == 0); + + /* odp_term_abnormal() is allowed to fail */ + ret = odp_term_abnormal(instance, 0, NULL); + + if (ret < 0) + ODPH_ERR("Failed to perform all abnormal termination actions: %d\n", ret); +} + odp_testinfo_t testinfo[] = { ODP_TEST_INFO(init_test_defaults), ODP_TEST_INFO(init_test_abort), @@ -250,6 +269,7 @@ odp_testinfo_t testinfo[] = { ODP_TEST_INFO(init_test_feature_disabled), ODP_TEST_INFO(init_test_log_thread), ODP_TEST_INFO(init_test_param_init), + ODP_TEST_INFO(init_test_term_abnormal) }; odp_testinfo_t init_suite[] = { @@ -265,7 +285,7 @@ odp_suiteinfo_t init_suites[] = { static int fill_testinfo(odp_testinfo_t *info, unsigned int test_case) { if (test_case >= (sizeof(testinfo) / sizeof(odp_testinfo_t))) { - printf("Bad test case number %u\n", test_case); + ODPH_ERR("Bad test case number %u\n", test_case); return -1; } diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 11860bf9b..ea2685666 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -57,12 +57,12 @@ static odp_pktio_t pktio_create(odp_pool_t pool) if (pktio == ODP_PKTIO_INVALID) { ret = odp_pool_destroy(pool); if (ret) - fprintf(stderr, "unable to destroy pool.\n"); + ODPH_ERR("Unable to destroy pool\n"); return ODP_PKTIO_INVALID; } if (odp_pktio_capability(pktio, &capa)) { - fprintf(stderr, "pktio capabilities failed.\n"); + ODPH_ERR("Pktio capabilities failed\n"); return ODP_PKTIO_INVALID; } @@ -70,12 +70,12 @@ static odp_pktio_t pktio_create(odp_pool_t pool) pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC; if (odp_pktin_queue_config(pktio, &pktin_param)) { - fprintf(stderr, "pktin queue config failed.\n"); + ODPH_ERR("Pktin queue config failed\n"); return ODP_PKTIO_INVALID; } if (odp_pktout_queue_config(pktio, NULL)) { - fprintf(stderr, "pktout queue config failed.\n"); + ODPH_ERR("Pktout queue config failed\n"); return ODP_PKTIO_INVALID; } @@ -213,7 +213,7 @@ static void pktio_stop(odp_pktio_t pktio) odp_pktin_event_queue(pktio, &queue, 1); if (odp_pktio_stop(pktio)) - fprintf(stderr, "IPsec pktio stop failed.\n"); + ODPH_ERR("IPsec pktio stop failed\n"); while (1) { odp_event_t ev = recv_event(queue, 0); @@ -266,7 +266,7 @@ int ipsec_check(odp_bool_t ah, if (ah && (ODP_SUPPORT_NO == capa.proto_ah)) return ODP_TEST_INACTIVE; - if (odph_ipsec_alg_check(capa, cipher, cipher_bits / 8, auth, + if (odph_ipsec_alg_check(&capa, cipher, cipher_bits / 8, auth, auth_bits / 8) < 0) return ODP_TEST_INACTIVE; @@ -395,7 +395,10 @@ void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param, param->dir = dir; if (dir == ODP_IPSEC_DIR_INBOUND) { param->inbound.lookup_mode = ODP_IPSEC_LOOKUP_SPI; - param->inbound.antireplay_ws = capa.max_antireplay_ws; + if (auth_alg == ODP_AUTH_ALG_NULL) + param->inbound.antireplay_ws = 0; + else + param->inbound.antireplay_ws = capa.max_antireplay_ws; } param->proto = proto; @@ -455,6 +458,9 @@ static void ipsec_status_event_handle(odp_event_t ev_status, CU_ASSERT_EQUAL(1, odp_event_is_valid(ev_status)); CU_ASSERT_EQUAL_FATAL(ODP_EVENT_IPSEC_STATUS, odp_event_type(ev_status)); + /* No user area for IPsec status events */ + CU_ASSERT(odp_event_user_area(ev_status) == NULL); + CU_ASSERT_EQUAL(0, odp_ipsec_status(&status, ev_status)); CU_ASSERT_EQUAL(ODP_IPSEC_STATUS_WARN, status.id); CU_ASSERT_EQUAL(sa, status.sa); @@ -1276,7 +1282,7 @@ int ipsec_suite_term(void) if (ODP_QUEUE_INVALID != suite_context.queue) { if (odp_queue_destroy(suite_context.queue)) - fprintf(stderr, "IPsec destq destroy failed.\n"); + ODPH_ERR("IPsec destq destroy failed\n"); } if (odp_cunit_print_inactive()) @@ -1329,7 +1335,7 @@ int ipsec_suite_plain_init(void) dest_queue = plain_queue_create("ipsec-out"); if (ODP_QUEUE_INVALID == dest_queue) { - fprintf(stderr, "IPsec destq creation failed.\n"); + ODPH_ERR("IPsec destq creation failed\n"); return -1; } @@ -1345,7 +1351,7 @@ int ipsec_suite_sched_init(void) dest_queue = sched_queue_create("ipsec-out"); if (ODP_QUEUE_INVALID == dest_queue) { - fprintf(stderr, "IPsec destq creation failed.\n"); + ODPH_ERR("IPsec destq creation failed\n"); return -1; } @@ -1371,7 +1377,7 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode) suite_context.default_queue = ODP_QUEUE_INVALID; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -1379,22 +1385,22 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } if (odp_schedule_config(NULL)) { - fprintf(stderr, "odp_schedule_config() failed.\n"); + ODPH_ERR("odp_schedule_config() failed\n"); return -1; } if (odp_pool_capability(&pool_capa) < 0) { - fprintf(stderr, "error: odp_pool_capability() failed.\n"); + ODPH_ERR("odp_pool_capability() failed\n"); return -1; } @@ -1406,27 +1412,27 @@ int ipsec_init(odp_instance_t *inst, odp_ipsec_op_mode_t mode) if (pool_capa.pkt.max_seg_len && MAX_PKT_LEN > pool_capa.pkt.max_seg_len) { - fprintf(stderr, "Warning: small packet segment length\n"); + ODPH_ERR("Warning: small packet segment length\n"); params.pkt.seg_len = pool_capa.pkt.max_seg_len; } if (pool_capa.pkt.max_len && MAX_PKT_LEN > pool_capa.pkt.max_len) { - fprintf(stderr, "Pool max packet length too small\n"); + ODPH_ERR("Pool max packet length too small\n"); return -1; } pool = odp_pool_create("packet_pool", ¶ms); if (ODP_POOL_INVALID == pool) { - fprintf(stderr, "Packet pool creation failed.\n"); + ODPH_ERR("Packet pool creation failed\n"); return -1; } if (mode == ODP_IPSEC_OP_MODE_INLINE) { pktio = pktio_create(pool); if (ODP_PKTIO_INVALID == pktio) { - fprintf(stderr, "IPsec pktio creation failed.\n"); + ODPH_ERR("IPsec pktio creation failed\n"); return -1; } } @@ -1466,7 +1472,7 @@ int ipsec_config(odp_instance_t ODP_UNUSED inst) suite_context.default_queue = sched_queue_create("ipsec-default"); if (ODP_QUEUE_INVALID == suite_context.default_queue) { - fprintf(stderr, "IPsec defaultq creation failed.\n"); + ODPH_ERR("IPsec defaultq creation failed\n"); return -1; } } @@ -1561,26 +1567,26 @@ int ipsec_term(odp_instance_t inst) if (ODP_PKTIO_INVALID != pktio) { if (odp_pktio_close(pktio)) - fprintf(stderr, "IPsec pktio close failed.\n"); + ODPH_ERR("IPsec pktio close failed\n"); } if (ODP_QUEUE_INVALID != default_queue) { if (odp_queue_destroy(default_queue)) - fprintf(stderr, "IPsec defaultq destroy failed.\n"); + ODPH_ERR("IPsec defaultq destroy failed\n"); } if (ODP_POOL_INVALID != pool) { if (odp_pool_destroy(pool)) - fprintf(stderr, "Packet pool destroy failed.\n"); + ODPH_ERR("Packet pool destroy failed\n"); } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/lock/lock.c b/test/validation/api/lock/lock.c index 729994d66..5210f7e5d 100644 --- a/test/validation/api/lock/lock.c +++ b/test/validation/api/lock/lock.c @@ -569,12 +569,12 @@ static int spinlock_functional_test(void *arg UNUSED) if ((global_mem->g_verbose) && ((sync_failures != 0) || (is_locked_errs != 0))) - printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32 - " sync_failures and %" PRIu32 - " is_locked_errs in %" PRIu32 - " iterations\n", thread_num, - per_thread_mem->thread_id, per_thread_mem->thread_core, - sync_failures, is_locked_errs, iterations); + ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32 + " sync_failures and %" PRIu32 + " is_locked_errs in %" PRIu32 + " iterations\n", thread_num, + per_thread_mem->thread_id, per_thread_mem->thread_core, + sync_failures, is_locked_errs, iterations); CU_ASSERT(sync_failures == 0); CU_ASSERT(is_locked_errs == 0); @@ -675,14 +675,14 @@ static int spinlock_recursive_functional_test(void *arg UNUSED) if ((global_mem->g_verbose) && (sync_failures != 0 || recursive_errs != 0 || is_locked_errs != 0)) - printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32 - " sync_failures and %" PRIu32 - " recursive_errs and %" PRIu32 - " is_locked_errs in %" PRIu32 - " iterations\n", thread_num, - per_thread_mem->thread_id, per_thread_mem->thread_core, - sync_failures, recursive_errs, is_locked_errs, - iterations); + ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32 + " sync_failures and %" PRIu32 + " recursive_errs and %" PRIu32 + " is_locked_errs in %" PRIu32 + " iterations\n", thread_num, + per_thread_mem->thread_id, per_thread_mem->thread_core, + sync_failures, recursive_errs, is_locked_errs, + iterations); CU_ASSERT(sync_failures == 0); CU_ASSERT(recursive_errs == 0); @@ -765,12 +765,12 @@ static int ticketlock_functional_test(void *arg UNUSED) if ((global_mem->g_verbose) && ((sync_failures != 0) || (is_locked_errs != 0))) - printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32 - " sync_failures and %" PRIu32 - " is_locked_errs in %" PRIu32 " iterations\n", - thread_num, - per_thread_mem->thread_id, per_thread_mem->thread_core, - sync_failures, is_locked_errs, iterations); + ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32 + " sync_failures and %" PRIu32 + " is_locked_errs in %" PRIu32 " iterations\n", + thread_num, + per_thread_mem->thread_id, per_thread_mem->thread_core, + sync_failures, is_locked_errs, iterations); CU_ASSERT(sync_failures == 0); CU_ASSERT(is_locked_errs == 0); @@ -858,11 +858,11 @@ static int rwlock_functional_test(void *arg UNUSED) } if ((global_mem->g_verbose) && (sync_failures != 0)) - printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32 - " sync_failures in %" PRIu32 " iterations\n", thread_num, - per_thread_mem->thread_id, - per_thread_mem->thread_core, - sync_failures, iterations); + ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32 + " sync_failures in %" PRIu32 " iterations\n", thread_num, + per_thread_mem->thread_id, + per_thread_mem->thread_core, + sync_failures, iterations); CU_ASSERT(sync_failures == 0); @@ -985,13 +985,13 @@ static int rwlock_recursive_functional_test(void *arg UNUSED) } if ((global_mem->g_verbose) && (sync_failures != 0)) - printf("\nThread %" PRIu32 " (id=%d core=%d) had %" PRIu32 - " sync_failures and %" PRIu32 - " recursive_errs in %" PRIu32 - " iterations\n", thread_num, - per_thread_mem->thread_id, - per_thread_mem->thread_core, - sync_failures, recursive_errs, iterations); + ODPH_ERR("Thread %" PRIu32 " (id=%d core=%d) had %" PRIu32 + " sync_failures and %" PRIu32 + " recursive_errs in %" PRIu32 + " iterations\n", thread_num, + per_thread_mem->thread_id, + per_thread_mem->thread_core, + sync_failures, recursive_errs, iterations); CU_ASSERT(sync_failures == 0); CU_ASSERT(recursive_errs == 0); @@ -1153,7 +1153,7 @@ static int lock_init(odp_instance_t *inst) odph_helper_options_t helper_options; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -1161,18 +1161,18 @@ static int lock_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } global_shm = odp_shm_reserve(GLOBAL_SHM_NAME, sizeof(global_shared_mem_t), 64, 0); if (ODP_SHM_INVALID == global_shm) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); + ODPH_ERR("Unable to reserve memory for global_shm\n"); return -1; } @@ -1208,17 +1208,17 @@ static int lock_term(odp_instance_t inst) shm = odp_shm_lookup(GLOBAL_SHM_NAME); if (0 != odp_shm_free(shm)) { - fprintf(stderr, "error: odp_shm_free() failed.\n"); + ODPH_ERR("odp_shm_free() failed\n"); return -1; } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index c654aa055..a7631d47c 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -200,7 +200,7 @@ static int packet_suite_init(void) memset(&pool_capa, 0, sizeof(odp_pool_capability_t)); if (odp_pool_capability(&pool_capa) < 0) { - printf("pool_capability failed\n"); + ODPH_ERR("odp_pool_capability() failed\n"); return -1; } @@ -246,14 +246,14 @@ static int packet_suite_init(void) default_pool = odp_pool_create("default_pool", ¶ms); if (default_pool == ODP_POOL_INVALID) { - printf("default pool create failed\n"); + ODPH_ERR("Default pool create failed\n"); return -1; } test_packet = odp_packet_alloc(default_pool, packet_len); if (test_packet == ODP_PACKET_INVALID) { - printf("test_packet alloc failed\n"); + ODPH_ERR("Packet alloc failed\n"); return -1; } @@ -277,7 +277,7 @@ static int packet_suite_init(void) segmented_packet_len > pool_capa.pkt.min_seg_len); if (ret != PACKET_POOL_NUM_SEG) { - printf("packet alloc failed\n"); + ODPH_ERR("Packet alloc failed\n"); return -1; } segmented_test_packet = pkt_tbl[0]; @@ -285,7 +285,7 @@ static int packet_suite_init(void) if (odp_packet_is_valid(test_packet) == 0 || odp_packet_is_valid(segmented_test_packet) == 0) { - printf("packet_is_valid failed\n"); + ODPH_ERR("odp_packet_is_valid() failed\n"); return -1; } @@ -299,7 +299,7 @@ static int packet_suite_init(void) udat = odp_packet_user_area(test_packet); if (odp_packet_user_area_size(test_packet) < uarea_size) { - printf("Bad packet user area size %u\n", odp_packet_user_area_size(test_packet)); + ODPH_ERR("Bad packet user area size %u\n", odp_packet_user_area_size(test_packet)); return -1; } @@ -308,8 +308,8 @@ static int packet_suite_init(void) udat = odp_packet_user_area(segmented_test_packet); if (odp_packet_user_area_size(segmented_test_packet) < uarea_size) { - printf("Bad segmented packet user area size %u\n", - odp_packet_user_area_size(segmented_test_packet)); + ODPH_ERR("Bad segmented packet user area size %u\n", + odp_packet_user_area_size(segmented_test_packet)); return -1; } @@ -873,6 +873,12 @@ static void packet_test_basic_metadata(void) CU_ASSERT(!odp_time_cmp(ts, odp_packet_ts(pkt))); odp_packet_has_ts_clr(pkt); CU_ASSERT(!odp_packet_has_ts(pkt)); + + CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DISABLED); + odp_packet_free_ctrl_set(pkt, ODP_PACKET_FREE_CTRL_DONT_FREE); + CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DONT_FREE); + odp_packet_free_ctrl_set(pkt, ODP_PACKET_FREE_CTRL_DISABLED); + CU_ASSERT(odp_packet_free_ctrl(pkt) == ODP_PACKET_FREE_CTRL_DISABLED); } static void packet_test_length(void) @@ -3255,6 +3261,8 @@ static void packet_vector_test_user_area(void) CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); for (i = 0; i < num; i++) { + odp_event_t ev; + pktv[i] = odp_packet_vector_alloc(pool); if (pktv[i] == ODP_PACKET_VECTOR_INVALID) @@ -3265,6 +3273,9 @@ static void packet_vector_test_user_area(void) CU_ASSERT_FATAL(addr != NULL); CU_ASSERT(prev != addr); + ev = odp_packet_vector_to_event(pktv[i]); + CU_ASSERT(odp_event_user_area(ev) == addr); + prev = addr; memset(addr, 0, size); } @@ -3337,14 +3348,14 @@ static int packet_vector_suite_init(void) vector_default_pool = odp_pool_create("vector_default_pool", ¶ms); if (vector_default_pool == ODP_POOL_INVALID) { - ODPH_ERR("default vector pool create failed\n"); + ODPH_ERR("Default vector pool create failed\n"); goto err1; } /* Allocating a default vector */ pktv_default = odp_packet_vector_alloc(vector_default_pool); if (pktv_default == ODP_PACKET_VECTOR_INVALID) { - ODPH_ERR("default vector packet allocation failed\n"); + ODPH_ERR("Default vector packet allocation failed\n"); goto err2; } return 0; @@ -3400,7 +3411,7 @@ static void packet_test_max_pools(void) CU_ASSERT(num_pool == max_pools); if (num_pool != max_pools) - printf("Error: created only %u pools\n", num_pool); + ODPH_ERR("Created only %u pools\n", num_pool); for (i = 0; i < num_pool; i++) { packet[i] = odp_packet_alloc(pool[i], len); @@ -3436,6 +3447,7 @@ static void packet_test_user_area(void) odp_pool_param_t param; odp_packet_t pkt; odp_pool_t pool; + odp_event_t ev; memcpy(¶m, &default_param, sizeof(odp_pool_param_t)); @@ -3451,6 +3463,8 @@ static void packet_test_user_area(void) } else { CU_ASSERT(odp_packet_user_area(pkt) == NULL); } + ev = odp_packet_to_event(pkt); + CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt)); odp_packet_free(pkt); CU_ASSERT(odp_pool_destroy(pool) == 0); @@ -3464,6 +3478,8 @@ static void packet_test_user_area(void) pkt = odp_packet_alloc(pool, param.pkt.len); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL); + ev = odp_packet_to_event(pkt); + CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt)); CU_ASSERT(odp_packet_user_area_size(pkt) >= 1); *(char *)odp_packet_user_area(pkt) = 0; CU_ASSERT_FATAL(odp_packet_is_valid(pkt) == 1); @@ -3476,6 +3492,8 @@ static void packet_test_user_area(void) pkt = odp_packet_alloc(pool, param.pkt.len); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); CU_ASSERT_FATAL(odp_packet_user_area(pkt) != NULL); + ev = odp_packet_to_event(pkt); + CU_ASSERT(odp_event_user_area(ev) == odp_packet_user_area(pkt)); CU_ASSERT(odp_packet_user_area_size(pkt) == param.pkt.uarea_size); memset(odp_packet_user_area(pkt), 0, param.pkt.uarea_size); CU_ASSERT_FATAL(odp_packet_is_valid(pkt) == 1); @@ -3492,7 +3510,7 @@ static int packet_parse_suite_init(void) memset(&pool_capa, 0, sizeof(odp_pool_capability_t)); if (odp_pool_capability(&pool_capa) < 0) { - printf("pool_capability failed\n"); + ODPH_ERR("odp_pool_capability() failed\n"); return -1; } diff --git a/test/validation/api/pktio/parser.c b/test/validation/api/pktio/parser.c index 2b5042724..7d243877c 100644 --- a/test/validation/api/pktio/parser.c +++ b/test/validation/api/pktio/parser.c @@ -70,20 +70,19 @@ static int pkt_pool_create(void) odp_pool_param_t params; if (odp_pool_capability(&capa) != 0) { - printf("Error: unable to query pool capability.\n"); + ODPH_ERR("Unable to query pool capability\n"); return -1; } if (capa.pkt.max_num && capa.pkt.max_num < PKT_POOL_NUM) { - printf("Error: packet pool size not supported.\n"); - printf("MAX: %" PRIu32 "\n", capa.pkt.max_num); + ODPH_ERR("Packet pool size not supported: MAX=%" PRIu32 "\n", capa.pkt.max_num); return -1; } else if (capa.pkt.max_len && capa.pkt.max_len < PKT_POOL_BUF_LEN) { - printf("Error: packet length not supported.\n"); + ODPH_ERR("Packet length not supported\n"); return -1; } else if (capa.pkt.max_seg_len && capa.pkt.max_seg_len < PKT_POOL_BUF_LEN) { - printf("Error: segment length not supported.\n"); + ODPH_ERR("Segment length not supported\n"); return -1; } @@ -95,7 +94,7 @@ static int pkt_pool_create(void) parser_pool = odp_pool_create("pkt_pool_default", ¶ms); if (parser_pool == ODP_POOL_INVALID) { - printf("Error: packet pool create failed.\n"); + ODPH_ERR("Packet pool create failed\n"); return -1; } @@ -115,24 +114,24 @@ static odp_pktio_t create_pktio(int iface_idx, odp_pool_t pool) pktio = odp_pktio_open(iface, pool, &pktio_param); if (pktio == ODP_PKTIO_INVALID) { - printf("Error: failed to open %s\n", iface); + ODPH_ERR("Failed to open %s\n", iface); return ODP_PKTIO_INVALID; } odp_pktio_config_init(&config); config.parser.layer = ODP_PROTO_LAYER_ALL; if (odp_pktio_config(pktio, &config)) { - printf("Error: failed to configure %s\n", iface); + ODPH_ERR("Failed to configure %s\n", iface); return ODP_PKTIO_INVALID; } /* By default, single input and output queue is used */ if (odp_pktin_queue_config(pktio, NULL)) { - printf("Error: failed to config input queue for %s\n", iface); + ODPH_ERR("Failed to config input queue for %s\n", iface); return ODP_PKTIO_INVALID; } if (odp_pktout_queue_config(pktio, NULL)) { - printf("Error: failed to config output queue for %s\n", iface); + ODPH_ERR("Failed to config output queue for %s\n", iface); return ODP_PKTIO_INVALID; } @@ -151,7 +150,7 @@ static odp_packet_t create_packet(const uint8_t *data, uint32_t len) return ODP_PACKET_INVALID; if (odp_packet_copy_from_mem(pkt, 0, len, data)) { - printf("Error: failed to copy test packet data\n"); + ODPH_ERR("Failed to copy test packet data\n"); odp_packet_free(pkt); return ODP_PACKET_INVALID; } @@ -513,7 +512,7 @@ int parser_suite_init(void) } if (pkt_pool_create() != 0) { - printf("Error: failed to create parser pool\n"); + ODPH_ERR("Failed to create parser pool\n"); return -1; } @@ -525,22 +524,22 @@ int parser_suite_init(void) io->name = iface_name[i]; io->hdl = create_pktio(i, parser_pool); if (io->hdl == ODP_PKTIO_INVALID) { - printf("Error: failed to open iface"); + ODPH_ERR("Failed to open iface"); return -1; } if (odp_pktout_queue(io->hdl, &io->pktout, 1) != 1) { - printf("Error: failed to start iface: %s\n", io->name); + ODPH_ERR("Failed to start iface: %s\n", io->name); return -1; } if (odp_pktin_queue(io->hdl, &io->pktin, 1) != 1) { - printf("Error: failed to start iface: %s\n", io->name); + ODPH_ERR("Failed to start iface: %s\n", io->name); return -1; } if (odp_pktio_start(io->hdl)) { - printf("Error: failed to start iface: %s\n", io->name); + ODPH_ERR("Failed to start iface: %s\n", io->name); return -1; } @@ -562,19 +561,17 @@ int parser_suite_term(void) for (i = 0; i < num_ifaces; ++i) { if (odp_pktio_stop(pktios[i].hdl)) { - printf("Error: failed to stop pktio: %s\n", - pktios[i].name); + ODPH_ERR("Failed to stop pktio: %s\n", pktios[i].name); ret = -1; } if (odp_pktio_close(pktios[i].hdl)) { - printf("Error: failed to close pktio: %s\n", - pktios[i].name); + ODPH_ERR("Failed to close pktio: %s\n", pktios[i].name); ret = -1; } } if (odp_pool_destroy(parser_pool) != 0) { - printf("Error: failed to destroy packet pool\n"); + ODPH_ERR("Failed to destroy packet pool\n"); ret = -1; } diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 2f4dda4a4..f412a01c4 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -3495,7 +3495,7 @@ static void pktio_test_pktout_ts(void) } } -static void pktio_test_pktout_compl(bool use_plain_queue) +static void pktio_test_pktout_compl_event(bool use_plain_queue) { odp_pktio_t pktio[MAX_NUM_IFACES] = {ODP_PKTIO_INVALID}; odp_queue_t compl_queue[TX_BATCH_LEN]; @@ -3550,7 +3550,9 @@ static void pktio_test_pktout_compl(bool use_plain_queue) /* Configure Tx completion offload for PKTIO Tx */ if (i == 0) { - CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_all == 1); + CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_event == 1); + CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_all == + pktio_capa.tx_compl.mode_event); if (use_plain_queue) { /* CU_ASSERT needs these extra braces */ CU_ASSERT_FATAL(pktio_capa.tx_compl.queue_type_plain != 0); @@ -3559,7 +3561,7 @@ static void pktio_test_pktout_compl(bool use_plain_queue) } odp_pktio_config_init(&config); - config.pktout.bit.tx_compl_ena = 1; + config.tx_compl.mode_event = 1; CU_ASSERT_FATAL(odp_pktio_config(pktio[i], &config) == 0); } @@ -3583,10 +3585,30 @@ static void pktio_test_pktout_compl(bool use_plain_queue) memset(&opt, 0, sizeof(opt)); + /* Disabled by default */ + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0); + + /* Check that disable works. Also COMPL_ALL should be still supported. */ + opt.queue = compl_queue[0]; + opt.mode = ODP_PACKET_TX_COMPL_ALL; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0); + opt.mode = ODP_PACKET_TX_COMPL_DISABLED; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0); + opt.queue = compl_queue[0]; + opt.mode = ODP_PACKET_TX_COMPL_EVENT; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0); + opt.mode = ODP_PACKET_TX_COMPL_DISABLED; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0); + /* Prepare batch of pkts with different tx completion queues */ for (i = 0; i < TX_BATCH_LEN; i++) { + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) == 0); opt.queue = compl_queue[i]; - opt.mode = ODP_PACKET_TX_COMPL_ALL; + opt.mode = ODP_PACKET_TX_COMPL_EVENT; odp_packet_tx_compl_request(pkt_tbl[i], &opt); CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) != 0); /* Set pkt sequence number as its user ptr */ @@ -3623,6 +3645,9 @@ static void pktio_test_pktout_compl(bool use_plain_queue) CU_ASSERT(odp_packet_tx_compl_user_ptr(tx_compl) == (const void *)&pkt_seq[i]); + /* No user area for TX completion events */ + CU_ASSERT(odp_event_user_area(ev) == NULL); + /* Alternatively call event free / compl free */ if (i % 2) odp_packet_tx_compl_free(tx_compl); @@ -3657,6 +3682,10 @@ static void pktio_test_pktout_compl(bool use_plain_queue) break; } } + + /* No user area for TX completion events */ + CU_ASSERT(odp_event_user_area(ev) == NULL); + /* Check that sequence number is found */ CU_ASSERT(j < TX_BATCH_LEN); @@ -3690,7 +3719,104 @@ static void pktio_test_pktout_compl(bool use_plain_queue) odp_queue_destroy(compl_queue[i]); } -static int pktio_check_pktout_compl(bool plain) +static void pktio_test_pktout_compl_poll(void) +{ + odp_pktio_t pktio[MAX_NUM_IFACES] = {ODP_PKTIO_INVALID}; + odp_packet_t pkt_tbl[TX_BATCH_LEN]; + odp_pktio_capability_t pktio_capa; + odp_pktout_queue_t pktout_queue; + uint32_t pkt_seq[TX_BATCH_LEN]; + odp_pktio_t pktio_tx, pktio_rx; + odp_packet_tx_compl_opt_t opt; + pktio_info_t pktio_rx_info; + odp_pktio_config_t config; + int ret, i, num_rx = 0; + + CU_ASSERT_FATAL(num_ifaces >= 1); + + /* Open and configure interfaces */ + for (i = 0; i < num_ifaces; ++i) { + pktio[i] = create_pktio(i, ODP_PKTIN_MODE_DIRECT, + ODP_PKTOUT_MODE_DIRECT); + CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID); + + CU_ASSERT_FATAL(odp_pktio_capability(pktio[i], &pktio_capa) == 0); + + /* Configure Tx completion offload for PKTIO Tx */ + if (i == 0) { + CU_ASSERT_FATAL(pktio_capa.tx_compl.mode_poll == 1); + CU_ASSERT_FATAL(pktio_capa.tx_compl.max_compl_id >= (TX_BATCH_LEN - 1)); + + odp_pktio_config_init(&config); + config.tx_compl.mode_poll = 1; + config.tx_compl.max_compl_id = TX_BATCH_LEN - 1; + CU_ASSERT_FATAL(odp_pktio_config(pktio[i], &config) == 0); + } + + CU_ASSERT_FATAL(odp_pktio_start(pktio[i]) == 0); + } + + for (i = 0; i < num_ifaces; i++) + _pktio_wait_linkup(pktio[i]); + + pktio_tx = pktio[0]; + pktio_rx = (num_ifaces > 1) ? pktio[1] : pktio_tx; + pktio_rx_info.id = pktio_rx; + pktio_rx_info.inq = ODP_QUEUE_INVALID; + pktio_rx_info.in_mode = ODP_PKTIN_MODE_DIRECT; + + ret = create_packets(pkt_tbl, pkt_seq, TX_BATCH_LEN, pktio_tx, pktio_rx); + CU_ASSERT_FATAL(ret == TX_BATCH_LEN); + + ret = odp_pktout_queue(pktio_tx, &pktout_queue, 1); + CU_ASSERT_FATAL(ret > 0); + + memset(&opt, 0, sizeof(opt)); + + /* Disabled by default */ + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0); + + /* Check that disable works */ + opt.compl_id = 0; + opt.mode = ODP_PACKET_TX_COMPL_POLL; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) != 0); + opt.mode = ODP_PACKET_TX_COMPL_DISABLED; + odp_packet_tx_compl_request(pkt_tbl[0], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[0]) == 0); + + /* Prepare batch of pkts with different tx completion identifiers */ + for (i = 0; i < TX_BATCH_LEN; i++) { + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) == 0); + opt.compl_id = i; + opt.mode = ODP_PACKET_TX_COMPL_EVENT; + odp_packet_tx_compl_request(pkt_tbl[i], &opt); + CU_ASSERT(odp_packet_has_tx_compl_request(pkt_tbl[i]) != 0); + /* Set pkt sequence number as its user ptr */ + odp_packet_user_ptr_set(pkt_tbl[i], (const void *)&pkt_seq[i]); + } + + CU_ASSERT_FATAL(odp_pktout_send(pktout_queue, pkt_tbl, TX_BATCH_LEN) == TX_BATCH_LEN); + + num_rx = wait_for_packets(&pktio_rx_info, pkt_tbl, pkt_seq, TX_BATCH_LEN, TXRX_MODE_SINGLE, + ODP_TIME_SEC_IN_NS, false); + CU_ASSERT(num_rx == TX_BATCH_LEN); + for (i = 0; i < num_rx; i++) + odp_packet_free(pkt_tbl[i]); + + /* Transmits should be complete since we received the packets already */ + for (i = 0; i < num_rx; i++) { + ret = odp_packet_tx_compl_done(pktio_tx, i); + CU_ASSERT(ret > 0); + } + + for (i = 0; i < num_ifaces; i++) { + CU_ASSERT_FATAL(odp_pktio_stop(pktio[i]) == 0); + CU_ASSERT_FATAL(odp_pktio_close(pktio[i]) == 0); + } +} + +static int pktio_check_pktout_compl_event(bool plain) { odp_pktio_param_t pktio_param; odp_pktio_capability_t capa; @@ -3708,7 +3834,7 @@ static int pktio_check_pktout_compl(bool plain) ret = odp_pktio_capability(pktio, &capa); (void)odp_pktio_close(pktio); - if (ret < 0 || !capa.tx_compl.mode_all || + if (ret < 0 || !capa.tx_compl.mode_event || (plain && !capa.tx_compl.queue_type_plain) || (!plain && !capa.tx_compl.queue_type_sched)) return ODP_TEST_INACTIVE; @@ -3716,24 +3842,49 @@ static int pktio_check_pktout_compl(bool plain) return ODP_TEST_ACTIVE; } -static int pktio_check_pktout_compl_plain_queue(void) +static int pktio_check_pktout_compl_poll(void) +{ + odp_pktio_param_t pktio_param; + odp_pktio_capability_t capa; + odp_pktio_t pktio; + int ret; + + odp_pktio_param_init(&pktio_param); + pktio_param.in_mode = ODP_PKTIN_MODE_DIRECT; + pktio_param.out_mode = ODP_PKTOUT_MODE_DIRECT; + + pktio = odp_pktio_open(iface_name[0], pool[0], &pktio_param); + if (pktio == ODP_PKTIO_INVALID) + return ODP_TEST_INACTIVE; + + ret = odp_pktio_capability(pktio, &capa); + (void)odp_pktio_close(pktio); + + if (ret < 0 || capa.tx_compl.mode_poll == 0 || + capa.tx_compl.max_compl_id < (TX_BATCH_LEN - 1)) + return ODP_TEST_INACTIVE; + + return ODP_TEST_ACTIVE; +} + +static int pktio_check_pktout_compl_event_plain_queue(void) { - return pktio_check_pktout_compl(true); + return pktio_check_pktout_compl_event(true); } -static int pktio_check_pktout_compl_sched_queue(void) +static int pktio_check_pktout_compl_event_sched_queue(void) { - return pktio_check_pktout_compl(false); + return pktio_check_pktout_compl_event(false); } -static void pktio_test_pktout_compl_plain_queue(void) +static void pktio_test_pktout_compl_event_plain_queue(void) { - pktio_test_pktout_compl(true); + pktio_test_pktout_compl_event(true); } -static void pktio_test_pktout_compl_sched_queue(void) +static void pktio_test_pktout_compl_event_sched_queue(void) { - pktio_test_pktout_compl(false); + pktio_test_pktout_compl_event(false); } static void pktio_test_chksum(void (*config_fn)(odp_pktio_t, odp_pktio_t), @@ -5172,10 +5323,11 @@ odp_testinfo_t pktio_suite_unsegmented[] = { pktio_check_maxlen_set), ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_aging_tmo, pktio_check_pktout_aging_tmo), - ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_plain_queue, - pktio_check_pktout_compl_plain_queue), - ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_sched_queue, - pktio_check_pktout_compl_sched_queue), + ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_event_plain_queue, + pktio_check_pktout_compl_event_plain_queue), + ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_event_sched_queue, + pktio_check_pktout_compl_event_sched_queue), + ODP_TEST_INFO_CONDITIONAL(pktio_test_pktout_compl_poll, pktio_check_pktout_compl_poll), ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_rx, pktio_check_pause_rx), ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_tx, pktio_check_pause_tx), ODP_TEST_INFO_CONDITIONAL(pktio_test_enable_pause_both, pktio_check_pause_both), diff --git a/test/validation/api/pool/pool.c b/test/validation/api/pool/pool.c index cded05650..b335f194c 100644 --- a/test/validation/api/pool/pool.c +++ b/test/validation/api/pool/pool.c @@ -1098,6 +1098,7 @@ static int pool_check_timeout_pool_statistics(void) static void pool_test_pool_statistics(odp_pool_type_t pool_type) { odp_pool_stats_t stats; + odp_pool_stats_selected_t selected; odp_pool_param_t param; odp_pool_stats_opt_t supported; uint32_t i, j, num_pool, num_obj, cache_size; @@ -1164,8 +1165,8 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT_FATAL(max_pools != 0); /* Extra alloc rounds for testing odp_pool_stats_t.alloc_fails */ - uint32_t num_alloc_rounds = num_obj + 100; - odp_event_t event[max_pools][num_alloc_rounds]; + uint32_t num_allocs = num_obj + 100; + odp_event_t event[max_pools][num_allocs]; uint32_t num_event[max_pools]; odp_pool_t pool[max_pools]; @@ -1187,22 +1188,40 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) stats.thread.first = first; stats.thread.last = last; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); CU_ASSERT(stats.available <= num_obj); + if (supported.bit.available) + CU_ASSERT(selected.available <= num_obj); CU_ASSERT(stats.alloc_ops == 0); + if (supported.bit.alloc_ops) + CU_ASSERT(selected.alloc_ops == 0); CU_ASSERT(stats.alloc_fails == 0); + if (supported.bit.alloc_fails) + CU_ASSERT(selected.alloc_fails == 0); CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); CU_ASSERT(stats.total_ops == 0); + if (supported.bit.total_ops) + CU_ASSERT(selected.total_ops == 0); CU_ASSERT(stats.cache_available <= num_obj); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available <= num_obj); CU_ASSERT(stats.cache_alloc_ops == 0); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops == 0); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); + CU_ASSERT(stats.thread.first == first); CU_ASSERT(stats.thread.last == last); for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++) CU_ASSERT(stats.thread.cache_available[j] <= stats.cache_available); /* Allocate the events */ - for (j = 0; j < num_alloc_rounds; j++) { + for (j = 0; j < num_allocs; j++) { odp_event_t new_event = ODP_EVENT_INVALID; uint64_t total_cached = 0; uint16_t first_id = 0; @@ -1236,8 +1255,14 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) num_fails++; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, + &supported) == 0); CU_ASSERT(stats.available <= num_obj - num_events); + if (supported.bit.available) + CU_ASSERT(selected.available <= num_obj - num_events); CU_ASSERT(stats.cache_available <= num_obj - num_events); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available <= num_obj - num_events); while (first_id < odp_thread_count_max()) { stats.thread.first = first_id; @@ -1264,39 +1289,70 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT(num_events == num_obj); num_event[i] = num_events; + /* Allow implementation some time to update counters */ + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS); + stats.thread.first = first; stats.thread.last = last; CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); /* All events are allocated, available count in pool and pool * local caches should be zero. */ CU_ASSERT(stats.available == 0); + if (supported.bit.available) + CU_ASSERT(selected.available == 0); CU_ASSERT(stats.cache_available == 0); + if (supported.bit.cache_available) + CU_ASSERT(selected.cache_available == 0); for (j = 0; j < ODP_POOL_MAX_THREAD_STATS; j++) CU_ASSERT(stats.thread.cache_available[j] == 0); - if (supported.bit.alloc_ops) - CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_obj + 1); - if (supported.bit.alloc_fails) + if (supported.bit.alloc_ops) { + CU_ASSERT(stats.alloc_ops > 0 && stats.alloc_ops <= num_allocs); + CU_ASSERT(selected.alloc_ops > 0 && selected.alloc_ops <= num_allocs); + } + if (supported.bit.alloc_fails) { CU_ASSERT(stats.alloc_fails == num_fails); - if (supported.bit.total_ops) - CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_obj + 1); + CU_ASSERT(selected.alloc_fails == num_fails); + } + if (supported.bit.total_ops) { + CU_ASSERT(stats.total_ops > 0 && stats.total_ops <= num_allocs); + CU_ASSERT(selected.total_ops > 0 && selected.total_ops <= num_allocs); + } CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); + CU_ASSERT(stats.cache_alloc_ops <= num_allocs); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops <= num_allocs); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); } for (i = 0; i < num_pool; i++) { odp_event_free_multi(event[i], num_event[i]); + /* Allow implementation some time to update counters */ + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS); + stats.thread.first = odp_thread_id(); stats.thread.last = odp_thread_id(); CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); - if (supported.bit.available && supported.bit.cache_available) + if (supported.bit.available && supported.bit.cache_available) { CU_ASSERT(stats.available + stats.cache_available == num_obj); - if (supported.bit.free_ops) + CU_ASSERT(selected.available + selected.cache_available == num_obj); + } + if (supported.bit.free_ops) { CU_ASSERT(stats.free_ops > 0); - if (supported.bit.total_ops) + CU_ASSERT(selected.free_ops > 0); + } + if (supported.bit.total_ops) { CU_ASSERT(stats.total_ops > 0); + CU_ASSERT(selected.total_ops > 0); + } if (i == 0) { printf("\nPool Statistics\n---------------\n"); @@ -1314,13 +1370,26 @@ static void pool_test_pool_statistics(odp_pool_type_t pool_type) CU_ASSERT_FATAL(odp_pool_stats_reset(pool[i]) == 0); CU_ASSERT_FATAL(odp_pool_stats(pool[i], &stats) == 0); + CU_ASSERT_FATAL(odp_pool_stats_selected(pool[i], &selected, &supported) == 0); CU_ASSERT(stats.alloc_ops == 0); + if (supported.bit.alloc_ops) + CU_ASSERT(selected.alloc_ops == 0); CU_ASSERT(stats.alloc_fails == 0); + if (supported.bit.alloc_fails) + CU_ASSERT(selected.alloc_fails == 0); CU_ASSERT(stats.free_ops == 0); + if (supported.bit.free_ops) + CU_ASSERT(selected.free_ops == 0); CU_ASSERT(stats.total_ops == 0); + if (supported.bit.total_ops) + CU_ASSERT(selected.total_ops == 0); CU_ASSERT(stats.cache_alloc_ops == 0); + if (supported.bit.cache_alloc_ops) + CU_ASSERT(selected.cache_alloc_ops == 0); CU_ASSERT(stats.cache_free_ops == 0); + if (supported.bit.cache_free_ops) + CU_ASSERT(selected.cache_free_ops == 0); CU_ASSERT(odp_pool_destroy(pool[i]) == 0); } @@ -1858,7 +1927,7 @@ static int pool_suite_init(void) memset(&default_pool_param, 0, sizeof(odp_pool_param_t)); if (odp_pool_capability(&global_pool_capa) < 0) { - printf("pool_capability failed in suite init\n"); + ODPH_ERR("odp_pool_capability() failed in suite init\n"); return -1; } @@ -1872,12 +1941,12 @@ static int pool_ext_suite_init(void) memset(&global_pool_ext_capa, 0, sizeof(odp_pool_ext_capability_t)); if (odp_pool_ext_capability(ODP_POOL_PACKET, &global_pool_ext_capa)) { - printf("Pool ext capa failed in suite init\n"); + ODPH_ERR("Pool ext capa failed in suite init\n"); return -1; } if (global_pool_ext_capa.type != ODP_POOL_PACKET) { - printf("Bad type from pool ext capa in suite init\n"); + ODPH_ERR("Bad type from pool ext capa in suite init\n"); return -1; } diff --git a/test/validation/api/queue/queue.c b/test/validation/api/queue/queue.c index f661da075..2cd474455 100644 --- a/test/validation/api/queue/queue.c +++ b/test/validation/api/queue/queue.c @@ -6,6 +6,7 @@ */ #include <odp_api.h> +#include <odp/helper/odph_api.h> #include <odp_cunit_common.h> #define MAX_WORKERS 32 @@ -65,7 +66,7 @@ static int queue_suite_init(void) ODP_CACHE_LINE_SIZE, 0); if (shm == ODP_SHM_INVALID) { - printf("Shared memory reserve failed\n"); + ODPH_ERR("Shared memory reserve failed\n"); return -1; } @@ -91,7 +92,7 @@ static int queue_suite_init(void) pool = odp_pool_create("msg_pool", ¶ms); if (ODP_POOL_INVALID == pool) { - printf("Pool create failed.\n"); + ODPH_ERR("Pool create failed\n"); return -1; } return 0; @@ -103,17 +104,17 @@ static int queue_suite_term(void) shm = odp_shm_lookup(GLOBALS_NAME); if (shm == ODP_SHM_INVALID) { - printf("SHM lookup failed.\n"); + ODPH_ERR("SHM lookup failed\n"); return -1; } if (odp_shm_free(shm)) { - printf("SHM free failed.\n"); + ODPH_ERR("SHM free failed\n"); return -1; } if (odp_pool_destroy(pool)) { - printf("Pool destroy failed.\n"); + ODPH_ERR("Pool destroy failed\n"); return -1; } @@ -455,7 +456,7 @@ static int queue_pair_work_loop(void *arg) buf = odp_buffer_from_event(ev); data = odp_buffer_addr(buf); if (*data != i) { - printf("Seq error: expected %u, recv %u\n", i, *data); + ODPH_ERR("Seq error: expected %u, recv %u\n", i, *data); CU_FAIL("Sequence number error"); } diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c index cd9ad1ac1..ec06cf27d 100644 --- a/test/validation/api/scheduler/scheduler.c +++ b/test/validation/api/scheduler/scheduler.c @@ -3155,12 +3155,12 @@ static int create_queues(test_globals_t *globals) int sched_types; if (odp_queue_capability(&queue_capa) < 0) { - printf("Queue capability query failed\n"); + ODPH_ERR("Queue capability query failed\n"); return -1; } if (odp_schedule_capability(&sched_capa) < 0) { - printf("Queue capability query failed\n"); + ODPH_ERR("Queue capability query failed\n"); return -1; } @@ -3196,9 +3196,9 @@ static int create_queues(test_globals_t *globals) num_plain = (prios * queues_per_prio); } if (!queues_per_prio) { - printf("Not enough queues. At least %d scheduled queues and " - "%d plain queus required.\n", - ((prios * sched_types) + CHAOS_NUM_QUEUES), prios); + ODPH_ERR("Not enough queues. At least %d scheduled queues and " + "%d plain queues required.\n", + ((prios * sched_types) + CHAOS_NUM_QUEUES), prios); return -1; } globals->queues_per_prio = queues_per_prio; @@ -3211,7 +3211,7 @@ static int create_queues(test_globals_t *globals) queue_ctx_pool = odp_pool_create(QUEUE_CTX_POOL_NAME, ¶ms); if (queue_ctx_pool == ODP_POOL_INVALID) { - printf("Pool creation failed (queue ctx).\n"); + ODPH_ERR("Pool creation failed (queue ctx)\n"); return -1; } globals->queue_ctx_pool = queue_ctx_pool; @@ -3231,7 +3231,7 @@ static int create_queues(test_globals_t *globals) q = odp_queue_create(name, &p); if (q == ODP_QUEUE_INVALID) { - printf("Parallel queue create failed.\n"); + ODPH_ERR("Parallel queue create failed\n"); return -1; } @@ -3241,21 +3241,21 @@ static int create_queues(test_globals_t *globals) q = odp_queue_create(name, &p); if (q == ODP_QUEUE_INVALID) { - printf("Atomic queue create failed.\n"); + ODPH_ERR("Atomic queue create failed\n"); return -1; } snprintf(name, sizeof(name), "plain_%d_%d_o", i, j); pq = odp_queue_create(name, NULL); if (pq == ODP_QUEUE_INVALID) { - printf("Plain queue create failed.\n"); + ODPH_ERR("Plain queue create failed\n"); return -1; } queue_ctx_buf = odp_buffer_alloc(queue_ctx_pool); if (queue_ctx_buf == ODP_BUFFER_INVALID) { - printf("Cannot allocate plain queue ctx buf\n"); + ODPH_ERR("Cannot allocate plain queue ctx buf\n"); return -1; } @@ -3266,7 +3266,7 @@ static int create_queues(test_globals_t *globals) rc = odp_queue_context_set(pq, pqctx, 0); if (rc != 0) { - printf("Cannot set plain queue context\n"); + ODPH_ERR("Cannot set plain queue context\n"); return -1; } @@ -3277,7 +3277,7 @@ static int create_queues(test_globals_t *globals) q = odp_queue_create(name, &p); if (q == ODP_QUEUE_INVALID) { - printf("Ordered queue create failed.\n"); + ODPH_ERR("Ordered queue create failed\n"); return -1; } if (odp_queue_lock_count(q) != @@ -3293,7 +3293,7 @@ static int create_queues(test_globals_t *globals) queue_ctx_buf = odp_buffer_alloc(queue_ctx_pool); if (queue_ctx_buf == ODP_BUFFER_INVALID) { - printf("Cannot allocate queue ctx buf\n"); + ODPH_ERR("Cannot allocate queue ctx buf\n"); return -1; } @@ -3311,7 +3311,7 @@ static int create_queues(test_globals_t *globals) rc = odp_queue_context_set(q, qctx, 0); if (rc != 0) { - printf("Cannot set queue context\n"); + ODPH_ERR("Cannot set queue context\n"); return -1; } } @@ -3522,14 +3522,14 @@ static int scheduler_test_global_init(void) sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0); if (shm == ODP_SHM_INVALID) { - printf("Shared memory reserve failed (globals).\n"); + ODPH_ERR("Shared memory reserve failed (globals)\n"); return -1; } globals = odp_shm_addr(shm); if (!globals) { - printf("Shared memory reserve failed (globals).\n"); + ODPH_ERR("Shared memory reserve failed (globals)\n"); return -1; } @@ -3544,7 +3544,7 @@ static int scheduler_test_global_init(void) ODP_CACHE_LINE_SIZE, 0); if (shm == ODP_SHM_INVALID) { - printf("Shared memory reserve failed (args).\n"); + ODPH_ERR("Shared memory reserve failed (args)\n"); return -1; } @@ -3552,7 +3552,7 @@ static int scheduler_test_global_init(void) globals->shm_args = shm; if (!args) { - printf("Shared memory reserve failed (args).\n"); + ODPH_ERR("Shared memory reserve failed (args)\n"); return -1; } @@ -3572,14 +3572,14 @@ static int scheduler_test_global_init(void) pool = odp_pool_create(MSG_POOL_NAME, ¶ms); if (pool == ODP_POOL_INVALID) { - printf("Pool creation failed (msg).\n"); + ODPH_ERR("Pool creation failed (msg)\n"); return -1; } globals->pool = pool; if (odp_schedule_capability(&sched_capa)) { - printf("odp_schedule_capability() failed\n"); + ODPH_ERR("odp_schedule_capability() failed\n"); return -1; } @@ -3599,7 +3599,7 @@ static int scheduler_test_global_init(void) /* Configure the scheduler. All test cases share the config. */ if (odp_schedule_config(&sched_config)) { - printf("odp_schedule_config() failed.\n"); + ODPH_ERR("odp_schedule_config() failed\n"); return -1; } diff --git a/test/validation/api/scheduler/scheduler_no_predef_groups.c b/test/validation/api/scheduler/scheduler_no_predef_groups.c index 3dd79ebcc..1b941ac61 100644 --- a/test/validation/api/scheduler/scheduler_no_predef_groups.c +++ b/test/validation/api/scheduler/scheduler_no_predef_groups.c @@ -139,7 +139,7 @@ static int scheduler_suite_init(void) odp_schedule_config_t sched_config; if (odp_schedule_capability(&sched_capa)) { - printf("odp_schedule_capability() failed\n"); + ODPH_ERR("odp_schedule_capability() failed\n"); return -1; } @@ -152,7 +152,7 @@ static int scheduler_suite_init(void) /* Configure the scheduler. All test cases share the config. */ if (odp_schedule_config(&sched_config)) { - printf("odp_schedule_config() failed.\n"); + ODPH_ERR("odp_schedule_config() failed\n"); return -1; } diff --git a/test/validation/api/stash/stash.c b/test/validation/api/stash/stash.c index fd4c04577..67c336a2f 100644 --- a/test/validation/api/stash/stash.c +++ b/test/validation/api/stash/stash.c @@ -5,6 +5,8 @@ */ #include <odp_api.h> +#include <odp/helper/odph_api.h> + #include "odp_cunit_common.h" #include <string.h> @@ -63,7 +65,7 @@ static int stash_suite_init(void) odp_stash_capability_t *capa_fifo = &global.capa_fifo; if (odp_stash_capability(capa_default, ODP_STASH_TYPE_DEFAULT)) { - printf("stash capability failed for the default type\n"); + ODPH_ERR("Stash capability failed for the default type\n"); return -1; } diff --git a/test/validation/api/thread/thread.c b/test/validation/api/thread/thread.c index 2dc799c2a..87c23e74e 100644 --- a/test/validation/api/thread/thread.c +++ b/test/validation/api/thread/thread.c @@ -30,7 +30,7 @@ static int thread_global_init(odp_instance_t *inst) odph_helper_options_t helper_options; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -38,11 +38,11 @@ static int thread_global_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } @@ -50,7 +50,7 @@ static int thread_global_init(odp_instance_t *inst) sizeof(global_shared_mem_t), ODP_CACHE_LINE_SIZE, 0); if (global_shm == ODP_SHM_INVALID) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); + ODPH_ERR("Unable to reserve memory for global_shm\n"); return -1; } @@ -66,17 +66,17 @@ static int thread_global_term(odp_instance_t inst) shm = odp_shm_lookup(GLOBAL_SHM_NAME); if (0 != odp_shm_free(shm)) { - fprintf(stderr, "error: odp_shm_free() failed.\n"); + ODPH_ERR("odp_shm_free() failed\n"); return -1; } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c index f285bf8e4..22189ce03 100644 --- a/test/validation/api/time/time.c +++ b/test/validation/api/time/time.c @@ -1,5 +1,5 @@ /* Copyright (c) 2015-2018, Linaro Limited - * Copyright (c) 2019-2022, Nokia + * Copyright (c) 2019-2023, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -12,6 +12,7 @@ #include <time.h> #include <odp_api.h> +#include <odp/helper/odph_api.h> #include "odp_cunit_common.h" #define BUSY_LOOP_CNT 30000000 /* used for t > min resolution */ @@ -19,6 +20,11 @@ #define MAX_TIME_RATE 15000000000 #define DELAY_TOLERANCE 40000000 /* deviation for delay */ #define WAIT_SECONDS 3 +#define MAX_WORKERS 32 +#define TIME_SAMPLES 2 +#define TIME_TOLERANCE_NS 1000000 +#define TIME_TOLERANCE_CI_NS 40000000 +#define GLOBAL_SHM_NAME "GlobalTimeTest" static uint64_t local_res; static uint64_t global_res; @@ -28,6 +34,96 @@ typedef uint64_t time_res_cb(void); typedef odp_time_t time_from_ns_cb(uint64_t ns); typedef uint64_t time_nsec_cb(void); +typedef struct { + uint32_t num_threads; + odp_barrier_t test_barrier; + odp_time_t time[MAX_WORKERS + 1][TIME_SAMPLES]; +} global_shared_mem_t; + +static global_shared_mem_t *global_mem; +static odp_instance_t *instance; + +static int time_global_init(odp_instance_t *inst) +{ + odp_shm_t global_shm; + odp_init_t init_param; + odph_helper_options_t helper_options; + uint32_t workers_count, max_threads; + + if (odph_options(&helper_options)) { + ODPH_ERR("odph_options() failed\n"); + return -1; + } + + odp_init_param_init(&init_param); + init_param.mem_model = helper_options.mem_model; + + if (0 != odp_init_global(inst, &init_param, NULL)) { + ODPH_ERR("odp_init_global() failed\n"); + return -1; + } + if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { + ODPH_ERR("odp_init_local() failed\n"); + return -1; + } + + global_shm = odp_shm_reserve(GLOBAL_SHM_NAME, + sizeof(global_shared_mem_t), + ODP_CACHE_LINE_SIZE, 0); + if (global_shm == ODP_SHM_INVALID) { + ODPH_ERR("Unable reserve memory for global_shm\n"); + return -1; + } + + global_mem = odp_shm_addr(global_shm); + memset(global_mem, 0, sizeof(global_shared_mem_t)); + + global_mem->num_threads = MAX_WORKERS; + + workers_count = odp_cpumask_default_worker(NULL, 0); + + max_threads = (workers_count >= MAX_WORKERS) ? + MAX_WORKERS : workers_count; + + if (max_threads < global_mem->num_threads) { + printf("Requested num of threads is too large\n"); + printf("reducing from %" PRIu32 " to %" PRIu32 "\n", + global_mem->num_threads, + max_threads); + global_mem->num_threads = max_threads; + } + + printf("Num of threads used = %" PRIu32 "\n", + global_mem->num_threads); + + instance = inst; + + return 0; +} + +static int time_global_term(odp_instance_t inst) +{ + odp_shm_t shm; + + shm = odp_shm_lookup(GLOBAL_SHM_NAME); + if (0 != odp_shm_free(shm)) { + ODPH_ERR("odp_shm_free() failed\n"); + return -1; + } + + if (0 != odp_term_local()) { + ODPH_ERR("odp_term_local() failed\n"); + return -1; + } + + if (0 != odp_term_global(inst)) { + ODPH_ERR("odp_term_global() failed\n"); + return -1; + } + + return 0; +} + static void time_test_constants(void) { uint64_t ns; @@ -423,16 +519,14 @@ static void time_test_wait_until(time_cb time_cur, time_from_ns_cb time_from_ns) DELAY_TOLERANCE); if (odp_time_cmp(wait, lower_limit) < 0) { - fprintf(stderr, "Exceed lower limit: " - "wait is %" PRIu64 ", lower_limit %" PRIu64 "\n", - odp_time_to_ns(wait), odp_time_to_ns(lower_limit)); + ODPH_ERR("Exceed lower limit: wait is %" PRIu64 ", lower_limit %" PRIu64 "\n", + odp_time_to_ns(wait), odp_time_to_ns(lower_limit)); CU_FAIL("Exceed lower limit\n"); } if (odp_time_cmp(wait, upper_limit) > 0) { - fprintf(stderr, "Exceed upper limit: " - "wait is %" PRIu64 ", upper_limit %" PRIu64 "\n", - odp_time_to_ns(wait), odp_time_to_ns(lower_limit)); + ODPH_ERR("Exceed upper limit: wait is %" PRIu64 ", upper_limit %" PRIu64 "\n", + odp_time_to_ns(wait), odp_time_to_ns(lower_limit)); CU_FAIL("Exceed upper limit\n"); } } @@ -466,16 +560,14 @@ static void time_test_wait_ns(void) DELAY_TOLERANCE); if (odp_time_cmp(diff, lower_limit) < 0) { - fprintf(stderr, "Exceed lower limit: " - "diff is %" PRIu64 ", lower_limit %" PRIu64 "\n", - odp_time_to_ns(diff), odp_time_to_ns(lower_limit)); + ODPH_ERR("Exceed lower limit: diff is %" PRIu64 ", lower_limit %" PRIu64 "\n", + odp_time_to_ns(diff), odp_time_to_ns(lower_limit)); CU_FAIL("Exceed lower limit\n"); } if (odp_time_cmp(diff, upper_limit) > 0) { - fprintf(stderr, "Exceed upper limit: " - "diff is %" PRIu64 ", upper_limit %" PRIu64 "\n", - odp_time_to_ns(diff), odp_time_to_ns(upper_limit)); + ODPH_ERR("Exceed upper limit: diff is %" PRIu64 ", upper_limit %" PRIu64 "\n", + odp_time_to_ns(diff), odp_time_to_ns(upper_limit)); CU_FAIL("Exceed upper limit\n"); } } @@ -486,13 +578,13 @@ static void check_time_diff(double t_odp, double t_system, { if (t_odp > t_system * 1.05) { CU_FAIL("ODP time too high"); - fprintf(stderr, "ODP time too high (%s/%d): t_odp: %f, t_system: %f\n", - test, id, t_odp, t_system); + ODPH_ERR("ODP time too high (%s/%d): t_odp: %f, t_system: %f\n", + test, id, t_odp, t_system); } if (t_odp < t_system * 0.95) { CU_FAIL("ODP time too low"); - fprintf(stderr, "ODP time too low (%s/%d): t_odp: %f, t_system: %f\n", - test, id, t_odp, t_system); + ODPH_ERR("ODP time too low (%s/%d): t_odp: %f, t_system: %f\n", + test, id, t_odp, t_system); } } @@ -589,6 +681,138 @@ static void time_test_accuracy_nsec(void) } } +static int time_test_global_sync_thr(void *arg ODP_UNUSED) +{ + int tid = odp_thread_id(); + odp_shm_t global_shm = odp_shm_lookup(GLOBAL_SHM_NAME); + global_shared_mem_t *global_mem = odp_shm_addr(global_shm); + + if (!global_mem) + return 1; + + odp_barrier_wait(&global_mem->test_barrier); + global_mem->time[tid][0] = odp_time_global(); + odp_time_wait_ns(ODP_TIME_MSEC_IN_NS * 100); + odp_barrier_wait(&global_mem->test_barrier); + global_mem->time[tid][1] = odp_time_global(); + + return 0; +} + +static void time_test_global_sync(const int ctrl) +{ + odp_cpumask_t cpumask; + odph_thread_common_param_t thr_common; + odph_thread_param_t thr_param; + odph_thread_t thread_tbl[MAX_WORKERS]; + const uint64_t tolerance = + odp_cunit_ci() ? TIME_TOLERANCE_CI_NS : TIME_TOLERANCE_NS; + const int num = ctrl ? 2 : global_mem->num_threads; + + if (num < 2) { + printf(" number of threads is less than two, test skipped. "); + return; + } + + odp_barrier_init(&global_mem->test_barrier, num); + + odph_thread_param_init(&thr_param); + thr_param.start = time_test_global_sync_thr; + + odph_thread_common_param_init(&thr_common); + thr_common.instance = *instance; + + int thr = 0; + + if (ctrl) { + /* Test sync between one control and one worker thread. */ + odp_cpumask_default_control(&cpumask, 1); + thr_common.cpumask = &cpumask; + thr_param.thr_type = ODP_THREAD_CONTROL; + + int r = odph_thread_create(&thread_tbl[thr++], + &thr_common, &thr_param, 1); + CU_ASSERT_FATAL(r == 1); + odp_cpumask_default_worker(&cpumask, 1); + } else { + /* Test sync between num worker threads. */ + odp_cpumask_default_worker(&cpumask, num); + } + + int cpu = odp_cpumask_first(&cpumask); + + while (cpu >= 0) { + odp_cpumask_t cpumask_one; + + /* + * Delay for more than the tolerance, so that we notice if the + * thread's view of global time is affected. + */ + odp_time_wait_ns(tolerance * 2); + + odp_cpumask_zero(&cpumask_one); + odp_cpumask_set(&cpumask_one, cpu); + thr_common.cpumask = &cpumask_one; + thr_param.thr_type = ODP_THREAD_WORKER; + + int r = odph_thread_create(&thread_tbl[thr++], + &thr_common, &thr_param, 1); + CU_ASSERT_FATAL(r == 1); + + cpu = odp_cpumask_next(&cpumask, cpu); + } + + CU_ASSERT(odph_thread_join(thread_tbl, num) == num); + + for (int s = 0; s < TIME_SAMPLES; s++) { + int min_idx = 0, max_idx = 0; + uint64_t min = UINT64_MAX, max = 0; + double avg = 0; + + for (int i = 1; i < num + 1; i++) { + uint64_t t = odp_time_to_ns(global_mem->time[i][s]); + + if (t < min) { + min = t; + min_idx = i; + } + } + + printf("\nround %d\nthread time diffs: ", s); + + for (int i = 1; i < num + 1; i++) { + uint64_t t = odp_time_to_ns(global_mem->time[i][s]) - min; + + printf("%" PRIu64 " ", t); + + if (t > max) { + max = t; + max_idx = i; + } + + avg += t; + } + + /* The min result itself is not included in the average. */ + avg /= num - 1; + printf("\nmin: %" PRIu64 " (tid %d) max diff: %" PRIu64 + " (tid %d) avg diff: %g", min, min_idx, max, max_idx, avg); + CU_ASSERT(max < tolerance); + } + + printf("\n"); +} + +static void time_test_global_sync_workers(void) +{ + time_test_global_sync(0); +} + +static void time_test_global_sync_control(void) +{ + time_test_global_sync(1); +} + odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_constants), ODP_TEST_INFO(time_test_local_res), @@ -614,6 +838,8 @@ odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_global_strict_diff), ODP_TEST_INFO(time_test_global_strict_sum), ODP_TEST_INFO(time_test_global_strict_cmp), + ODP_TEST_INFO(time_test_global_sync_workers), + ODP_TEST_INFO(time_test_global_sync_control), ODP_TEST_INFO_NULL }; @@ -630,6 +856,9 @@ int main(int argc, char *argv[]) if (odp_cunit_parse_options(argc, argv)) return -1; + odp_cunit_register_global_init(time_global_init); + odp_cunit_register_global_term(time_global_term); + ret = odp_cunit_register(time_suites); if (ret == 0) diff --git a/test/validation/api/timer/timer.c b/test/validation/api/timer/timer.c index eb7f0772a..dad99ab41 100644 --- a/test/validation/api/timer/timer.c +++ b/test/validation/api/timer/timer.c @@ -15,6 +15,8 @@ #include <odp/helper/odph_api.h> #include "odp_cunit_common.h" +#include <stdint.h> + #define MAX_WORKERS 32 #define GLOBAL_SHM_NAME "GlobalTimerTest" @@ -117,7 +119,7 @@ static int timer_global_init(odp_instance_t *inst) int i; if (odph_options(&helper_options)) { - fprintf(stderr, "error: odph_options() failed.\n"); + ODPH_ERR("odph_options() failed\n"); return -1; } @@ -125,11 +127,11 @@ static int timer_global_init(odp_instance_t *inst) init_param.mem_model = helper_options.mem_model; if (0 != odp_init_global(inst, &init_param, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); + ODPH_ERR("odp_init_global() failed\n"); return -1; } if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); + ODPH_ERR("odp_init_local() failed\n"); return -1; } @@ -137,7 +139,7 @@ static int timer_global_init(odp_instance_t *inst) sizeof(global_shared_mem_t), ODP_CACHE_LINE_SIZE, 0); if (global_shm == ODP_SHM_INVALID) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); + ODPH_ERR("Unable to reserve memory for global_shm\n"); return -1; } @@ -149,7 +151,7 @@ static int timer_global_init(odp_instance_t *inst) memset(&capa, 0, sizeof(capa)); if (odp_timer_capability(ODP_CLOCK_DEFAULT, &capa)) { - fprintf(stderr, "Timer capability failed\n"); + ODPH_ERR("Timer capability failed\n"); return -1; } @@ -162,7 +164,7 @@ static int timer_global_init(odp_instance_t *inst) res_capa.res_ns = res_ns; if (odp_timer_res_capability(ODP_CLOCK_DEFAULT, &res_capa)) { - fprintf(stderr, "Timer resolution capability failed\n"); + ODPH_ERR("Timer resolution capability failed\n"); return -1; } @@ -178,7 +180,7 @@ static int timer_global_init(odp_instance_t *inst) range = (RANGE_MS * 1000) + THREE_POINT_THREE_MSEC; if ((max_tmo - min_tmo) < range) { - fprintf(stderr, "Validation test needs %u msec range\n", range); + ODPH_ERR("Validation test needs %u msec range\n", range); return -1; } @@ -209,17 +211,17 @@ static int timer_global_term(odp_instance_t inst) shm = odp_shm_lookup(GLOBAL_SHM_NAME); if (0 != odp_shm_free(shm)) { - fprintf(stderr, "error: odp_shm_free() failed.\n"); + ODPH_ERR("odp_shm_free() failed\n"); return -1; } if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + ODPH_ERR("odp_term_local() failed\n"); return -1; } if (0 != odp_term_global(inst)) { - fprintf(stderr, "error: odp_term_global() failed.\n"); + ODPH_ERR("odp_term_global() failed\n"); return -1; } @@ -279,7 +281,7 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src) CU_ASSERT_FATAL(ret == 0); CU_ASSERT(capa.highest_res_ns == capa.max_res.res_ns); - /* Assuming max resoultion to be 100 msec or better */ + /* Assuming max resolution to be 100 msec or better */ CU_ASSERT(capa.max_res.res_ns <= 100000000); CU_ASSERT(capa.max_res.res_hz >= 10); CU_ASSERT(capa.max_res.res_ns < capa.max_res.max_tmo); @@ -302,6 +304,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src) CU_ASSERT(res_capa.min_tmo == capa.max_res.min_tmo); CU_ASSERT(res_capa.max_tmo == capa.max_res.max_tmo); + if (capa.max_res.res_ns > 1) { + memset(&res_capa, 0, sizeof(res_capa)); + res_capa.res_ns = capa.max_res.res_ns - 1; + ret = odp_timer_res_capability(clk_src, &res_capa); + CU_ASSERT(ret < 0); + } + /* Set max resolution in hz */ memset(&res_capa, 0, sizeof(res_capa)); res_capa.res_hz = capa.max_res.res_hz; @@ -312,6 +321,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src) CU_ASSERT(res_capa.min_tmo == capa.max_res.min_tmo); CU_ASSERT(res_capa.max_tmo == capa.max_res.max_tmo); + if (capa.max_res.res_hz < UINT64_MAX) { + memset(&res_capa, 0, sizeof(res_capa)); + res_capa.res_hz = capa.max_res.res_hz + 1; + ret = odp_timer_res_capability(clk_src, &res_capa); + CU_ASSERT(ret < 0); + } + /* Set max timeout */ memset(&res_capa, 0, sizeof(res_capa)); res_capa.max_tmo = capa.max_tmo.max_tmo; @@ -322,6 +338,13 @@ static void timer_test_capa_run(odp_timer_clk_src_t clk_src) CU_ASSERT(res_capa.min_tmo == capa.max_tmo.min_tmo); CU_ASSERT(res_capa.res_ns == capa.max_tmo.res_ns); CU_ASSERT(res_capa.res_hz == capa.max_tmo.res_hz); + + if (capa.max_tmo.max_tmo < UINT64_MAX) { + memset(&res_capa, 0, sizeof(res_capa)); + res_capa.max_tmo = capa.max_tmo.max_tmo + 1; + ret = odp_timer_res_capability(clk_src, &res_capa); + CU_ASSERT(ret < 0); + } } static void timer_test_capa(void) @@ -494,6 +517,8 @@ static void timer_test_timeout_user_area(void) CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); for (i = 0; i < num; i++) { + odp_event_t ev; + tmo[i] = odp_timeout_alloc(pool); if (tmo[i] == ODP_TIMEOUT_INVALID) @@ -505,6 +530,9 @@ static void timer_test_timeout_user_area(void) CU_ASSERT_FATAL(addr != NULL); CU_ASSERT(prev != addr); + ev = odp_timeout_to_event(tmo[i]); + CU_ASSERT(odp_event_user_area(ev) == addr); + prev = addr; memset(addr, 0, size); } @@ -749,9 +777,9 @@ static void timer_pool_max_res(void) ev = ODP_EVENT_INVALID; ret = odp_timer_cancel(timer, &ev); - CU_ASSERT(ret == 0); + CU_ASSERT(ret == ODP_TIMER_SUCCESS); - if (ret == 0) { + if (ret == ODP_TIMER_SUCCESS) { CU_ASSERT(ev != ODP_EVENT_INVALID); odp_event_free(ev); } @@ -922,9 +950,9 @@ static void timer_single_shot(odp_queue_type_t queue_type, odp_timer_tick_type_t if (cancel) { ret = odp_timer_cancel(timer, &ev); - CU_ASSERT(ret == 0); + CU_ASSERT(ret == ODP_TIMER_SUCCESS); - if (ret == 0) + if (ret == ODP_TIMER_SUCCESS) CU_ASSERT(ev != ODP_EVENT_INVALID); } else { uint64_t diff_ns; @@ -1061,6 +1089,148 @@ static void timer_sched_abs_wait_3sec(void) timer_single_shot(ODP_QUEUE_TYPE_SCHED, ABSOLUTE, START, TIMEOUT, 30, 110 * MSEC); } +static void timer_pool_current_tick_run(odp_timer_clk_src_t clk_src) +{ + odp_timer_capability_t capa; + odp_timer_pool_param_t tp_param; + odp_timer_pool_t tp; + uint64_t t1, t2, ticks, min, max; + uint64_t nsec = 100 * ODP_TIME_MSEC_IN_NS; + + memset(&capa, 0, sizeof(capa)); + CU_ASSERT_FATAL(odp_timer_capability(clk_src, &capa) == 0); + + /* Highest resolution */ + odp_timer_pool_param_init(&tp_param); + tp_param.res_hz = capa.max_res.res_hz; + tp_param.min_tmo = capa.max_res.min_tmo; + tp_param.max_tmo = capa.max_res.max_tmo; + tp_param.num_timers = 100; + tp_param.clk_src = clk_src; + + tp = odp_timer_pool_create("cur_tick", &tp_param); + CU_ASSERT_FATAL(tp != ODP_TIMER_POOL_INVALID); + + odp_timer_pool_start(); + + /* Allow +-10% error margin */ + min = odp_timer_ns_to_tick(tp, 0.9 * nsec); + max = odp_timer_ns_to_tick(tp, 1.1 * nsec); + + t1 = odp_timer_current_tick(tp); + + odp_time_wait_ns(nsec); + + t2 = odp_timer_current_tick(tp); + + ticks = t2 - t1; + + CU_ASSERT(t2 >= t1); + CU_ASSERT(ticks >= min); + CU_ASSERT(ticks <= max); + + printf("\nClock source %i\n", clk_src); + printf(" Time nsec: %" PRIu64 "\n", nsec); + printf(" Measured ticks: %" PRIu64 "\n", ticks); + printf(" Expected ticks: %" PRIu64 "\n", odp_timer_ns_to_tick(tp, nsec)); + + odp_timer_pool_destroy(tp); +} + +static void timer_pool_current_tick(void) +{ + odp_timer_clk_src_t clk_src; + int i; + + for (i = 0; i < ODP_CLOCK_NUM_SRC; i++) { + clk_src = ODP_CLOCK_SRC_0 + i; + if (global_mem->clk_supported[i]) { + ODPH_DBG("\nTesting clock source: %i\n", clk_src); + timer_pool_current_tick_run(clk_src); + } + } +} + +static void timer_pool_sample_ticks_run(odp_timer_clk_src_t clk_2) +{ + odp_timer_capability_t capa; + odp_timer_pool_param_t tp_param; + odp_timer_pool_t tp[2]; + uint64_t t1[2], t2[2], ticks[2], min[2], max[2]; + uint64_t clk_count[2] = {0}; + odp_timer_clk_src_t clk_1 = ODP_CLOCK_DEFAULT; + uint64_t nsec = 100 * ODP_TIME_MSEC_IN_NS; + + /* Highest resolution */ + odp_timer_pool_param_init(&tp_param); + tp_param.num_timers = 100; + + /* First timer pool: default clock source */ + memset(&capa, 0, sizeof(capa)); + CU_ASSERT_FATAL(odp_timer_capability(clk_1, &capa) == 0); + tp_param.clk_src = clk_1; + tp_param.res_hz = capa.max_res.res_hz; + tp_param.min_tmo = capa.max_res.min_tmo; + tp_param.max_tmo = capa.max_res.max_tmo; + + tp[0] = odp_timer_pool_create("timer_pool_0", &tp_param); + CU_ASSERT_FATAL(tp[0] != ODP_TIMER_POOL_INVALID); + + /* Second timer pool: another clock source */ + memset(&capa, 0, sizeof(capa)); + CU_ASSERT_FATAL(odp_timer_capability(clk_2, &capa) == 0); + tp_param.clk_src = clk_2; + tp_param.res_hz = capa.max_res.res_hz; + tp_param.min_tmo = capa.max_res.min_tmo; + tp_param.max_tmo = capa.max_res.max_tmo; + + tp[1] = odp_timer_pool_create("timer_pool_1", &tp_param); + CU_ASSERT_FATAL(tp[1] != ODP_TIMER_POOL_INVALID); + + odp_timer_pool_start(); + + /* Allow +-10% error margin */ + min[0] = odp_timer_ns_to_tick(tp[0], 0.9 * nsec); + max[0] = odp_timer_ns_to_tick(tp[0], 1.1 * nsec); + min[1] = odp_timer_ns_to_tick(tp[1], 0.9 * nsec); + max[1] = odp_timer_ns_to_tick(tp[1], 1.1 * nsec); + + CU_ASSERT_FATAL(odp_timer_sample_ticks(tp, t1, NULL, 2) == 0); + + odp_time_wait_ns(nsec); + + CU_ASSERT_FATAL(odp_timer_sample_ticks(tp, t2, clk_count, 2) == 0); + + ticks[0] = t2[0] - t1[0]; + ticks[1] = t2[1] - t1[1]; + + CU_ASSERT(t2[0] >= t1[0]); + CU_ASSERT(t2[1] >= t1[1]); + CU_ASSERT(ticks[0] >= min[0]); + CU_ASSERT(ticks[1] >= min[1]); + CU_ASSERT(ticks[0] <= max[0]); + CU_ASSERT(ticks[1] <= max[1]); + + printf("\nClock source: %i, %i\n", clk_1, clk_2); + printf(" Time nsec: %" PRIu64 "\n", nsec); + printf(" Measured ticks: %" PRIu64 ", %" PRIu64 "\n", ticks[0], ticks[1]); + printf(" Expected ticks: %" PRIu64 ", %" PRIu64 "\n", + odp_timer_ns_to_tick(tp[0], nsec), odp_timer_ns_to_tick(tp[1], nsec)); + printf(" T2 tick: %" PRIu64 ", %" PRIu64 "\n", t2[0], t2[1]); + printf(" Clk count: %" PRIu64 ", %" PRIu64 "\n", clk_count[0], clk_count[1]); + + odp_timer_pool_destroy(tp[0]); + odp_timer_pool_destroy(tp[1]); +} + +static void timer_pool_sample_ticks(void) +{ + for (int i = 0; i < ODP_CLOCK_NUM_SRC; i++) { + if (global_mem->clk_supported[i]) + timer_pool_sample_ticks_run(ODP_CLOCK_SRC_0 + i); + } +} + static void timer_pool_tick_info_run(odp_timer_clk_src_t clk_src) { odp_timer_capability_t capa; @@ -1572,7 +1742,7 @@ static void timer_test_cancel(void) odp_timer_t tim; odp_event_t ev; odp_timeout_t tmo; - odp_timer_set_t rc; + odp_timer_retval_t rc; int ret; memset(&capa, 0, sizeof(capa)); @@ -1632,7 +1802,7 @@ static void timer_test_cancel(void) CU_FAIL_FATAL("Failed to set timer (relative time)"); ev = ODP_EVENT_INVALID; - if (odp_timer_cancel(tim, &ev) != 0) + if (odp_timer_cancel(tim, &ev) != ODP_TIMER_SUCCESS) CU_FAIL_FATAL("Failed to cancel timer (relative time)"); if (ev == ODP_EVENT_INVALID) @@ -1815,7 +1985,7 @@ static void timer_test_tmo_limit(odp_queue_type_t queue_type, t2 = odp_time_local(); diff_ns = odp_time_diff_ns(t2, t1); - CU_ASSERT(ret == 0); + CU_ASSERT(ret == ODP_TIMER_SUCCESS); CU_ASSERT(ev != ODP_EVENT_INVALID); if (ev != ODP_EVENT_INVALID) @@ -1962,7 +2132,6 @@ static int worker_entrypoint(void *arg ODP_UNUSED) int thr = odp_thread_id(); uint32_t i, allocated; unsigned seed = thr; - int rc; odp_queue_t queue; struct test_timer *tt; uint32_t nset; @@ -1976,7 +2145,7 @@ static int worker_entrypoint(void *arg ODP_UNUSED) odp_event_t ev; struct timespec ts; uint32_t nstale; - odp_timer_set_t timer_rc; + odp_timer_retval_t rc; odp_timer_start_t start_param; odp_timer_pool_t tp = global_mem->tp; odp_pool_t tbp = global_mem->tbp; @@ -2049,11 +2218,11 @@ static int worker_entrypoint(void *arg ODP_UNUSED) start_param.tmo_ev = tt[i].ev; tt[i].ev = ODP_EVENT_INVALID; - timer_rc = odp_timer_start(tt[i].tim, &start_param); - if (timer_rc == ODP_TIMER_TOO_NEAR) { + rc = odp_timer_start(tt[i].tim, &start_param); + if (rc == ODP_TIMER_TOO_NEAR) { ODPH_ERR("Missed tick, setting timer\n"); - } else if (timer_rc != ODP_TIMER_SUCCESS) { - ODPH_ERR("Failed to set timer: %d\n", timer_rc); + } else if (rc != ODP_TIMER_SUCCESS) { + ODPH_ERR("Failed to set timer: %d\n", rc); CU_FAIL("Failed to set timer"); } else { tt[i].tick = tck; @@ -2087,16 +2256,18 @@ static int worker_entrypoint(void *arg ODP_UNUSED) goto sleep; /* Timer active, cancel it */ rc = odp_timer_cancel(tt[i].tim, &tt[i].ev); - if (rc != 0) { + + if (rc == ODP_TIMER_SUCCESS) { + tt[i].tick = TICK_INVALID; + ncancel++; + } else if (rc == ODP_TIMER_TOO_NEAR) { /* Cancel failed, timer already expired */ ntoolate++; - ODPH_DBG("Failed to cancel timer, probably already expired\n"); + ODPH_DBG("Failed to cancel timer, already expired\n"); } else { - tt[i].tick = TICK_INVALID; - ncancel++; + CU_FAIL_FATAL("Cancel failed"); } } else { - odp_timer_set_t rc; uint64_t cur_tick; uint64_t tck; int reset_timer = 0; @@ -2151,15 +2322,21 @@ sleep: CU_FAIL_FATAL("nanosleep failed"); } - /* Cancel and free all timers */ + /* Try to cancel all active timers */ nstale = 0; for (i = 0; i < allocated; i++) { - (void)odp_timer_cancel(tt[i].tim, &tt[i].ev); + if (tt[i].ev != ODP_EVENT_INVALID) + continue; + + rc = odp_timer_cancel(tt[i].tim, &tt[i].ev); tt[i].tick = TICK_INVALID; - if (tt[i].ev == ODP_EVENT_INVALID) - /* Cancel too late, timer already expired and - * timeout enqueued */ + + if (rc == ODP_TIMER_TOO_NEAR) { + /* Cancel too late, timer already expired and timeout enqueued */ nstale++; + } else if (rc != ODP_TIMER_SUCCESS) { + CU_FAIL("Timer cancel failed"); + } } ODPH_DBG("Thread %u: %" PRIu32 " timers set\n", thr, nset); @@ -2207,8 +2384,7 @@ sleep: if (ev != ODP_EVENT_INVALID) CU_FAIL("Unexpected event received"); - rc = odp_queue_destroy(queue); - CU_ASSERT(rc == 0); + CU_ASSERT(odp_queue_destroy(queue) == 0); for (i = 0; i < allocated; i++) { if (tt[i].ev != ODP_EVENT_INVALID) odp_event_free(tt[i].ev); @@ -2407,11 +2583,15 @@ static void timer_test_periodic_capa(void) CU_ASSERT_FATAL(min_fract.integer || min_fract.numer); CU_ASSERT_FATAL(max_fract.integer || max_fract.numer); - if (min_fract.numer) + if (min_fract.numer) { CU_ASSERT_FATAL(min_fract.denom); + CU_ASSERT_FATAL(min_fract.numer < min_fract.denom); + } - if (max_fract.numer) + if (max_fract.numer) { CU_ASSERT_FATAL(max_fract.denom); + CU_ASSERT_FATAL(max_fract.numer < max_fract.denom); + } min_freq = odp_fract_u64_to_dbl(&min_fract); max_freq = odp_fract_u64_to_dbl(&max_fract); @@ -2497,8 +2677,11 @@ static void timer_test_periodic_capa(void) capa.base_freq_hz.numer != base_freq.numer || capa.base_freq_hz.denom != base_freq.denom) - if (capa.base_freq_hz.numer) + if (capa.base_freq_hz.numer) { CU_ASSERT_FATAL(capa.base_freq_hz.denom); + CU_ASSERT_FATAL(capa.base_freq_hz.numer < + capa.base_freq_hz.denom); + } CU_ASSERT(odp_fract_u64_to_dbl(&capa.base_freq_hz) >= min_freq); CU_ASSERT(odp_fract_u64_to_dbl(&capa.base_freq_hz) <= max_freq); @@ -2583,6 +2766,11 @@ static void timer_test_periodic(odp_queue_type_t queue_type, int use_first) if (ret == 0) { /* Allow 10% difference in outputted base frequency */ CU_ASSERT((freq_out > (0.9 * freq)) && (freq_out < (1.1 * freq))); + + if (periodic_capa.base_freq_hz.numer) { + CU_ASSERT_FATAL(periodic_capa.base_freq_hz.numer < + periodic_capa.base_freq_hz.denom); + } } else { CU_ASSERT(base_freq.integer == periodic_capa.base_freq_hz.integer); CU_ASSERT(base_freq.numer == periodic_capa.base_freq_hz.numer); @@ -2798,6 +2986,8 @@ odp_testinfo_t timer_suite[] = { ODP_TEST_INFO(timer_pool_create_destroy), ODP_TEST_INFO(timer_pool_create_max), ODP_TEST_INFO(timer_pool_max_res), + ODP_TEST_INFO(timer_pool_current_tick), + ODP_TEST_INFO(timer_pool_sample_ticks), ODP_TEST_INFO(timer_pool_tick_info), ODP_TEST_INFO_CONDITIONAL(timer_plain_rel_wait, check_plain_queue_support), ODP_TEST_INFO_CONDITIONAL(timer_plain_abs_wait, check_plain_queue_support), |