From patchwork Fri Feb 16 21:00:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128640 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp977180ljc; Fri, 16 Feb 2018 13:03:15 -0800 (PST) X-Google-Smtp-Source: AH8x224sRl/5iTuZmGGc5mcOlrh4C0iiHwchnq+czHBwiLkZ7AiGEtAIHLFmdjkh4Ncc+d3I5awO X-Received: by 10.237.52.36 with SMTP id w33mr8588424qtd.257.1518814995075; Fri, 16 Feb 2018 13:03:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518814995; cv=none; d=google.com; s=arc-20160816; b=J61Pu4b8JNaHUqHp5315o2fhdj4p+27xC+BNpbcWSjbPAktnr1ZyoknEXWVBQoWU9S irGoVEUXJ0h7ddN51SFEWtB2P8ZFhBtiEQDEChtGH0IGTZ2OekMnlgkVrzSEwpoUz+7Q ZRl1kUS/MvjazRGZP02wFWRYH6PlHUXtfQQ/NnA7jIHZWdg/KSOjJr1IFVWkCSB/lJpE PHkztNSvUFoWVmZzHNUp1+6juyY0UL4iC0+Eckdi8GAWND4vmdQIdNVwIQhPu1VMK2fi l03zoV08ScOpovwGzFc3fK+viLt8HnoluzujKisfOnSZxg+aKetZp0h769MQULq1PFRq Fi9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:github-pr-num:mime-version:references :in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=8A3CvFIxTyshwZnMaKQppsPM5TR/4oyzIGepaGK4zM4=; b=xsHg5hjvirXaZ6ZPwsgE/QQnSYe6btnuScCK+zTXn75eedLznKc8q6Gx0mspuoVZZa 7ADEZ8FZM6qzusJQw27RjpUMoaNEZu9U+LbtjeQ1e5DCLr/ib3m+HVX6mM6goR7iE56g +PoM9ge20zVt3of4TfgqVtzCO/Iw9i1cEcn8nZ07xHm4CylBXd5wkRehPUpBRBaA3E/P u+ritg5wNQ45cfYL7Dl+NZ7pi1wzRxxQTCCDHWtTt6R6z/UqcKcnPxP0gvl35v1omdzt cT3sO6RPmOGrUVSzGOktUQg+74WcOyKCldwivITdg2cnYNgF9e7Tkg/k4+3Y6TT9JjJD fz9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id o15si2690375qtk.346.2018.02.16.13.03.11; Fri, 16 Feb 2018 13:03:15 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E573E617AA; Fri, 16 Feb 2018 21:03:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E143D6172B; Fri, 16 Feb 2018 21:00:52 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E5DAC616FA; Fri, 16 Feb 2018 21:00:36 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id EE87660CBD for ; Fri, 16 Feb 2018 21:00:24 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 42A57181B9A for ; Sat, 17 Feb 2018 00:00:23 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OZaEKOxIsc-0NXCUtQF; Sat, 17 Feb 2018 00:00:23 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id A5sQrqtPc3-0MxevIRg; Sat, 17 Feb 2018 00:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 17 Feb 2018 00:00:18 +0300 Message-Id: <1518814818-27115-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518814818-27115-1-git-send-email-odpbot@yandex.ru> References: <1518814818-27115-1-git-send-email-odpbot@yandex.ru> MIME-Version: 1.0 Github-pr-num: 464 Subject: [lng-odp] [PATCH API-NEXT v1 3/3] validation: crypto: draft of 3GPP crypto algorightms support X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 464 (lumag:crypto-3gpp) ** https://github.com/Linaro/odp/pull/464 ** Patch: https://github.com/Linaro/odp/pull/464.patch ** Base sha: af7be638ef9ac98bdb1f2e4917f152889eb1850f ** Merge commit sha: da657b8b144e5fd9f465c0a4a0698ecd7dad4eef **/ test/validation/api/crypto/odp_crypto_test_inp.c | 420 ++++++++++++++++++++++- test/validation/api/crypto/test_vectors.h | 408 ++++++++++++++++++++++ test/validation/api/crypto/test_vectors_len.h | 27 ++ 3 files changed, 838 insertions(+), 17 deletions(-) diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 8c0ef5bca..386b2e6e1 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -58,6 +58,12 @@ static const char *auth_alg_name(odp_auth_alg_t auth) 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_ZUC_EIA3: + return "ODP_AUTH_ALG_ZUC_EIA3"; default: return "Unknown"; } @@ -80,6 +86,12 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher) 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_ZUC_EEA3: + return "ODP_CIPHER_ALG_ZUC_EEA3"; default: return "Unknown"; } @@ -322,6 +334,7 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_ses_create_err_t status; odp_bool_t ok = false; int iteration; + uint32_t reflength; odp_crypto_session_param_t ses_params; odp_packet_data_range_t cipher_range; odp_packet_data_range_t auth_range; @@ -358,6 +371,7 @@ static void alg_test(odp_crypto_op_t op, ses_params.auth_key = auth_key; ses_params.auth_digest_len = ref->digest_length; ses_params.auth_aad_len = ref->aad_length; + ses_params.bitstring = ref->bitstring; rc = odp_crypto_session_create(&ses_params, &session, &status); CU_ASSERT_FATAL(!rc); @@ -370,9 +384,14 @@ static void alg_test(odp_crypto_op_t op, auth_range.offset = 0; auth_range.length = ref->length; + if (ref->bitstring) + reflength = (ref->length + 7) / 8; + else + reflength = ref->length; + /* Prepare input data */ odp_packet_t pkt = odp_packet_alloc(suite_context.pool, - ref->length + ref->digest_length); + reflength + ref->digest_length); CU_ASSERT(pkt != ODP_PACKET_INVALID); if (pkt == ODP_PACKET_INVALID) goto cleanup; @@ -386,18 +405,18 @@ static void alg_test(odp_crypto_op_t op, continue; if (op == ODP_CRYPTO_OP_ENCODE) { - odp_packet_copy_from_mem(pkt, 0, ref->length, + odp_packet_copy_from_mem(pkt, 0, reflength, ref->plaintext); } else { - odp_packet_copy_from_mem(pkt, 0, ref->length, + odp_packet_copy_from_mem(pkt, 0, reflength, ref->ciphertext); - odp_packet_copy_from_mem(pkt, ref->length, + odp_packet_copy_from_mem(pkt, reflength, ref->digest_length, ref->digest); if (iteration == WRONG_DIGEST_TEST) { uint8_t byte = ~ref->digest[0]; - odp_packet_copy_from_mem(pkt, ref->length, + odp_packet_copy_from_mem(pkt, reflength, 1, &byte); } } @@ -407,19 +426,19 @@ static void alg_test(odp_crypto_op_t op, ovr_iv ? ref->cipher_iv : NULL, ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->length); + ref->aad, reflength); else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) rc = alg_packet_op_enq(pkt, &ok, session, ovr_iv ? ref->cipher_iv : NULL, ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->length); + ref->aad, reflength); else rc = alg_packet_op(pkt, &ok, session, ovr_iv ? ref->cipher_iv : NULL, ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, - ref->aad, ref->length); + ref->aad, reflength); if (rc < 0) break; @@ -433,14 +452,14 @@ static void alg_test(odp_crypto_op_t op, if (op == ODP_CRYPTO_OP_ENCODE) { CU_ASSERT(!packet_cmp_mem(pkt, 0, ref->ciphertext, - ref->length)); - CU_ASSERT(!packet_cmp_mem(pkt, ref->length, + reflength)); + CU_ASSERT(!packet_cmp_mem(pkt, reflength, ref->digest, ref->digest_length)); } else { CU_ASSERT(!packet_cmp_mem(pkt, 0, ref->plaintext, - ref->length)); + reflength)); } } @@ -489,6 +508,15 @@ static void check_alg(odp_crypto_op_t op, if (cipher_alg == ODP_CIPHER_ALG_CHACHA20_POLY1305 && !(capa.ciphers.bit.chacha20_poly1305)) rc = -1; + if (cipher_alg == ODP_CIPHER_ALG_KASUMI_F8 && + !(capa.ciphers.bit.kasumi_f8)) + rc = -1; + if (cipher_alg == ODP_CIPHER_ALG_SNOW3G_UEA2 && + !(capa.ciphers.bit.snow3g_uea2)) + rc = -1; + if (cipher_alg == ODP_CIPHER_ALG_ZUC_EEA3 && + !(capa.ciphers.bit.zuc_eea3)) + rc = -1; if (cipher_alg == ODP_CIPHER_ALG_DES && !(capa.ciphers.bit.des)) rc = -1; @@ -514,6 +542,15 @@ static void check_alg(odp_crypto_op_t op, if (auth_alg == ODP_AUTH_ALG_CHACHA20_POLY1305 && !(capa.auths.bit.chacha20_poly1305)) rc = -1; + if (auth_alg == ODP_AUTH_ALG_KASUMI_F9 && + !(capa.auths.bit.kasumi_f9)) + rc = -1; + if (auth_alg == ODP_AUTH_ALG_SNOW3G_UIA2 && + !(capa.auths.bit.snow3g_uia2)) + rc = -1; + if (auth_alg == ODP_AUTH_ALG_ZUC_EIA3 && + !(capa.auths.bit.zuc_eia3)) + rc = -1; if (auth_alg == ODP_AUTH_ALG_MD5_HMAC && !(capa.auths.bit.md5_hmac)) rc = -1; @@ -559,7 +596,9 @@ static void check_alg(odp_crypto_op_t op, if (cipher_capa[i].key_len == ref[idx].cipher_key_length && cipher_capa[i].iv_len == - ref[idx].cipher_iv_length) { + ref[idx].cipher_iv_length && + cipher_capa[i].bitstring == + ref[idx].bitstring) { cipher_idx = i; break; } @@ -567,10 +606,11 @@ static void check_alg(odp_crypto_op_t op, if (cipher_idx < 0) { printf("\n Unsupported: alg=%s, key_len=%" PRIu32 - ", iv_len=%" PRIu32 "\n", + ", iv_len=%" PRIu32 "%s\n", cipher_alg_name(cipher_alg), ref[idx].cipher_key_length, - ref[idx].cipher_iv_length); + ref[idx].cipher_iv_length, + ref[idx].bitstring ? " bitstring" : ""); continue; } @@ -580,7 +620,9 @@ static void check_alg(odp_crypto_op_t op, auth_capa[i].iv_len == ref[idx].auth_iv_length && auth_capa[i].key_len == - ref[idx].auth_key_length) { + ref[idx].auth_key_length && + auth_capa[i].bitstring == + ref[idx].bitstring) { auth_idx = i; break; } @@ -588,11 +630,13 @@ static void check_alg(odp_crypto_op_t op, if (auth_idx < 0) { printf("\n Unsupported: alg=%s, key_len=%" PRIu32 - ", iv_len=%" PRIu32 ", digest_len=%" PRIu32 "\n", + ", iv_len=%" PRIu32 ", digest_len=%" PRIu32 + "%s\n", auth_alg_name(auth_alg), ref[idx].auth_key_length, ref[idx].auth_iv_length, - ref[idx].digest_length); + ref[idx].digest_length, + ref[idx].bitstring ? " bitstring" : ""); continue; } @@ -687,6 +731,18 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) 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_ZUC_EEA3: + if (!capability.ciphers.bit.zuc_eea3) + return ODP_TEST_INACTIVE; + break; default: fprintf(stderr, "Unsupported cipher algorithm\n"); return ODP_TEST_INACTIVE; @@ -734,6 +790,18 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) 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_ZUC_EIA3: + if (!capability.auths.bit.zuc_eia3) + return ODP_TEST_INACTIVE; + break; default: fprintf(stderr, "Unsupported authentication algorithm\n"); return ODP_TEST_INACTIVE; @@ -1108,6 +1176,141 @@ static void crypto_test_dec_alg_aes_ctr_ovr_iv(void) true); } +static int check_alg_kasumi_f8(void) +{ + return check_alg_support(ODP_CIPHER_ALG_KASUMI_F8, ODP_AUTH_ALG_NULL); +} + +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), + false); +} + +static void crypto_test_enc_alg_kasumi_f8_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_KASUMI_F8, + ODP_AUTH_ALG_NULL, + kasumi_f8_reference, + ARRAY_SIZE(kasumi_f8_reference), + true); +} + +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), + false); +} + +static void crypto_test_dec_alg_kasumi_f8_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_KASUMI_F8, + ODP_AUTH_ALG_NULL, + kasumi_f8_reference, + ARRAY_SIZE(kasumi_f8_reference), + true); +} + +static int check_alg_snow3g_uea2(void) +{ + return check_alg_support(ODP_CIPHER_ALG_SNOW3G_UEA2, ODP_AUTH_ALG_NULL); +} + +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), + false); +} + +static void crypto_test_enc_alg_snow3g_uea2_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_SNOW3G_UEA2, + ODP_AUTH_ALG_NULL, + snow3g_uea2_reference, + ARRAY_SIZE(snow3g_uea2_reference), + true); +} + +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), + false); +} + +static void crypto_test_dec_alg_snow3g_uea2_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_SNOW3G_UEA2, + ODP_AUTH_ALG_NULL, + snow3g_uea2_reference, + ARRAY_SIZE(snow3g_uea2_reference), + true); +} + +static int check_alg_zuc_eea3(void) +{ + return check_alg_support(ODP_CIPHER_ALG_ZUC_EEA3, ODP_AUTH_ALG_NULL); +} + +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), + false); +} + +static void crypto_test_enc_alg_zuc_eea3_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_ZUC_EEA3, + ODP_AUTH_ALG_NULL, + zuc_eea3_reference, + ARRAY_SIZE(zuc_eea3_reference), + true); +} + +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), + false); +} + +static void crypto_test_dec_alg_zuc_eea3_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_ZUC_EEA3, + ODP_AUTH_ALG_NULL, + zuc_eea3_reference, + ARRAY_SIZE(zuc_eea3_reference), + true); +} + static int check_alg_hmac_md5(void) { return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_MD5_HMAC); @@ -1306,6 +1509,141 @@ static void crypto_test_check_alg_aes_cmac(void) false); } +static int check_alg_kasumi_f9(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_KASUMI_F9); +} + +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), + false); +} + +static void crypto_test_gen_alg_kasumi_f9_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_KASUMI_F9, + kasumi_f9_reference, + ARRAY_SIZE(kasumi_f9_reference), + true); +} + +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), + false); +} + +static void crypto_test_check_alg_kasumi_f9_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_KASUMI_F9, + kasumi_f9_reference, + ARRAY_SIZE(kasumi_f9_reference), + true); +} + +static int check_alg_snow3g_uia2(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_SNOW3G_UIA2); +} + +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), + false); +} + +static void crypto_test_gen_alg_snow3g_uia2_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_SNOW3G_UIA2, + snow3g_uia2_reference, + ARRAY_SIZE(snow3g_uia2_reference), + true); +} + +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), + false); +} + +static void crypto_test_check_alg_snow3g_uia2_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_SNOW3G_UIA2, + snow3g_uia2_reference, + ARRAY_SIZE(snow3g_uia2_reference), + true); +} + +static int check_alg_zuc_eia3(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_ZUC_EIA3); +} + +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), + false); +} + +static void crypto_test_gen_alg_zuc_eia3_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_ZUC_EIA3, + zuc_eia3_reference, + ARRAY_SIZE(zuc_eia3_reference), + true); +} + +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), + false); +} + +static void crypto_test_check_alg_zuc_eia3_ovr_iv(void) +{ + check_alg(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_ZUC_EIA3, + zuc_eia3_reference, + ARRAY_SIZE(zuc_eia3_reference), + true); +} + int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); @@ -1387,6 +1725,30 @@ odp_testinfo_t crypto_suite[] = { check_alg_aes_ctr), ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_ctr_ovr_iv, check_alg_aes_ctr), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_kasumi_f8, + check_alg_kasumi_f8), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_kasumi_f8, + check_alg_kasumi_f8), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_kasumi_f8_ovr_iv, + check_alg_kasumi_f8), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_kasumi_f8_ovr_iv, + check_alg_kasumi_f8), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_snow3g_uea2, + check_alg_snow3g_uea2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_snow3g_uea2, + check_alg_snow3g_uea2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_snow3g_uea2_ovr_iv, + check_alg_snow3g_uea2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_snow3g_uea2_ovr_iv, + check_alg_snow3g_uea2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_zuc_eea3, + check_alg_zuc_eea3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_zuc_eea3, + check_alg_zuc_eea3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_zuc_eea3_ovr_iv, + check_alg_zuc_eea3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_zuc_eea3_ovr_iv, + check_alg_zuc_eea3), ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm, check_alg_aes_gcm), ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm_ovr_iv, @@ -1439,6 +1801,30 @@ odp_testinfo_t crypto_suite[] = { check_alg_aes_cmac), ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_cmac, check_alg_aes_cmac), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_kasumi_f9, + check_alg_kasumi_f9), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_kasumi_f9, + check_alg_kasumi_f9), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_kasumi_f9_ovr_iv, + check_alg_kasumi_f9), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_kasumi_f9_ovr_iv, + check_alg_kasumi_f9), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_snow3g_uia2, + check_alg_snow3g_uia2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_snow3g_uia2, + check_alg_snow3g_uia2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_snow3g_uia2_ovr_iv, + check_alg_snow3g_uia2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_snow3g_uia2_ovr_iv, + check_alg_snow3g_uia2), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_zuc_eia3, + check_alg_zuc_eia3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_zuc_eia3, + check_alg_zuc_eia3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_zuc_eia3_ovr_iv, + check_alg_zuc_eia3), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_zuc_eia3_ovr_iv, + check_alg_zuc_eia3), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h index 23ed95251..a7dd316da 100644 --- a/test/validation/api/crypto/test_vectors.h +++ b/test/validation/api/crypto/test_vectors.h @@ -25,6 +25,7 @@ typedef struct crypto_test_reference_s { uint8_t aad[MAX_AAD_LEN]; uint32_t digest_length; uint8_t digest[MAX_DIGEST_LEN]; + odp_bool_t bitstring; } crypto_test_reference_t; static crypto_test_reference_t null_reference[] = { @@ -1325,4 +1326,411 @@ static crypto_test_reference_t hmac_sha512_reference[] = { } }; +/* + * 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[] = { + { + .bitstring = true, + .cipher_key_length = KASUMI_F8_KEY_LEN, + .cipher_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, + 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48}, + .cipher_iv_length = KASUMI_F8_IV_LEN, + .cipher_iv = { 0x72, 0xa4, 0xf2, 0x0f, 0x64, 0x00, 0x00, 0x00 }, + .length = 798, /* 100 bytes */ + .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 = { 0xd1, 0xe2, 0xde, 0x70, 0xee, 0xf8, 0x6c, 0x69, + 0x64, 0xfb, 0x54, 0x2b, 0xc2, 0xd4, 0x60, 0xaa, + 0xbf, 0xaa, 0x10, 0xa4, 0xa0, 0x93, 0x26, 0x2b, + 0x7d, 0x19, 0x9e, 0x70, 0x6f, 0xc2, 0xd4, 0x89, + 0x15, 0x53, 0x29, 0x69, 0x10, 0xf3, 0xa9, 0x73, + 0x01, 0x26, 0x82, 0xe4, 0x1c, 0x4e, 0x2b, 0x02, + 0xbe, 0x20, 0x17, 0xb7, 0x25, 0x3b, 0xbf, 0x93, + 0x09, 0xde, 0x58, 0x19, 0xcb, 0x42, 0xe8, 0x19, + 0x56, 0xf4, 0xc9, 0x9b, 0xc9, 0x76, 0x5c, 0xaf, + 0x53, 0xb1, 0xd0, 0xbb, 0x82, 0x79, 0x82, 0x6a, + 0xdb, 0xbc, 0x55, 0x22, 0xe9, 0x15, 0xc1, 0x20, + 0xa6, 0x18, 0xa5, 0xa7, 0xf5, 0xe8, 0x97, 0x08, + 0x93, 0x39, 0x65, 0x0f } + }, + { + .bitstring = true, + .cipher_key_length = KASUMI_F8_KEY_LEN, + .cipher_key = { 0xef, 0xa8, 0xb2, 0x22, 0x9e, 0x72, 0x0c, 0x2a, + 0x7c, 0x36, 0xea, 0x55, 0xe9, 0x60, 0x56, 0x95}, + .cipher_iv_length = KASUMI_F8_IV_LEN, + .cipher_iv = { 0xe2, 0x8b, 0xcf, 0x7b, 0xc0, 0x00, 0x00, 0x00 }, + .length = 510, /* 64 bytes */ + .plaintext = { 0x10, 0x11, 0x12, 0x31, 0xe0, 0x60, 0x25, 0x3a, + 0x43, 0xfd, 0x3f, 0x57, 0xe3, 0x76, 0x07, 0xab, + 0x28, 0x27, 0xb5, 0x99, 0xb6, 0xb1, 0xbb, 0xda, + 0x37, 0xa8, 0xab, 0xcc, 0x5a, 0x8c, 0x55, 0x0d, + 0x1b, 0xfb, 0x2f, 0x49, 0x46, 0x24, 0xfb, 0x50, + 0x36, 0x7f, 0xa3, 0x6c, 0xe3, 0xbc, 0x68, 0xf1, + 0x1c, 0xf9, 0x3b, 0x15, 0x10, 0x37, 0x6b, 0x02, + 0x13, 0x0f, 0x81, 0x2a, 0x9f, 0xa1, 0x69, 0xd8}, + .ciphertext = { 0x3d, 0xea, 0xcc, 0x7c, 0x15, 0x82, 0x1c, 0xaa, + 0x89, 0xee, 0xca, 0xde, 0x9b, 0x5b, 0xd3, 0x61, + 0x4b, 0xd0, 0xc8, 0x41, 0x9d, 0x71, 0x03, 0x85, + 0xdd, 0xbe, 0x58, 0x49, 0xef, 0x1b, 0xac, 0x5a, + 0xe8, 0xb1, 0x4a, 0x5b, 0x0a, 0x67, 0x41, 0x52, + 0x1e, 0xb4, 0xe0, 0x0b, 0xb9, 0xec, 0xf3, 0xe9, + 0xf7, 0xcc, 0xb9, 0xca, 0xe7, 0x41, 0x52, 0xd7, + 0xf4, 0xe2, 0xa0, 0x34, 0xb6, 0xea, 0x00, 0xec } + } +}; + +static crypto_test_reference_t kasumi_f9_reference[] = { + { + .bitstring = true, + .auth_key_length = KASUMI_F9_KEY_LEN, + .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, + 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 }, + .auth_iv_length = KASUMI_F9_IV_LEN, + .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0x05, 0xd2, 0xec, 0x49, + 0x00, }, + .length = 189, /* 24 bytes */ + .plaintext = { 0x6b, 0x22, 0x77, 0x37, 0x29, 0x6f, 0x39, 0x3c, + 0x80, 0x79, 0x35, 0x3e, 0xdc, 0x87, 0xe2, 0xe8, + 0x05, 0xd2, 0xec, 0x49, 0xa4, 0xf2, 0xd8, 0xe0}, + .ciphertext = { 0x6b, 0x22, 0x77, 0x37, 0x29, 0x6f, 0x39, 0x3c, + 0x80, 0x79, 0x35, 0x3e, 0xdc, 0x87, 0xe2, 0xe8, + 0x05, 0xd2, 0xec, 0x49, 0xa4, 0xf2, 0xd8, 0xe0}, + .digest_length = KASUMI_F9_DIGEST_LEN, + .digest = { 0xf6, 0x3b, 0xd7, 0x2c } + }, + { + .bitstring = true, + .auth_key_length = KASUMI_F9_KEY_LEN, + .auth_key = { 0xd4, 0x2f, 0x68, 0x24, 0x28, 0x20, 0x1c, 0xaf, + 0xcd, 0x9f, 0x97, 0x94, 0x5e, 0x6d, 0xe7, 0xb7 }, + .auth_iv_length = KASUMI_F9_IV_LEN, + .auth_iv = { 0x3e, 0xdc, 0x87, 0xe2, 0xa4, 0xf2, 0xd8, 0xe2, + 0x01, }, + .length = 254, /* 32 bytes */ + .plaintext = { 0xb5, 0x92, 0x43, 0x84, 0x32, 0x8a, 0x4a, 0xe0, + 0x0b, 0x73, 0x71, 0x09, 0xf8, 0xb6, 0xc8, 0xdd, + 0x2b, 0x4d, 0xb6, 0x3d, 0xd5, 0x33, 0x98, 0x1c, + 0xeb, 0x19, 0xaa, 0xd5, 0x2a, 0x5b, 0x2b, 0xc0}, + .ciphertext = { 0xb5, 0x92, 0x43, 0x84, 0x32, 0x8a, 0x4a, 0xe0, + 0x0b, 0x73, 0x71, 0x09, 0xf8, 0xb6, 0xc8, 0xdd, + 0x2b, 0x4d, 0xb6, 0x3d, 0xd5, 0x33, 0x98, 0x1c, + 0xeb, 0x19, 0xaa, 0xd5, 0x2a, 0x5b, 0x2b, 0xc0}, + .digest_length = KASUMI_F9_DIGEST_LEN, + .digest = { 0xa9, 0xda, 0xf1, 0xff } + } +}; + +/* + * 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[] = { + { + .bitstring = true, + .cipher_key_length = SNOW3G_UEA2_KEY_LEN, + .cipher_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, + 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48}, + .cipher_iv_length = SNOW3G_UEA2_IV_LEN, + .cipher_iv = { 0x72, 0xa4, 0xf2, 0x0f, 0x64, 0x00, 0x00, 0x00, + 0x72, 0xa4, 0xf2, 0x0f, 0x64, 0x00, 0x00, 0x00 }, + .length = 798, /* 100 bytes */ + .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 = { 0x8c, 0xeb, 0xa6, 0x29, 0x43, 0xdc, 0xed, 0x3a, + 0x09, 0x90, 0xb0, 0x6e, 0xa1, 0xb0, 0xa2, 0xc4, + 0xfb, 0x3c, 0xed, 0xc7, 0x1b, 0x36, 0x9f, 0x42, + 0xba, 0x64, 0xc1, 0xeb, 0x66, 0x65, 0xe7, 0x2a, + 0xa1, 0xc9, 0xbb, 0x0d, 0xea, 0xa2, 0x0f, 0xe8, + 0x60, 0x58, 0xb8, 0xba, 0xee, 0x2c, 0x2e, 0x7f, + 0x0b, 0xec, 0xce, 0x48, 0xb5, 0x29, 0x32, 0xa5, + 0x3c, 0x9d, 0x5f, 0x93, 0x1a, 0x3a, 0x7c, 0x53, + 0x22, 0x59, 0xaf, 0x43, 0x25, 0xe2, 0xa6, 0x5e, + 0x30, 0x84, 0xad, 0x5f, 0x6a, 0x51, 0x3b, 0x7b, + 0xdd, 0xc1, 0xb6, 0x5f, 0x0a, 0xa0, 0xd9, 0x7a, + 0x05, 0x3d, 0xb5, 0x5a, 0x88, 0xc4, 0xc4, 0xf9, + 0x60, 0x5e, 0x41, 0x40 } + }, + { + .bitstring = true, + .cipher_key_length = SNOW3G_UEA2_KEY_LEN, + .cipher_key = { 0xef, 0xa8, 0xb2, 0x22, 0x9e, 0x72, 0x0c, 0x2a, + 0x7c, 0x36, 0xea, 0x55, 0xe9, 0x60, 0x56, 0x95}, + .cipher_iv_length = SNOW3G_UEA2_IV_LEN, + .cipher_iv = { 0xe2, 0x8b, 0xcf, 0x7b, 0xc0, 0x00, 0x00, 0x00, + 0xe2, 0x8b, 0xcf, 0x7b, 0xc0, 0x00, 0x00, 0x00 }, + .length = 510, /* 64 bytes */ + .plaintext = { 0x10, 0x11, 0x12, 0x31, 0xe0, 0x60, 0x25, 0x3a, + 0x43, 0xfd, 0x3f, 0x57, 0xe3, 0x76, 0x07, 0xab, + 0x28, 0x27, 0xb5, 0x99, 0xb6, 0xb1, 0xbb, 0xda, + 0x37, 0xa8, 0xab, 0xcc, 0x5a, 0x8c, 0x55, 0x0d, + 0x1b, 0xfb, 0x2f, 0x49, 0x46, 0x24, 0xfb, 0x50, + 0x36, 0x7f, 0xa3, 0x6c, 0xe3, 0xbc, 0x68, 0xf1, + 0x1c, 0xf9, 0x3b, 0x15, 0x10, 0x37, 0x6b, 0x02, + 0x13, 0x0f, 0x81, 0x2a, 0x9f, 0xa1, 0x69, 0xd8}, + .ciphertext = { 0xe0, 0xda, 0x15, 0xca, 0x8e, 0x25, 0x54, 0xf5, + 0xe5, 0x6c, 0x94, 0x68, 0xdc, 0x6c, 0x7c, 0x12, + 0x9c, 0x56, 0x8a, 0xa5, 0x03, 0x23, 0x17, 0xe0, + 0x4e, 0x07, 0x29, 0x64, 0x6c, 0xab, 0xef, 0xa6, + 0x89, 0x86, 0x4c, 0x41, 0x0f, 0x24, 0xf9, 0x19, + 0xe6, 0x1e, 0x3d, 0xfd, 0xfa, 0xd7, 0x7e, 0x56, + 0x0d, 0xb0, 0xa9, 0xcd, 0x36, 0xc3, 0x4a, 0xe4, + 0x18, 0x14, 0x90, 0xb2, 0x9f, 0x5f, 0xa2, 0xfc } + } +}; + +static crypto_test_reference_t snow3g_uia2_reference[] = { + { + .bitstring = true, + .auth_key_length = SNOW3G_UIA2_KEY_LEN, + .auth_key = { 0x2b, 0xd6, 0x45, 0x9f, 0x82, 0xc5, 0xb3, 0x00, + 0x95, 0x2c, 0x49, 0x10, 0x48, 0x81, 0xff, 0x48 }, + .auth_iv_length = SNOW3G_UIA2_IV_LEN, + .auth_iv = { 0x38, 0xa6, 0xf0, 0x56, 0x05, 0xd2, 0xec, 0x49, + 0x38, 0xa6, 0xf0, 0x56, 0x05, 0xd2, 0xec, 0x49 }, + .length = 189, /* 24 bytes */ + .plaintext = { 0x6b, 0x22, 0x77, 0x37, 0x29, 0x6f, 0x39, 0x3c, + 0x80, 0x79, 0x35, 0x3e, 0xdc, 0x87, 0xe2, 0xe8, + 0x05, 0xd2, 0xec, 0x49, 0xa4, 0xf2, 0xd8, 0xe0}, + .ciphertext = { 0x6b, 0x22, 0x77, 0x37, 0x29, 0x6f, 0x39, 0x3c, + 0x80, 0x79, 0x35, 0x3e, 0xdc, 0x87, 0xe2, 0xe8, + 0x05, 0xd2, 0xec, 0x49, 0xa4, 0xf2, 0xd8, 0xe0}, + .digest_length = SNOW3G_UIA2_DIGEST_LEN, + .digest = { 0x2b, 0xce, 0x18, 0x20 } + }, + { + .bitstring = true, + .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 */ + .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 } + }, + { + .bitstring = false, + .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 / 8, /* 48 bytes */ + .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 } + }, +}; + +/* + * 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[] = { + { + .bitstring = true, + .cipher_key_length = ZUC_EEA3_KEY_LEN, + .cipher_key = { 0x17, 0x3d, 0x14, 0xba, 0x50, 0x03, 0x73, 0x1d, + 0x7a, 0x60, 0x04, 0x94, 0x70, 0xf0, 0x0a, 0x29}, + .cipher_iv_length = ZUC_EEA3_IV_LEN, + .cipher_iv = { 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00, + 0x66, 0x03, 0x54, 0x92, 0x78, 0x00, 0x00, 0x00 }, + .length = 193, /* 25 bytes */ + .plaintext = { 0x6c, 0xf6, 0x53, 0x40, 0x73, 0x55, 0x52, 0xab, + 0x0c, 0x97, 0x52, 0xfa, 0x6f, 0x90, 0x25, 0xfe, + 0x0b, 0xd6, 0x75, 0xd9, 0x00, 0x58, 0x75, 0xb2, + 0x00 }, + .ciphertext = { 0xa6, 0xc8, 0x5f, 0xc6, 0x6a, 0xfb, 0x85, 0x33, + 0xaa, 0xfc, 0x25, 0x18, 0xdf, 0xe7, 0x84, 0x94, + 0x0e, 0xe1, 0xe4, 0xb0, 0x30, 0x23, 0x8c, 0xc8, + 0x00 } + }, + { + .bitstring = true, + .cipher_key_length = ZUC_EIA3_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 */ + .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 } + }, + { + .bitstring = false, + .cipher_key_length = ZUC_EIA3_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 / 8, /* 100 bytes */ + .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 } + } +}; + +static crypto_test_reference_t zuc_eia3_reference[] = { + { + .bitstring = true, + .auth_key_length = ZUC_EIA3_KEY_LEN, + .auth_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .auth_iv_length = ZUC_EIA3_IV_LEN, + .auth_iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + .length = 1, /* 1 bytes */ + .plaintext = { 0x00 }, + .ciphertext = { 0x00 }, + .digest_length = ZUC_EIA3_DIGEST_LEN, + .digest = { 0xc8, 0xa9, 0x59, 0x5e } + }, + { + .bitstring = true, + .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 = 577, /* 73 bytes */ + .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 }, + .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 }, + .digest_length = ZUC_EIA3_DIGEST_LEN, + .digest = { 0xfa, 0xe8, 0xff, 0x0b } + } +}; + #endif diff --git a/test/validation/api/crypto/test_vectors_len.h b/test/validation/api/crypto/test_vectors_len.h index 860840cfe..f2ecaf091 100644 --- a/test/validation/api/crypto/test_vectors_len.h +++ b/test/validation/api/crypto/test_vectors_len.h @@ -60,4 +60,31 @@ #define CHACHA20_POLY1305_IV_LEN 12 #define CHACHA20_POLY1305_CHECK_LEN 16 +/* KASUMI_F8 */ +#define KASUMI_F8_KEY_LEN 16 +#define KASUMI_F8_IV_LEN 8 + +/* SNOW3G_UEA2 */ +#define SNOW3G_UEA2_KEY_LEN 16 +#define SNOW3G_UEA2_IV_LEN 16 + +/* ZUC_EEA3 */ +#define ZUC_EEA3_KEY_LEN 16 +#define ZUC_EEA3_IV_LEN 16 + +/* KASUMI_F9 */ +#define KASUMI_F9_KEY_LEN 16 +#define KASUMI_F9_IV_LEN 9 +#define KASUMI_F9_DIGEST_LEN 4 + +/* SNOW3G_UIA2 */ +#define SNOW3G_UIA2_KEY_LEN 16 +#define SNOW3G_UIA2_IV_LEN 16 +#define SNOW3G_UIA2_DIGEST_LEN 4 + +/* ZUC_EIA3 */ +#define ZUC_EIA3_KEY_LEN 16 +#define ZUC_EIA3_IV_LEN 16 +#define ZUC_EIA3_DIGEST_LEN 4 + #endif