From patchwork Tue Aug 1 02:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109078 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp912337qge; Mon, 31 Jul 2017 19:00:57 -0700 (PDT) X-Received: by 10.55.26.14 with SMTP id a14mr24877244qka.4.1501552857261; Mon, 31 Jul 2017 19:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501552857; cv=none; d=google.com; s=arc-20160816; b=GMULTSxHM1kDahBQZrBl/PgnyYSPtRQbj68RjkfnReYQ3kYCpBcXO1B4XpS7cvgYHD peAvcjZCYAgwQREu77EYrjZXXfkSN9fkbeGFY8exp/mIVVg4nZslM8P7kL2g0jbfYtx1 rIbHxOd+K+t71mdx56ob5QkE8dHf+yYqtAzIKvS1ts1h65R3SGj6Q8r+yxqn2c64itp2 RBJfY+4pT77lyzLC42KyWGheqm83RSGcFvpu0UOAXBcQ4OEbI+gzY3egosQJgtHl9Lmx jHR5z0TJ2WhrgYj6JKTkb8pkGATiq9HVDPxWNragTT9hg4r9E2wskODTNR0J0v1ZMIeO LAtw== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=5AwjAiDuRe5Wd5XIOt3eOiFi6HYMGVeOzWkxKTjDWas=; b=lG1SUjqI0Ib+Hay8Gee8koKMhrVZ5P6Vf9JR9Dl5B5c3FRu4klcxdghXc5yVpbDsY6 vHLLV0isY3WxOUwgpAZccIPIbYJ0bZQb5PIxdcTUMWCuLNvdCdJjZbGkipcEC4iKN6sb NqrCNpnLa8CyyJrYpEQjj0/JvDXWiWM1kGN9YsQLOyBly2Qgqgxv/tCnY0RaKm2mG712 Rne2YQKtg5CWBSe/FHfkjQQCvcqiMuARVbxeDUIpOGhv8ALshffvolfnm6ST7kv2QKtl hSb81jvPTaEKJae3Xu402nIt7P96/q74QLLjM8xzB2PC5PjbuVLpnpNVd7hxoMnUETqd zIuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k188si24727407qkc.178.2017.07.31.19.00.56; Mon, 31 Jul 2017 19:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 DAD1965CFC; Tue, 1 Aug 2017 02:00:56 +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,URIBL_BLOCKED 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 DC4BE65C78; Tue, 1 Aug 2017 02:00:25 +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 B312B65C3D; Tue, 1 Aug 2017 02:00:22 +0000 (UTC) Received: from forward4h.cmail.yandex.net (forward4h.cmail.yandex.net [87.250.230.101]) by lists.linaro.org (Postfix) with ESMTPS id A453B644D9 for ; Tue, 1 Aug 2017 02:00:21 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::25]) by forward4h.cmail.yandex.net (Yandex) with ESMTP id 29A9B208FF for ; Tue, 1 Aug 2017 05:00:20 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 034101300AB6 for ; Tue, 1 Aug 2017 05:00:19 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0ItigJbr; Tue, 01 Aug 2017 05:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:04 +0300 Message-Id: <1501552809-14585-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 1/6] api: packet: add packet memset and memcmp-like functions 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 Currently we have such functions in internal namespace for in-ODP use only. Exporting them as a part of public API would allow using them from tests and user applications. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ include/odp/api/spec/packet.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 95f5349b..d37468ff 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1135,6 +1135,39 @@ int odp_packet_copy_data(odp_packet_t pkt, uint32_t dst_offset, int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, uint32_t src_offset, uint32_t len); +/** + * Set packet data to specific value + * + * Set 'len' bytes of packet data to value 'c' starting from 'offset'. Maximum + * number of bytes to copy is packet data length minus the offset. Packet is + * not modified on an error. + * + * @param pkt Packet handle + * @param offset Byte offset into the packet + * @param c Value to set + * @param len Number of bytes to set + */ +int odp_packet_set_data(odp_packet_t pkt, uint32_t offset, + uint8_t c, uint32_t len); + +/** + * Compare data with packet + * + * Compare 'len' bytes of data from the source address with the packet + * contentes starting from offset. Maximum number of bytes to compare is packet + * data length minus the offset. Packet is not modified on an error. + * + * @param pkt Packet handle + * @param offset Byte offset into the packet + * @param data Data address + * @param len Number of bytes to compare + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_packet_cmp_mem(odp_packet_t pkt, uint32_t offset, + const void *data, uint32_t len); + /* * * Meta-data From patchwork Tue Aug 1 02:00:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109079 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp912968qge; Mon, 31 Jul 2017 19:01:37 -0700 (PDT) X-Received: by 10.200.14.72 with SMTP id j8mr15330091qti.124.1501552897785; Mon, 31 Jul 2017 19:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501552897; cv=none; d=google.com; s=arc-20160816; b=pGnOFwQZLrY0ItEJDoz+eppQLSIkGkaMWKBeLaPFZ/n+thgjurdG5VdXNTXb4FUZGV 18nENaNyg1dC9AH59rm9D2L5bcdIrqbav+r3bGeIHnibLmKN7IHlK4mu9NguChgtD5qa 4j9TT1F1Uwbxi8qIxH/GQ4jWOmbQJxgMENUleFL9ktX2DO5mTwuU6Jymfa5GUT2XedQl 4W6COP8V32WvixWuk7SIwO7/yFBE1Dnoz2riNKtnLhdG7cjuSX7+WCRpfrg3IrOEJXih pyizynu900Ck7pxoKNPrIRNY/Gx9OkXKL1smbOnldEu+loxTP4hyrWbUKRU3tXTktbmh KeTA== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=biu2T0aCbvFxSpx2DsIdz7KszdDAGWMTIak0Yfwn5zw=; b=uzBHJ+P/PFbDe+/PFokGlz3Rk01eqgWlofBqIkSXbev0nkDdCn/2s1Ig1m4mQOeP8Y nKUAzrNrSW7qBS2aSX+zl5h023XHzH0FpeBUWly5W+E5YnNAepRxsIqiFgzQSLrV3HZQ ySLCiERwkv3XRCzpeFxWBN92+W5pPyOtrSsOC/a2dcDpGbVpgh8QUOwpYrV1n1+mxUEL eo08WfPwN1aBEktJpzSJKwgguSSku9gMeZqPEaFhTAD/KUxQciaWSXTNq3tzO736lIak PJAzbfsPGg3AEWf9Rtozfe+00o2haz7/uApe8Fr/jFDq51U//caFlY4tVWc+co7A80Gk 6nTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j31si7394414qtd.438.2017.07.31.19.01.37; Mon, 31 Jul 2017 19:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 7696B65C8D; Tue, 1 Aug 2017 02:01:37 +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,URIBL_BLOCKED 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 AB69265CDE; Tue, 1 Aug 2017 02:00:32 +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 840D165C78; Tue, 1 Aug 2017 02:00:25 +0000 (UTC) Received: from forward4j.cmail.yandex.net (forward4j.cmail.yandex.net [5.255.227.22]) by lists.linaro.org (Postfix) with ESMTPS id E7BFB644D6 for ; Tue, 1 Aug 2017 02:00:22 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::25]) by forward4j.cmail.yandex.net (Yandex) with ESMTP id 64AA820E6C for ; Tue, 1 Aug 2017 05:00:21 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 2BFD81300AB6 for ; Tue, 1 Aug 2017 05:00:20 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0Ktq453H; Tue, 01 Aug 2017 05:00:20 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:05 +0300 Message-Id: <1501552809-14585-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 2/6] linux-gen: packet: provide new data set and compare API 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 Currently we have such functions in internal namespace for in-ODP use only. Exporting them as a part of public API would allow using them from tests and user applications. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ platform/linux-generic/include/odp_packet_internal.h | 6 ------ platform/linux-generic/odp_crypto.c | 4 ++-- platform/linux-generic/odp_packet.c | 8 ++++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index e028bc28..0a4e67f3 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -302,12 +302,6 @@ int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); -int _odp_packet_set_data(odp_packet_t pkt, uint32_t offset, - uint8_t c, uint32_t len); - -int _odp_packet_cmp_data(odp_packet_t pkt, uint32_t offset, - const void *s, uint32_t len); - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 42bd4d58..fa8b0a28 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -213,8 +213,8 @@ odp_crypto_alg_err_t auth_check(odp_packet_t pkt, odp_packet_copy_to_mem(pkt, param->hash_result_offset, bytes, hash_in); - _odp_packet_set_data(pkt, param->hash_result_offset, - 0, bytes); + odp_packet_set_data(pkt, param->hash_result_offset, + 0, bytes); /* Hash it */ packet_hmac(pkt, param, session, hash_out); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 88032cf2..b3f1f6be 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1593,8 +1593,8 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, pkt, src_offset, len); } -int _odp_packet_set_data(odp_packet_t pkt, uint32_t offset, - uint8_t c, uint32_t len) +int odp_packet_set_data(odp_packet_t pkt, uint32_t offset, + uint8_t c, uint32_t len) { void *mapaddr; uint32_t seglen = 0; /* GCC */ @@ -1615,8 +1615,8 @@ int _odp_packet_set_data(odp_packet_t pkt, uint32_t offset, return 0; } -int _odp_packet_cmp_data(odp_packet_t pkt, uint32_t offset, - const void *s, uint32_t len) +int odp_packet_cmp_mem(odp_packet_t pkt, uint32_t offset, + const void *s, uint32_t len) { const uint8_t *ptr = s; void *mapaddr; From patchwork Tue Aug 1 02:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109080 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp913474qge; Mon, 31 Jul 2017 19:02:17 -0700 (PDT) X-Received: by 10.55.148.70 with SMTP id w67mr22116107qkd.160.1501552937567; Mon, 31 Jul 2017 19:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501552937; cv=none; d=google.com; s=arc-20160816; b=VlAO1T5UTjKMUinQPYB7thY+HhIHsR3uFt7x+x6xUH3w+RDtEiCBzmKEj/oH8uMjv4 H5Aflr6Vh/WvmLBH9R/NBRpsr1Bn8oV6PPtDsrnbBcM6109NSghRPnZ0+RI+dahuDYjU j3k143Z8g4IBI9ETsrwA+aLseKAZ5XQU862hs9poxLzcPX9qkoaQXC8lMtDSo2Dd3rOn Nt2/63x+R2Af7HrC2/rbAhYu1Pz94V0X+aBlLTwOf85QNSwIEI8qyEcuKIZ5VmIsbGNQ F9hzs3XrUcP1S+4Ec/w0rWyLO6m8S47bHFjm2KbF0685DDwH142y2PJJqzm0Lg8GsWg9 1iRA== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=61qtyQjDdveVvPMlgsd7HuSIR8qLDkJD0ZDjY7Pf2pM=; b=gYW5ySdApfrWZVUWOc1UGjs90ZzQpv/gSxiA2JqNoG/9Oh8N34IvlC2mrOHlNYzIX5 0uqHqnpQb7WhtG/20YHR+5gOYQ2L9agRh+f0OKQNSNWgnge3E7yGb9pQ4byaXdQNVAi+ FN5EPRNHJ2k055NXtxuMDadGPATIIL2pVH8PE1ECTcBd4pZsIYrko6MRxVp6VgCp0D2T U9UNlHP+sr8JfD0xvWf2LemRmN++JMyOfdMuZxn7Z5x1OyYzzb4S7iNSQbLpJdZbCLvv 72yv8Xq/ibpe7wktzvL55Vz7JzgIZn9u2Bjme3fdr+m3Dln+BUpxxGRZyCB+TkiH9kLC 6ItA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j52si14509228qtc.324.2017.07.31.19.02.17; Mon, 31 Jul 2017 19:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 325A165D0B; Tue, 1 Aug 2017 02:02:17 +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,URIBL_BLOCKED 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 112D065CE1; Tue, 1 Aug 2017 02:00:37 +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 793ED65CD9; Tue, 1 Aug 2017 02:00:26 +0000 (UTC) Received: from forward1o.cmail.yandex.net (forward1o.cmail.yandex.net [37.9.109.84]) by lists.linaro.org (Postfix) with ESMTPS id C2565644D9 for ; Tue, 1 Aug 2017 02:00:23 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward1o.cmail.yandex.net (Yandex) with ESMTP id 602DC2125B for ; Tue, 1 Aug 2017 05:00:22 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 3FCCB1300C13 for ; Tue, 1 Aug 2017 05:00:21 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0LtG8qAI; Tue, 01 Aug 2017 05:00:21 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:06 +0300 Message-Id: <1501552809-14585-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 3/6] validation: packet: add tests for o_p_set_data and o_p_cmp_data 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 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ test/common_plat/validation/api/packet/packet.c | 35 +++++++++++++++++++++++++ test/common_plat/validation/api/packet/packet.h | 1 + 2 files changed, 36 insertions(+) diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index fa6f4afd..27ef701d 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -1311,6 +1311,40 @@ void packet_test_copydata(void) odp_packet_free(pkt); } +void packet_test_setcmpdata(void) +{ + odp_packet_t pkt = test_packet; + uint32_t pkt_len = odp_packet_len(pkt); + uint8_t *data_buf; + uint32_t i; + int correct_memory; + + CU_ASSERT_FATAL(pkt_len > 0); + + data_buf = malloc(pkt_len); + CU_ASSERT_PTR_NOT_NULL_FATAL(data_buf); + + CU_ASSERT(!odp_packet_set_data(pkt, 0, 0xa5, pkt_len)); + memset(data_buf, 0, pkt_len); + CU_ASSERT(!odp_packet_copy_to_mem(pkt, 0, pkt_len, data_buf)); + + correct_memory = 1; + for (i = 0; i < pkt_len; i++) + if (data_buf[i] != 0xa5) { + correct_memory = 0; + break; + } + CU_ASSERT(correct_memory); + + CU_ASSERT(!odp_packet_cmp_mem(pkt, 0, data_buf, pkt_len)); + + data_buf[pkt_len - 1] = 0x5a; + + CU_ASSERT(odp_packet_cmp_mem(pkt, 0, data_buf, pkt_len)); + + free(data_buf); +} + void packet_test_concatsplit(void) { odp_packet_t pkt, pkt2; @@ -2431,6 +2465,7 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_add_rem_data), ODP_TEST_INFO(packet_test_copy), ODP_TEST_INFO(packet_test_copydata), + ODP_TEST_INFO(packet_test_setcmpdata), ODP_TEST_INFO(packet_test_concatsplit), ODP_TEST_INFO(packet_test_concat_small), ODP_TEST_INFO(packet_test_concat_extend_trunc), diff --git a/test/common_plat/validation/api/packet/packet.h b/test/common_plat/validation/api/packet/packet.h index 783b7a11..2080544b 100644 --- a/test/common_plat/validation/api/packet/packet.h +++ b/test/common_plat/validation/api/packet/packet.h @@ -29,6 +29,7 @@ void packet_test_error_flags(void); void packet_test_add_rem_data(void); void packet_test_copy(void); void packet_test_copydata(void); +void packet_test_setcmpdata(void); void packet_test_concatsplit(void); void packet_test_concat_small(void); void packet_test_concat_extend_trunc(void); From patchwork Tue Aug 1 02:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109081 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp914478qge; Mon, 31 Jul 2017 19:03:32 -0700 (PDT) X-Received: by 10.55.164.209 with SMTP id n200mr22269829qke.159.1501553012769; Mon, 31 Jul 2017 19:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501553012; cv=none; d=google.com; s=arc-20160816; b=hblvuiUmpD5AwxS1boNwNLZ6hlq3JNe3/7g138jP8UU6hJjHyxWVhqHZRSadT9QBNV NzB4K4Jy/DN35TpFPz1eKxzPqVv+0e86JbHe22rYlk/I4t6rAR2JV14p0triFvNF3BZv zLuUoNbOgYQOWM+MCBhsCV6/WJ0bOXB3d46rWErnlbKc9GvRz5E0srwmJxUfUHMr1nRU o7pMtundgGWMq1lToK5gxgFBtieiR+9NrDJ1kuIHiSwrLiP5aU/DTAjXT5NK5Ss95+9g X3eTeYODjLVm0jY0GVkx8UDsoDYdcOK+B0sftM6++8XMkGsxQlNroztAW8YHkaJzj4Di 3+6g== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=/LIYZ0D4z6pfe9RpW+StNuOIUFTtl+/bPXFUlyLL6S0=; b=PTj1ruBwVDTdX3wztE5gi+Nr/jGuSaTlPvuvbtEHzzk2Wds08y3PEgzYDTfRZxmZoj P+1wG8yL5/PLE1oFETqoZ8XdI73RcCu3grwVqAWrHvJry0CyT+Y9RrnLxOCqJdpXauO5 Yn+mFHelSL51MQKmsMLJmMbly2QgQb56fGemOg3NDNRwBP6IEMaX/Vg9FCJTe8lKxFQn /f0Gk1QN4JwecLMWLdSRbbtVN1Tv0QUV7xoorygHK6+Kmw38PSE9uJfjLXTElVRu2P0K 4i5wRkiL7F9b+gtfN0GVN+oYYmNgPqwo2LxRNEgqeKxTHZxAiMINi2rGD51Mz0I7thHJ pT1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i44si13572347qte.187.2017.07.31.19.03.32; Mon, 31 Jul 2017 19:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 5C2EC65C3D; Tue, 1 Aug 2017 02:03:32 +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,URIBL_BLOCKED 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 A501365C5C; Tue, 1 Aug 2017 02:01:44 +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 19A9865CFA; Tue, 1 Aug 2017 02:01:19 +0000 (UTC) Received: from forward3o.cmail.yandex.net (forward3o.cmail.yandex.net [37.9.109.247]) by lists.linaro.org (Postfix) with ESMTPS id D0DBC65C5F for ; Tue, 1 Aug 2017 02:00:25 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward3o.cmail.yandex.net (Yandex) with ESMTP id 3970220E8E for ; Tue, 1 Aug 2017 05:00:24 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 184E31300C28 for ; Tue, 1 Aug 2017 05:00:23 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0Mtqe1j8; Tue, 01 Aug 2017 05:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:07 +0300 Message-Id: <1501552809-14585-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 4/6] validation: crypto: rework testsuite 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 Currently crypto testsuite contains tons of similar c&p code setting keys, iv, data, etc. Data is scattered into different arrays. Refactor crypto testsuite so that all data is kept in the structured way, removing most of similar code from individual testing functions. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ .../validation/api/crypto/odp_crypto_test_inp.c | 1072 ++++---------------- .../validation/api/crypto/test_vectors.h | 888 ++++++++-------- .../validation/api/crypto/test_vectors_len.h | 23 +- 3 files changed, 674 insertions(+), 1309 deletions(-) diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index df4ac0c4..2aca9ce2 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -71,7 +71,7 @@ static int alg_op(odp_packet_t pkt, uint32_t aad_len, unsigned int plaintext_len) { - int data_off = 0, rc; + int rc; odp_crypto_op_result_t result; odp_crypto_op_param_t op_params; odp_bool_t posted; @@ -84,19 +84,8 @@ static int alg_op(odp_packet_t pkt, op_params.out_pkt = pkt; op_params.ctx = (void *)0xdeadbeef; - if (cipher_range) { - op_params.cipher_range = *cipher_range; - data_off = cipher_range->offset; - } else { - op_params.cipher_range.offset = data_off; - op_params.cipher_range.length = plaintext_len; - } - if (auth_range) { - op_params.auth_range = *auth_range; - } else { - op_params.auth_range.offset = data_off; - op_params.auth_range.length = plaintext_len; - } + op_params.cipher_range = *cipher_range; + op_params.auth_range = *auth_range; if (op_iv_ptr) op_params.override_iv_ptr = op_iv_ptr; @@ -159,7 +148,7 @@ static int alg_packet_op(odp_packet_t pkt, uint32_t aad_len, unsigned int plaintext_len) { - int data_off = 0, rc; + int rc; odp_crypto_packet_result_t result; odp_crypto_packet_op_param_t op_params; odp_event_subtype_t subtype; @@ -169,19 +158,8 @@ static int alg_packet_op(odp_packet_t pkt, memset(&op_params, 0, sizeof(op_params)); op_params.session = session; - if (cipher_range) { - op_params.cipher_range = *cipher_range; - data_off = cipher_range->offset; - } else { - op_params.cipher_range.offset = data_off; - op_params.cipher_range.length = plaintext_len; - } - if (auth_range) { - op_params.auth_range = *auth_range; - } else { - op_params.auth_range.offset = data_off; - op_params.auth_range.length = plaintext_len; - } + op_params.cipher_range = *cipher_range; + op_params.auth_range = *auth_range; if (op_iv_ptr) op_params.override_iv_ptr = op_iv_ptr; @@ -226,7 +204,7 @@ static int alg_packet_op_enq(odp_packet_t pkt, uint32_t aad_len, unsigned int plaintext_len) { - int data_off = 0, rc; + int rc; odp_event_t event; odp_crypto_packet_result_t result; odp_crypto_packet_op_param_t op_params; @@ -237,19 +215,8 @@ static int alg_packet_op_enq(odp_packet_t pkt, memset(&op_params, 0, sizeof(op_params)); op_params.session = session; - if (cipher_range) { - op_params.cipher_range = *cipher_range; - data_off = cipher_range->offset; - } else { - op_params.cipher_range.offset = data_off; - op_params.cipher_range.length = plaintext_len; - } - if (auth_range) { - op_params.auth_range = *auth_range; - } else { - op_params.auth_range.offset = data_off; - op_params.auth_range.length = plaintext_len; - } + op_params.cipher_range = *cipher_range; + op_params.auth_range = *auth_range; if (op_iv_ptr) op_params.override_iv_ptr = op_iv_ptr; @@ -306,33 +273,34 @@ static int alg_packet_op_enq(odp_packet_t pkt, * buffer can be used. * */ static void alg_test(odp_crypto_op_t op, - odp_bool_t should_fail, odp_cipher_alg_t cipher_alg, - odp_crypto_iv_t ses_iv, - uint8_t *op_iv_ptr, - odp_crypto_key_t cipher_key, odp_auth_alg_t auth_alg, - odp_crypto_key_t auth_key, - odp_packet_data_range_t *cipher_range, - odp_packet_data_range_t *auth_range, - uint8_t *aad, - uint32_t aad_len, - const uint8_t *plaintext, - unsigned int plaintext_len, - const uint8_t *ciphertext, - unsigned int ciphertext_len, - const uint8_t *digest, - uint32_t digest_len) + crypto_test_reference_t *ref, + odp_bool_t ovr_iv) { odp_crypto_session_t session; odp_crypto_capability_t capa; int rc; odp_crypto_ses_create_err_t status; odp_bool_t ok = false; + odp_bool_t should_fail = false; odp_crypto_session_param_t ses_params; - uint8_t *data_addr; odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; + odp_packet_data_range_t cipher_range; + odp_packet_data_range_t auth_range; + odp_crypto_key_t cipher_key = { + .data = ref->cipher_key, + .length = ref->cipher_key_length + }; + odp_crypto_key_t auth_key = { + .data = ref->auth_key, + .length = ref->auth_key_length + }; + odp_crypto_iv_t iv = { + .data = ovr_iv ? NULL : ref->iv, + .length = ref->iv_length + }; int num, i; int found; @@ -394,13 +362,18 @@ static void alg_test(odp_crypto_op_t op, /* Search for the test case */ for (i = 0; i < num; i++) { if (cipher_capa[i].key_len == cipher_key.length && - cipher_capa[i].iv_len == ses_iv.length) { + cipher_capa[i].iv_len == iv.length) { found = 1; break; } } - CU_ASSERT(found); + if (!found) { + printf("\n Unsupported: alg=%s, key_len=%" PRIu32 ", " + "iv_len=%" PRIu32 "\n", cipher_alg_name(cipher_alg), + cipher_key.length, iv.length); + return; + } num = odp_crypto_auth_capability(auth_alg, auth_capa, MAX_ALG_CAPA); @@ -414,14 +387,19 @@ static void alg_test(odp_crypto_op_t op, /* Search for the test case */ for (i = 0; i < num; i++) { - if (auth_capa[i].digest_len == digest_len && + if (auth_capa[i].digest_len == ref->digest_length && auth_capa[i].key_len == auth_key.length) { found = 1; break; } } - CU_ASSERT(found); + if (!found) { + printf("\n Unsupported: alg=%s, key_len=%" PRIu32 ", " + "digest_len=%" PRIu32 "\n", auth_alg_name(auth_alg), + auth_key.length, ref->digest_length); + return; + } /* Create a crypto session */ odp_crypto_session_param_init(&ses_params); @@ -434,9 +412,9 @@ static void alg_test(odp_crypto_op_t op, ses_params.compl_queue = suite_context.queue; ses_params.output_pool = suite_context.pool; ses_params.cipher_key = cipher_key; - ses_params.iv = ses_iv; + ses_params.iv = iv; ses_params.auth_key = auth_key; - ses_params.auth_digest_len = digest_len; + ses_params.auth_digest_len = ref->digest_length; rc = odp_crypto_session_create(&ses_params, &session, &status); CU_ASSERT_FATAL(!rc); @@ -444,29 +422,47 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(odp_crypto_session_to_u64(session) != odp_crypto_session_to_u64(ODP_CRYPTO_SESSION_INVALID)); + cipher_range.offset = 0; + cipher_range.length = ref->length; + auth_range.offset = 0; + auth_range.length = ref->length; + /* Prepare input data */ odp_packet_t pkt = odp_packet_alloc(suite_context.pool, - plaintext_len + digest_len); + ref->length + ref->digest_length); CU_ASSERT(pkt != ODP_PACKET_INVALID); - data_addr = odp_packet_data(pkt); - memcpy(data_addr, plaintext, plaintext_len); - if (0 != digest_len) { - memcpy(data_addr + plaintext_len, - digest, digest_len); +restart: + if (op == ODP_CRYPTO_OP_ENCODE) { + odp_packet_copy_from_mem(pkt, 0, ref->length, ref->plaintext); + } else { + odp_packet_copy_from_mem(pkt, 0, ref->length, ref->ciphertext); + if (should_fail) + odp_packet_set_data(pkt, ref->length, 0x5a, + ref->digest_length); + else + odp_packet_copy_from_mem(pkt, ref->length, + ref->digest_length, + ref->digest); } if (!suite_context.packet) - rc = alg_op(pkt, &ok, session, op_iv_ptr, - cipher_range, auth_range, aad, aad_len, - plaintext_len); + rc = alg_op(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->aad_length, + ref->length); else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) - rc = alg_packet_op_enq(pkt, &ok, session, op_iv_ptr, - cipher_range, auth_range, aad, aad_len, - plaintext_len); + rc = alg_packet_op_enq(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->aad_length, + ref->length); else - rc = alg_packet_op(pkt, &ok, session, op_iv_ptr, - cipher_range, auth_range, aad, aad_len, - plaintext_len); + rc = alg_packet_op(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->aad_length, + ref->length); if (rc < 0) { goto cleanup; } @@ -478,13 +474,23 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(ok); - data_addr = odp_packet_data(pkt); - if (cipher_alg != ODP_CIPHER_ALG_NULL) - CU_ASSERT(!memcmp(data_addr, ciphertext, ciphertext_len)); + if (op == ODP_CRYPTO_OP_ENCODE) { + CU_ASSERT(!odp_packet_cmp_mem(pkt, 0, + ref->ciphertext, + ref->length)); + CU_ASSERT(!odp_packet_cmp_mem(pkt, ref->length, + ref->digest, + ref->digest_length)); + } else { + CU_ASSERT(!odp_packet_cmp_mem(pkt, 0, + ref->plaintext, + ref->length)); + if (ref->digest_length != 0) { + should_fail = true; + goto restart; + } + } - if (op == ODP_CRYPTO_OP_ENCODE && auth_alg != ODP_AUTH_ALG_NULL) - CU_ASSERT(!memcmp(data_addr + plaintext_len, - digest, digest_len)); cleanup: rc = odp_crypto_session_destroy(session); CU_ASSERT(!rc); @@ -569,76 +575,6 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) return ODP_TEST_ACTIVE; } -/** - * Check if given cipher options are supported - * - * @param cipher Cipher algorithm - * @param key_len Key length - * @param iv_len IV length - * - * @retval non-zero if both cipher options are supported - * @retval 0 if both options are not supported - */ -static int check_cipher_options(odp_cipher_alg_t cipher, uint32_t key_len, - uint32_t iv_len) -{ - int i; - int num; - odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; - - num = odp_crypto_cipher_capability(cipher, cipher_capa, MAX_ALG_CAPA); - CU_ASSERT_FATAL(num >= 1); - - for (i = 0; i < num; i++) { - if (key_len == cipher_capa[i].key_len && - iv_len == cipher_capa[i].iv_len) - break; - } - - if (i == num) { - printf("\n Unsupported: alg=%s, key_len=%" PRIu32 ", " - "iv_len=%" PRIu32 "\n", cipher_alg_name(cipher), key_len, - iv_len); - return 0; - } - return 1; -} - -/** - * Check if given authentication options are supported - * - * @param auth Authentication algorithm - * @param key_len Key length - * @param digest_len Digest length - * - * @retval non-zero if both authentication options are supported - * @retval 0 if both options are not supported - */ -static int check_auth_options(odp_auth_alg_t auth, uint32_t key_len, - uint32_t digest_len) -{ - int i; - int num; - odp_crypto_auth_capability_t capa[MAX_ALG_CAPA]; - - num = odp_crypto_auth_capability(auth, capa, MAX_ALG_CAPA); - CU_ASSERT_FATAL(num >= 1); - - for (i = 0; i < num; i++) { - if (key_len == capa[i].key_len && - digest_len == capa[i].digest_len) - break; - } - - if (i == num) { - printf("\n Unsupported: alg=%s, key_len=%" PRIu32 ", " - "digest_len=%" PRIu32 "\n", auth_alg_name(auth), key_len, - digest_len); - return 0; - } - return 1; -} - static int check_alg_null(void) { return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_NULL); @@ -646,64 +582,30 @@ static int check_alg_null(void) void crypto_test_enc_alg_null(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0}; - unsigned int test_vec_num = (sizeof(null_reference_length) / - sizeof(null_reference_length[0])); + unsigned int test_vec_num = (sizeof(null_reference) / + sizeof(null_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - if (!check_cipher_options(ODP_CIPHER_ALG_NULL, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - null_reference_plaintext[i], - null_reference_length[i], - null_reference_plaintext[i], - null_reference_length[i], NULL, 0); - } + &null_reference[i], + false); } void crypto_test_dec_alg_null(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - unsigned int test_vec_num = (sizeof(null_reference_length) / - sizeof(null_reference_length[0])); + unsigned int test_vec_num = (sizeof(null_reference) / + sizeof(null_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - if (!check_cipher_options(ODP_CIPHER_ALG_NULL, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - null_reference_plaintext[i], - null_reference_length[i], - null_reference_plaintext[i], - null_reference_length[i], NULL, 0); - } + &null_reference[i], + false); } static int check_alg_3des_cbc(void) @@ -717,38 +619,16 @@ static int check_alg_3des_cbc(void) * packet buffer as completion event buffer.*/ void crypto_test_enc_alg_3des_cbc(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv; - unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) / - sizeof(tdes_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(tdes_cbc_reference) / + sizeof(tdes_cbc_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = tdes_cbc_reference_key[i]; - cipher_key.length = sizeof(tdes_cbc_reference_key[i]); - iv.data = tdes_cbc_reference_iv[i]; - iv.length = sizeof(tdes_cbc_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_3DES_CBC, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_3DES_CBC, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - tdes_cbc_reference_plaintext[i], - tdes_cbc_reference_length[i], - tdes_cbc_reference_ciphertext[i], - tdes_cbc_reference_length[i], NULL, 0); - } + &tdes_cbc_reference[i], + false); } /* This test verifies the correctness of encode (plaintext -> ciphertext) @@ -756,36 +636,16 @@ void crypto_test_enc_alg_3des_cbc(void) * */ void crypto_test_enc_alg_3des_cbc_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN }; - unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) / - sizeof(tdes_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(tdes_cbc_reference) / + sizeof(tdes_cbc_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = tdes_cbc_reference_key[i]; - cipher_key.length = sizeof(tdes_cbc_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_3DES_CBC, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_3DES_CBC, - iv, - tdes_cbc_reference_iv[i], - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - tdes_cbc_reference_plaintext[i], - tdes_cbc_reference_length[i], - tdes_cbc_reference_ciphertext[i], - tdes_cbc_reference_length[i], NULL, 0); - } + &tdes_cbc_reference[i], + true); } /* This test verifies the correctness of decode (ciphertext -> plaintext) @@ -795,38 +655,16 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void) * */ void crypto_test_dec_alg_3des_cbc(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) / - sizeof(tdes_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(tdes_cbc_reference) / + sizeof(tdes_cbc_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = tdes_cbc_reference_key[i]; - cipher_key.length = sizeof(tdes_cbc_reference_key[i]); - iv.data = tdes_cbc_reference_iv[i]; - iv.length = sizeof(tdes_cbc_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_3DES_CBC, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_3DES_CBC, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - tdes_cbc_reference_ciphertext[i], - tdes_cbc_reference_length[i], - tdes_cbc_reference_plaintext[i], - tdes_cbc_reference_length[i], NULL, 0); - } + &tdes_cbc_reference[i], + false); } /* This test verifies the correctness of decode (ciphertext -> plaintext) @@ -836,36 +674,16 @@ void crypto_test_dec_alg_3des_cbc(void) * */ void crypto_test_dec_alg_3des_cbc_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN }; - unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) / - sizeof(tdes_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(tdes_cbc_reference) / + sizeof(tdes_cbc_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = tdes_cbc_reference_key[i]; - cipher_key.length = sizeof(tdes_cbc_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_3DES_CBC, - cipher_key.length, iv.length)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_3DES_CBC, - iv, - tdes_cbc_reference_iv[i], - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - tdes_cbc_reference_ciphertext[i], - tdes_cbc_reference_length[i], - tdes_cbc_reference_plaintext[i], - tdes_cbc_reference_length[i], NULL, 0); - } + &tdes_cbc_reference[i], + true); } static int check_alg_aes_gcm(void) @@ -879,46 +697,16 @@ static int check_alg_aes_gcm(void) * packet buffer as completion event buffer.*/ void crypto_test_enc_alg_aes128_gcm(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN }; - unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) / - sizeof(aes128_gcm_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / + sizeof(aes128_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_gcm_reference_key[i]; - cipher_key.length = sizeof(aes128_gcm_reference_key[i]); - iv.data = aes128_gcm_reference_iv[i]; - iv.length = sizeof(aes128_gcm_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_GCM, - cipher_key.length, iv.length)) - continue; - if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, - aes128_gcm_reference_tag_length[i])) - continue; - alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_AES_GCM, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i] + - aes128_gcm_reference_length[i], - aes128_gcm_reference_tag_length[i]); + &aes128_gcm_reference[i], + false); } } @@ -928,44 +716,16 @@ void crypto_test_enc_alg_aes128_gcm(void) * packet buffer as completion event buffer.*/ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN }; - unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) / - sizeof(aes128_gcm_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / + sizeof(aes128_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_gcm_reference_key[i]; - cipher_key.length = sizeof(aes128_gcm_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_GCM, - cipher_key.length, iv.length)) - continue; - if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, - aes128_gcm_reference_tag_length[i])) - continue; - alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_AES_GCM, - iv, - aes128_gcm_reference_iv[i], - cipher_key, ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i] + - aes128_gcm_reference_length[i], - aes128_gcm_reference_tag_length[i]); + &aes128_gcm_reference[i], + true); } } @@ -976,68 +736,16 @@ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) * */ void crypto_test_dec_alg_aes128_gcm(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN }; - uint8_t wrong_digest[AES128_GCM_DIGEST_LEN]; - unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) / - sizeof(aes128_gcm_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / + sizeof(aes128_gcm_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_gcm_reference_key[i]; - cipher_key.length = sizeof(aes128_gcm_reference_key[i]); - iv.data = aes128_gcm_reference_iv[i]; - iv.length = sizeof(aes128_gcm_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_GCM, - cipher_key.length, iv.length)) - continue; - if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, - aes128_gcm_reference_tag_length[i])) - continue; - alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_AES_GCM, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i] + - aes128_gcm_reference_length[i], - aes128_gcm_reference_tag_length[i]); - - alg_test(ODP_CRYPTO_OP_DECODE, - 1, - ODP_CIPHER_ALG_AES_GCM, - iv, - NULL, - cipher_key, - ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - wrong_digest, - aes128_gcm_reference_tag_length[i]); + &aes128_gcm_reference[i], + false); } } @@ -1048,66 +756,16 @@ void crypto_test_dec_alg_aes128_gcm(void) * */ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN }; - uint8_t wrong_digest[AES128_GCM_DIGEST_LEN]; - unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) / - sizeof(aes128_gcm_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / + sizeof(aes128_gcm_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_gcm_reference_key[i]; - cipher_key.length = sizeof(aes128_gcm_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_GCM, - cipher_key.length, iv.length)) - continue; - if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, - aes128_gcm_reference_tag_length[i])) - continue; - - alg_test(ODP_CRYPTO_OP_DECODE, - 0, - ODP_CIPHER_ALG_AES_GCM, - iv, - aes128_gcm_reference_iv[i], - cipher_key, - ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_ciphertext[i] + - aes128_gcm_reference_length[i], - aes128_gcm_reference_tag_length[i]); - alg_test(ODP_CRYPTO_OP_DECODE, - 1, ODP_CIPHER_ALG_AES_GCM, - iv, - aes128_gcm_reference_iv[i], - cipher_key, ODP_AUTH_ALG_AES_GCM, - auth_key, - &aes128_gcm_cipher_range[i], - &aes128_gcm_cipher_range[i], - aes128_gcm_reference_aad[i], - aes128_gcm_reference_aad_length[i], - aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i], - aes128_gcm_reference_plaintext[i], - aes128_gcm_reference_length[i], - wrong_digest, - aes128_gcm_reference_tag_length[i]); + &aes128_gcm_reference[i], + true); } } @@ -1122,37 +780,16 @@ static int check_alg_aes_cbc(void) * packet buffer as completion event buffer.*/ void crypto_test_enc_alg_aes128_cbc(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv; - unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) / - sizeof(aes128_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / + sizeof(aes128_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_cbc_reference_key[i]; - cipher_key.length = sizeof(aes128_cbc_reference_key[i]); - iv.data = aes128_cbc_reference_iv[i]; - iv.length = sizeof(aes128_cbc_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_CBC, - cipher_key.length, iv.length)) - continue; - alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_AES_CBC, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - aes128_cbc_reference_plaintext[i], - aes128_cbc_reference_length[i], - aes128_cbc_reference_ciphertext[i], - aes128_cbc_reference_length[i], NULL, 0); + &aes128_cbc_reference[i], + false); } } @@ -1161,35 +798,16 @@ void crypto_test_enc_alg_aes128_cbc(void) * */ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_CBC_IV_LEN }; - unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) / - sizeof(aes128_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / + sizeof(aes128_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_cbc_reference_key[i]; - cipher_key.length = sizeof(aes128_cbc_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_CBC, - cipher_key.length, iv.length)) - continue; - alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_AES_CBC, - iv, - aes128_cbc_reference_iv[i], - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - aes128_cbc_reference_plaintext[i], - aes128_cbc_reference_length[i], - aes128_cbc_reference_ciphertext[i], - aes128_cbc_reference_length[i], NULL, 0); + &aes128_cbc_reference[i], + true); } } @@ -1200,37 +818,16 @@ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void) * */ void crypto_test_dec_alg_aes128_cbc(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) / - sizeof(aes128_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / + sizeof(aes128_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_cbc_reference_key[i]; - cipher_key.length = sizeof(aes128_cbc_reference_key[i]); - iv.data = aes128_cbc_reference_iv[i]; - iv.length = sizeof(aes128_cbc_reference_iv[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_CBC, - cipher_key.length, iv.length)) - continue; - alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_AES_CBC, - iv, - NULL, - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - aes128_cbc_reference_ciphertext[i], - aes128_cbc_reference_length[i], - aes128_cbc_reference_plaintext[i], - aes128_cbc_reference_length[i], NULL, 0); + &aes128_cbc_reference[i], + false); } } @@ -1241,35 +838,16 @@ void crypto_test_dec_alg_aes128_cbc(void) * */ void crypto_test_dec_alg_aes128_cbc_ovr_iv(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = AES128_CBC_IV_LEN }; - unsigned int test_vec_num = (sizeof(aes128_cbc_reference_length) / - sizeof(aes128_cbc_reference_length[0])); + unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / + sizeof(aes128_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { - cipher_key.data = aes128_cbc_reference_key[i]; - cipher_key.length = sizeof(aes128_cbc_reference_key[i]); - - if (!check_cipher_options(ODP_CIPHER_ALG_AES_CBC, - cipher_key.length, iv.length)) - continue; - alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_AES_CBC, - iv, - aes128_cbc_reference_iv[i], - cipher_key, ODP_AUTH_ALG_NULL, - auth_key, - NULL, NULL, - NULL, 0, - aes128_cbc_reference_ciphertext[i], - aes128_cbc_reference_length[i], - aes128_cbc_reference_plaintext[i], - aes128_cbc_reference_length[i], NULL, 0); + &aes128_cbc_reference[i], + true); } } @@ -1287,93 +865,30 @@ static int check_alg_hmac_md5(void) * */ void crypto_test_gen_alg_hmac_md5(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - - unsigned int test_vec_num = (sizeof(hmac_md5_reference_length) / - sizeof(hmac_md5_reference_length[0])); + unsigned int test_vec_num = (sizeof(hmac_md5_reference) / + sizeof(hmac_md5_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_md5_reference_key[i]; - auth_key.length = sizeof(hmac_md5_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length, - hmac_md5_reference_digest_length[i])) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_MD5_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_md5_reference_plaintext[i], - hmac_md5_reference_length[i], - NULL, 0, - hmac_md5_reference_digest[i], - hmac_md5_reference_digest_length[i]); - } + &hmac_md5_reference[i], + false); } void crypto_test_check_alg_hmac_md5(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - uint8_t wrong_digest[HMAC_MD5_DIGEST_LEN]; - - unsigned int test_vec_num = (sizeof(hmac_md5_reference_length) / - sizeof(hmac_md5_reference_length[0])); + unsigned int test_vec_num = (sizeof(hmac_md5_reference) / + sizeof(hmac_md5_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_md5_reference_key[i]; - auth_key.length = sizeof(hmac_md5_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length, - hmac_md5_reference_digest_length[i])) - continue; - - alg_test(ODP_CRYPTO_OP_DECODE, - 0, - ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, - ODP_AUTH_ALG_MD5_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_md5_reference_plaintext[i], - hmac_md5_reference_length[i], - NULL, 0, - hmac_md5_reference_digest[i], - hmac_md5_reference_digest_length[i]); - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 1, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_MD5_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_md5_reference_plaintext[i], - hmac_md5_reference_length[i], - NULL, 0, - wrong_digest, - hmac_md5_reference_digest_length[i]); - } + &hmac_md5_reference[i], + false); } static int check_alg_hmac_sha1(void) @@ -1390,97 +905,30 @@ static int check_alg_hmac_sha1(void) * */ void crypto_test_gen_alg_hmac_sha1(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - - unsigned int test_vec_num = (sizeof(hmac_sha1_reference_length) / - sizeof(hmac_sha1_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha1_reference) / + sizeof(hmac_sha1_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha1_reference_key[i]; - auth_key.length = sizeof(hmac_sha1_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA1_HMAC, - auth_key.length, - HMAC_SHA1_96_CHECK_LEN)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA1_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha1_reference_plaintext[i], - hmac_sha1_reference_length[i], - NULL, 0, - hmac_sha1_reference_digest[i], - HMAC_SHA1_96_CHECK_LEN); - } + &hmac_sha1_reference[i], + false); } void crypto_test_check_alg_hmac_sha1(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - uint8_t wrong_digest[HMAC_SHA1_DIGEST_LEN]; - - unsigned int test_vec_num = (sizeof(hmac_sha1_reference_length) / - sizeof(hmac_sha1_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha1_reference) / + sizeof(hmac_sha1_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha1_reference_key[i]; - auth_key.length = sizeof(hmac_sha1_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA1_HMAC, - auth_key.length, - HMAC_SHA1_96_CHECK_LEN)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA1_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha1_reference_plaintext[i], - hmac_sha1_reference_length[i], - NULL, 0, - hmac_sha1_reference_digest[i], - HMAC_SHA1_96_CHECK_LEN); - - alg_test(ODP_CRYPTO_OP_DECODE, - 1, - ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, - ODP_AUTH_ALG_SHA1_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha1_reference_plaintext[i], - hmac_sha1_reference_length[i], - NULL, 0, - wrong_digest, - HMAC_SHA1_96_CHECK_LEN); - } + &hmac_sha1_reference[i], + false); } static int check_alg_hmac_sha256(void) @@ -1497,97 +945,30 @@ static int check_alg_hmac_sha256(void) * */ void crypto_test_gen_alg_hmac_sha256(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - - unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) / - sizeof(hmac_sha256_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha256_reference) / + sizeof(hmac_sha256_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha256_reference_key[i]; - auth_key.length = sizeof(hmac_sha256_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC, - auth_key.length, - hmac_sha256_reference_digest_length[i])) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA256_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha256_reference_plaintext[i], - hmac_sha256_reference_length[i], - NULL, 0, - hmac_sha256_reference_digest[i], - hmac_sha256_reference_digest_length[i]); - } + &hmac_sha256_reference[i], + false); } void crypto_test_check_alg_hmac_sha256(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - uint8_t wrong_digest[HMAC_SHA256_DIGEST_LEN]; - - unsigned int test_vec_num = (sizeof(hmac_sha256_reference_length) / - sizeof(hmac_sha256_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha256_reference) / + sizeof(hmac_sha256_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha256_reference_key[i]; - auth_key.length = sizeof(hmac_sha256_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC, - auth_key.length, - hmac_sha256_reference_digest_length[i])) - continue; - - alg_test(ODP_CRYPTO_OP_DECODE, - 0, - ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, - ODP_AUTH_ALG_SHA256_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha256_reference_plaintext[i], - hmac_sha256_reference_length[i], - NULL, 0, - hmac_sha256_reference_digest[i], - hmac_sha256_reference_digest_length[i]); - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 1, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA256_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha256_reference_plaintext[i], - hmac_sha256_reference_length[i], - NULL, 0, - wrong_digest, - hmac_sha256_reference_digest_length[i]); - } + &hmac_sha256_reference[i], + false); } static int check_alg_hmac_sha512(void) @@ -1604,97 +985,30 @@ static int check_alg_hmac_sha512(void) * */ void crypto_test_gen_alg_hmac_sha512(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - - unsigned int test_vec_num = (sizeof(hmac_sha512_reference_length) / - sizeof(hmac_sha512_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha512_reference) / + sizeof(hmac_sha512_reference[0])); unsigned int i; - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha512_reference_key[i]; - auth_key.length = sizeof(hmac_sha512_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA512_HMAC, - auth_key.length, - HMAC_SHA512_256_CHECK_LEN)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_ENCODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA512_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha512_reference_plaintext[i], - hmac_sha512_reference_length[i], - NULL, 0, - hmac_sha512_reference_digest[i], - HMAC_SHA512_256_CHECK_LEN); - } + &hmac_sha512_reference[i], + false); } void crypto_test_check_alg_hmac_sha512(void) { - odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, - auth_key = { .data = NULL, .length = 0 }; - odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; - uint8_t wrong_digest[HMAC_SHA512_DIGEST_LEN]; - - unsigned int test_vec_num = (sizeof(hmac_sha512_reference_length) / - sizeof(hmac_sha512_reference_length[0])); - + unsigned int test_vec_num = (sizeof(hmac_sha512_reference) / + sizeof(hmac_sha512_reference[0])); unsigned int i; - memset(wrong_digest, 0xa5, sizeof(wrong_digest)); - - for (i = 0; i < test_vec_num; i++) { - auth_key.data = hmac_sha512_reference_key[i]; - auth_key.length = sizeof(hmac_sha512_reference_key[i]); - - if (!check_auth_options(ODP_AUTH_ALG_SHA512_HMAC, - auth_key.length, - HMAC_SHA512_256_CHECK_LEN)) - continue; - + for (i = 0; i < test_vec_num; i++) alg_test(ODP_CRYPTO_OP_DECODE, - 0, ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, ODP_AUTH_ALG_SHA512_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha512_reference_plaintext[i], - hmac_sha512_reference_length[i], - NULL, 0, - hmac_sha512_reference_digest[i], - HMAC_SHA512_256_CHECK_LEN); - - alg_test(ODP_CRYPTO_OP_DECODE, - 1, - ODP_CIPHER_ALG_NULL, - iv, - iv.data, - cipher_key, - ODP_AUTH_ALG_SHA512_HMAC, - auth_key, - NULL, NULL, - NULL, 0, - hmac_sha512_reference_plaintext[i], - hmac_sha512_reference_length[i], - NULL, 0, - wrong_digest, - HMAC_SHA512_256_CHECK_LEN); - } + &hmac_sha512_reference[i], + false); } int crypto_suite_sync_init(void) diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h index bd8bf347..f9ca9eb5 100644 --- a/test/common_plat/validation/api/crypto/test_vectors.h +++ b/test/common_plat/validation/api/crypto/test_vectors.h @@ -9,442 +9,498 @@ #include "test_vectors_len.h" -/** length in bytes */ -static uint32_t null_reference_length[] = { 8, 16 }; - -static uint8_t -null_reference_plaintext[][NULL_MAX_DATA_LEN] = { - {0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56}, - - {0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, 0x6d, 0x8e, 0xa2, 0x30, - 0x94, 0xea, 0x53, 0x09} +typedef struct crypto_test_reference_s { + uint32_t cipher_key_length; + uint8_t cipher_key[MAX_KEY_LEN]; + uint32_t auth_key_length; + uint8_t auth_key[MAX_KEY_LEN]; + uint32_t iv_length; + uint8_t iv[MAX_IV_LEN]; + uint32_t length; + uint8_t plaintext[MAX_DATA_LEN]; + uint8_t ciphertext[MAX_DATA_LEN]; + uint32_t aad_length; + uint8_t aad[MAX_AAD_LEN]; + uint32_t digest_length; + uint8_t digest[MAX_DIGEST_LEN]; +} crypto_test_reference_t; + +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 uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = { - {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, 0x43, 0xcd, 0x26, 0x5d, - 0x58, 0x40, 0xea, 0xf1, 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c, - }, - - {0x37, 0xae, 0x5e, 0xbf, 0x46, 0xdf, 0xf2, 0xdc, 0x07, 0x54, 0xb9, 0x4f, - 0x31, 0xcb, 0xb3, 0x85, 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae} -}; - -static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] = { - {0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75}, - - {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65} -}; - -/** length in bytes */ -static uint32_t tdes_cbc_reference_length[] = { 8, 16 }; - -static uint8_t -tdes_cbc_reference_plaintext[][TDES_CBC_MAX_DATA_LEN] = { - {0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56}, - - {0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, 0x6d, 0x8e, 0xa2, 0x30, - 0x94, 0xea, 0x53, 0x09} -}; - -static uint8_t -tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = { - {0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92}, - - {0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, 0xbd, 0x04, 0xa7, 0x5f, - 0xfb, 0xa7, 0xd2, 0xf5} -}; - -static uint8_t aes128_cbc_reference_key[][AES128_CBC_KEY_LEN] = { - {0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, - 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 }, - {0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, - 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a }, - {0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, - 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd }, - {0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, - 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49 } +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}, + .iv_length = TDES_CBC_IV_LEN, + .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}, + .iv_length = TDES_CBC_IV_LEN, + .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 } + } }; -static uint8_t aes128_cbc_reference_iv[][AES128_CBC_IV_LEN] = { - { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, - 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, - { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, - 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, - { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb, - 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 }, - { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, - 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 } -}; - -/** length in bytes */ -static uint32_t aes128_cbc_reference_length[] = { 16, 32, 48, 64 }; - -static uint8_t -aes128_cbc_reference_plaintext[][AES128_CBC_MAX_DATA_LEN] = { - "Single block msg", - { 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 }, - "This is a 48-byte message (exactly 3 AES blocks)", - { 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 } -}; - -static uint8_t -aes128_cbc_reference_ciphertext[][AES128_CBC_MAX_DATA_LEN] = { - { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, - 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }, - { 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 }, - { 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 }, - { 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 } +static crypto_test_reference_t aes128_cbc_reference[] = { + { + .cipher_key_length = AES128_CBC_KEY_LEN, + .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, + 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06}, + .iv_length = AES128_CBC_IV_LEN, + .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_CBC_KEY_LEN, + .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, + 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a}, + .iv_length = AES128_CBC_IV_LEN, + .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_CBC_KEY_LEN, + .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, + 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd}, + .iv_length = AES128_CBC_IV_LEN, + .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_CBC_KEY_LEN, + .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, + 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49}, + .iv_length = AES128_CBC_IV_LEN, + .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 } + } }; /* AES-GCM test vectors extracted from * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2 */ -static uint8_t aes128_gcm_reference_key[][AES128_GCM_KEY_LEN] = { - { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, - 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34 }, - { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, - 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f } -}; - -static uint8_t aes128_gcm_reference_iv[][AES128_GCM_IV_LEN] = { - { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e, - 0x3b, 0x24, 0x4c, 0xfe }, - { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, - 0xde, 0xca, 0xf8, 0x88 }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, - { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, - 0xa2, 0xfc, 0xa1, 0xa3 } +static crypto_test_reference_t aes128_gcm_reference[] = { + { + .cipher_key_length = AES128_GCM_KEY_LEN, + .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, + 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, + .iv_length = AES128_GCM_IV_LEN, + .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 = AES128_GCM_DIGEST_LEN, + .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, + 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 } + }, + { + .cipher_key_length = AES128_GCM_KEY_LEN, + .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08}, + .iv_length = AES128_GCM_IV_LEN, + .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 = AES128_GCM_DIGEST_LEN, + .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, + 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a } + }, + { + .cipher_key_length = AES128_GCM_KEY_LEN, + .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .iv_length = AES128_GCM_IV_LEN, + .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 = AES128_GCM_DIGEST_LEN, + .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, + 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d } + }, + { + .cipher_key_length = AES128_GCM_KEY_LEN, + .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, + 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f}, + .iv_length = AES128_GCM_IV_LEN, + .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 = AES128_GCM_DIGEST_LEN, + .digest = { 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe, + 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 } + }, }; -static uint32_t aes128_gcm_reference_length[] = { 72, 64, 64, 28}; - -static uint32_t aes128_gcm_reference_tag_length[] = { 16, 16, 16, 16}; - -static uint32_t aes128_gcm_reference_aad_length[] = { 12, 8, 8, 12}; - -static odp_packet_data_range_t aes128_gcm_cipher_range[] = { - { .offset = 0, .length = 72 }, - { .offset = 0, .length = 64 }, - { .offset = 0, .length = 64 }, - { .offset = 0, .length = 28 }, -}; - -static uint8_t aes128_gcm_reference_aad[][AES128_GCM_MAX_DATA_LEN] = { - { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, - 0x00, 0x00, 0x00, 0x00, }, - { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a, }, - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }, - { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, }, -}; - -static uint8_t -aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { - { 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 }, - - { 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 }, - - { 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 }, - - { 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 } -}; - -static uint8_t -aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = { - { /* Plain */ - 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, - /* Digest */ - 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, - 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 }, - - { /* Plain */ - 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, - /* Digest */ - 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, - 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a }, - - { /* Plain */ - 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, - /* Digest */ - 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, - 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d }, - - { /* Plain */ - 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, - /* Digest */ - 0x36, 0x9f, 0x07, 0x1f, 0x35, 0xe0, 0x34, 0xbe, - 0x95, 0xf1, 0x12, 0xe4, 0xe7, 0xd0, 0x5d, 0x35 } +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_96_CHECK_LEN, + .digest = { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, + 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d }, + + }, + { + .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_96_CHECK_LEN, + .digest = { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, + 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 }, + + }, + { + .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_96_CHECK_LEN, + .digest = { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, + 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } + } }; -static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = { - { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b }, - - /* "Jefe" */ - { 0x4a, 0x65, 0x66, 0x65 }, - - { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa } +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_96_CHECK_LEN, + .digest = { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, + 0x72, 0x64, 0xe2, 0x8b, 0xc0, 0xb6 } + }, + { + .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_96_CHECK_LEN, + .digest = { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, + 0x2f, 0xa2, 0xd2, 0x74, 0x16, 0xd5 } + }, + { + .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_96_CHECK_LEN, + .digest = { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, + 0x11, 0xcd, 0x91, 0xa3, 0x9a, 0xf4 } + } }; -static uint32_t hmac_md5_reference_length[] = { 8, 28, 50 }; - -static uint8_t -hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = { - /* "Hi There" */ - { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - - /* what do ya want for nothing?*/ - { 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 }, - - { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd } +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_128_CHECK_LEN, + .digest = { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, + 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b } + }, + { + .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_128_CHECK_LEN, + .digest = { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, + 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7 } + }, + { + .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_128_CHECK_LEN, + .digest = { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, + 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7 } + } }; -static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = { - { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, - 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d }, - - { 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03, - 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38 }, - - { 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88, - 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } -}; - -static uint32_t hmac_md5_reference_digest_length[] = { - 12, 12, 12 -}; - -static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = { - { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - - /* "Jefe" */ - { 0x4a, 0x65, 0x66, 0x65 }, - - { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa } -}; - -static uint32_t hmac_sha256_reference_length[] = { 8, 28, 50 }; - -static uint8_t -hmac_sha256_reference_plaintext[][HMAC_SHA256_MAX_DATA_LEN] = { - /* "Hi There" */ - { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - - /* what do ya want for nothing?*/ - { 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 }, - - { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd } -}; - -static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = { - { 0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, - 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b }, - - { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, - 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7 }, - - { 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, - 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7 } -}; - -static uint32_t hmac_sha256_reference_digest_length[] = { - 16, 16, 16 -}; - -static uint8_t hmac_sha1_reference_key[][HMAC_SHA1_KEY_LEN] = { - { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - - /* "Jefe" */ - { 0x4a, 0x65, 0x66, 0x65 }, - - { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa } -}; - -static uint32_t hmac_sha1_reference_length[] = { 8, 28, 50 }; - -static uint8_t -hmac_sha1_reference_plaintext[][HMAC_SHA1_MAX_DATA_LEN] = { - /* "Hi There" */ - { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - - /* what do ya want for nothing?*/ - { 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 }, - - { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd } -}; - -static uint8_t hmac_sha1_reference_digest[][HMAC_SHA1_DIGEST_LEN] = { - { 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, - 0x72, 0x64, 0xe2, 0x8b, 0xc0, 0xb6 }, - - { 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, - 0x2f, 0xa2, 0xd2, 0x74, 0x16, 0xd5 }, - - { 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, - 0x11, 0xcd, 0x91, 0xa3, 0x9a, 0xf4 }, -}; - -static uint8_t hmac_sha512_reference_key[][HMAC_SHA512_KEY_LEN] = { - { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, - 0x0b, 0x0b, 0x0b, 0x0b }, - - /* "Jefe" */ - { 0x4a, 0x65, 0x66, 0x65 }, - - { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa } -}; - -static uint32_t hmac_sha512_reference_length[] = { 8, 28, 50 }; - -static uint8_t -hmac_sha512_reference_plaintext[][HMAC_SHA512_MAX_DATA_LEN] = { - /* "Hi There" */ - { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, - - /* what do ya want for nothing?*/ - { 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 }, - - { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, - 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd } -}; - -static uint8_t hmac_sha512_reference_digest[][HMAC_SHA512_DIGEST_LEN] = { - { 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 }, - - { 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 }, - - { 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 } +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_256_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 } + }, + { + .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_256_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 } + }, + { + .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_256_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 } + } }; #endif diff --git a/test/common_plat/validation/api/crypto/test_vectors_len.h b/test/common_plat/validation/api/crypto/test_vectors_len.h index 20a7ddba..427c564b 100644 --- a/test/common_plat/validation/api/crypto/test_vectors_len.h +++ b/test/common_plat/validation/api/crypto/test_vectors_len.h @@ -6,45 +6,40 @@ #ifndef TEST_VECTORS_LEN_ #define TEST_VECTORS_LEN_ -/* NULL */ -#define NULL_MAX_DATA_LEN 16 +/* Maximum */ +#define MAX_KEY_LEN 64 +#define MAX_IV_LEN 16 +#define MAX_DATA_LEN 128 +#define MAX_AAD_LEN 12 +#define MAX_DIGEST_LEN 64 /* TDES-CBC */ #define TDES_CBC_KEY_LEN 24 #define TDES_CBC_IV_LEN 8 -#define TDES_CBC_MAX_DATA_LEN 16 /* AES128-CBC */ #define AES128_CBC_KEY_LEN 16 #define AES128_CBC_IV_LEN 16 -#define AES128_CBC_MAX_DATA_LEN 64 -/* AES128-CBC */ +/* AES128-GCM */ #define AES128_GCM_KEY_LEN 16 #define AES128_GCM_IV_LEN 12 -#define AES128_GCM_MAX_DATA_LEN 106 #define AES128_GCM_DIGEST_LEN 16 /* HMAC-MD5 */ #define HMAC_MD5_KEY_LEN 16 -#define HMAC_MD5_MAX_DATA_LEN 128 -#define HMAC_MD5_DIGEST_LEN 16 +#define HMAC_MD5_96_CHECK_LEN 12 /* HMAC-SHA256 */ #define HMAC_SHA256_KEY_LEN 32 -#define HMAC_SHA256_MAX_DATA_LEN 128 -#define HMAC_SHA256_DIGEST_LEN 32 +#define HMAC_SHA256_128_CHECK_LEN 16 /* HMAC-SHA1 */ #define HMAC_SHA1_KEY_LEN 20 -#define HMAC_SHA1_MAX_DATA_LEN 128 -#define HMAC_SHA1_DIGEST_LEN 20 #define HMAC_SHA1_96_CHECK_LEN 12 /* HMAC-SHA512 */ #define HMAC_SHA512_KEY_LEN 64 -#define HMAC_SHA512_MAX_DATA_LEN 128 -#define HMAC_SHA512_DIGEST_LEN 64 #define HMAC_SHA512_256_CHECK_LEN 32 #endif From patchwork Tue Aug 1 02:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109083 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp919511qge; Mon, 31 Jul 2017 19:09:44 -0700 (PDT) X-Received: by 10.200.11.134 with SMTP id h6mr14903348qti.236.1501553384110; Mon, 31 Jul 2017 19:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501553384; cv=none; d=google.com; s=arc-20160816; b=KJPjGD6xY6aatzwkqx9PwtGK6QAruIrcSGNeYAKjMwSN3CcP0AMOehUkXIfmNPBZtI 8PNNPw41sYKZgOzYaHPCeoTjhUm2dF85puIRNJWxrTxNvjyIGHUQZR1ntwokIS6TQCVH ImuDTt9isADJ0dEJnRBe3LV1VQErRPR5crKbR60lpGCogp33+cHIlbyMQ7LCNKmmdmDg 88RORcbH9iIx9i0DA6aLDPy+GM7G5YBgZih3sybfRKAJOweesrH4JViEuz8RJbS6oFW/ qRHvK3DwfpKj0KVv2xLXalQibDbuLoHkzoUH7nJloaoCVsHKWXYFJ9QNlWccvq6c/FiW hKog== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=UVgbPpp/77l0k92W1pWjdtDuX6EkQgkUwQgYmKOrFPM=; b=H+Hur0qggICMhGWmOrvBt4c5yQYtTIZgrYHh2hh7bdDRVwuiJL+wyB5EPIzn40vcdY LcufkA5PJOD1Y4zaZN1iGbLGH3zzZOGLJPSWqW9FpQbDYqX7McWsRQudo9eYvxtH3osp XgO8XfdwRIfWjENiVotdakcQcJyeeDc6pN1cy+2foUvxFbe9GZMXk4cPLgswMxpCN/zB mI4dcd88ebrwQGXhCleVMoiHSW8IM1csDV8LhxeN/LCBofwGyncAQ4r3Ex18i/pOJW6X m1CeXx4UCV22v5rvTe+fsv/r7GUnRGKYo2WzJnEZdSqdR9qQOixhjgOA3pF2fHTjbbq/ lN0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v4si25125276qtb.16.2017.07.31.19.09.43; Mon, 31 Jul 2017 19:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 BC7F665CE1; Tue, 1 Aug 2017 02:09:43 +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,URIBL_BLOCKED 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 7C1D265D0D; Tue, 1 Aug 2017 02:01:55 +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 DD36C65C3D; Tue, 1 Aug 2017 02:01:30 +0000 (UTC) Received: from forward4p.cmail.yandex.net (forward4p.cmail.yandex.net [77.88.31.19]) by lists.linaro.org (Postfix) with ESMTPS id 01BBF65C8D for ; Tue, 1 Aug 2017 02:00:28 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id 9496020F0A for ; Tue, 1 Aug 2017 05:00:25 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id 390161300C37 for ; Tue, 1 Aug 2017 05:00:24 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0OtGp6Jb; Tue, 01 Aug 2017 05:00:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:08 +0300 Message-Id: <1501552809-14585-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 5/6] validation: crypto: add AES-192/256 test cases 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 Add testcases for AES192-CBC, AES256-CBC, AES128-GCM, AES256-GCM. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ test/common_plat/validation/api/crypto/crypto.h | 16 +-- .../validation/api/crypto/odp_crypto_test_inp.c | 80 ++++++------- .../validation/api/crypto/test_vectors.h | 124 ++++++++++++++++++--- .../validation/api/crypto/test_vectors_len.h | 22 +++- 4 files changed, 177 insertions(+), 65 deletions(-) diff --git a/test/common_plat/validation/api/crypto/crypto.h b/test/common_plat/validation/api/crypto/crypto.h index dd15b448..71f862ec 100644 --- a/test/common_plat/validation/api/crypto/crypto.h +++ b/test/common_plat/validation/api/crypto/crypto.h @@ -16,14 +16,14 @@ void crypto_test_enc_alg_3des_cbc(void); void crypto_test_enc_alg_3des_cbc_ovr_iv(void); void crypto_test_dec_alg_3des_cbc(void); void crypto_test_dec_alg_3des_cbc_ovr_iv(void); -void crypto_test_enc_alg_aes128_cbc(void); -void crypto_test_enc_alg_aes128_cbc_ovr_iv(void); -void crypto_test_dec_alg_aes128_cbc(void); -void crypto_test_dec_alg_aes128_cbc_ovr_iv(void); -void crypto_test_enc_alg_aes128_gcm(void); -void crypto_test_enc_alg_aes128_gcm_ovr_iv(void); -void crypto_test_dec_alg_aes128_gcm(void); -void crypto_test_dec_alg_aes128_gcm_ovr_iv(void); +void crypto_test_enc_alg_aes_cbc(void); +void crypto_test_enc_alg_aes_cbc_ovr_iv(void); +void crypto_test_dec_alg_aes_cbc(void); +void crypto_test_dec_alg_aes_cbc_ovr_iv(void); +void crypto_test_enc_alg_aes_gcm(void); +void crypto_test_enc_alg_aes_gcm_ovr_iv(void); +void crypto_test_dec_alg_aes_gcm(void); +void crypto_test_dec_alg_aes_gcm_ovr_iv(void); void crypto_test_gen_alg_hmac_md5(void); void crypto_test_check_alg_hmac_md5(void); void crypto_test_gen_alg_hmac_sha1(void); diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index 2aca9ce2..d5c9f0b6 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -695,17 +695,17 @@ static int check_alg_aes_gcm(void) * operation for AES128_GCM algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes128_gcm(void) +void crypto_test_enc_alg_aes_gcm(void) { - unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / - sizeof(aes128_gcm_reference[0])); + unsigned int test_vec_num = (sizeof(aes_gcm_reference) / + sizeof(aes_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_GCM, ODP_AUTH_ALG_AES_GCM, - &aes128_gcm_reference[i], + &aes_gcm_reference[i], false); } } @@ -714,17 +714,17 @@ void crypto_test_enc_alg_aes128_gcm(void) * operation for AES128_GCM algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) +void crypto_test_enc_alg_aes_gcm_ovr_iv(void) { - unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / - sizeof(aes128_gcm_reference[0])); + unsigned int test_vec_num = (sizeof(aes_gcm_reference) / + sizeof(aes_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_GCM, ODP_AUTH_ALG_AES_GCM, - &aes128_gcm_reference[i], + &aes_gcm_reference[i], true); } } @@ -734,17 +734,17 @@ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes128_gcm(void) +void crypto_test_dec_alg_aes_gcm(void) { - unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / - sizeof(aes128_gcm_reference[0])); + unsigned int test_vec_num = (sizeof(aes_gcm_reference) / + sizeof(aes_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_GCM, ODP_AUTH_ALG_AES_GCM, - &aes128_gcm_reference[i], + &aes_gcm_reference[i], false); } } @@ -754,17 +754,17 @@ void crypto_test_dec_alg_aes128_gcm(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) +void crypto_test_dec_alg_aes_gcm_ovr_iv(void) { - unsigned int test_vec_num = (sizeof(aes128_gcm_reference) / - sizeof(aes128_gcm_reference[0])); + unsigned int test_vec_num = (sizeof(aes_gcm_reference) / + sizeof(aes_gcm_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_GCM, ODP_AUTH_ALG_AES_GCM, - &aes128_gcm_reference[i], + &aes_gcm_reference[i], true); } } @@ -778,17 +778,17 @@ static int check_alg_aes_cbc(void) * operation for AES128_CBC algorithm. IV for the operation is the session IV. * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer.*/ -void crypto_test_enc_alg_aes128_cbc(void) +void crypto_test_enc_alg_aes_cbc(void) { - unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / - sizeof(aes128_cbc_reference[0])); + unsigned int test_vec_num = (sizeof(aes_cbc_reference) / + sizeof(aes_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CBC, ODP_AUTH_ALG_NULL, - &aes128_cbc_reference[i], + &aes_cbc_reference[i], false); } } @@ -796,17 +796,17 @@ void crypto_test_enc_alg_aes128_cbc(void) /* This test verifies the correctness of encode (plaintext -> ciphertext) * operation for AES128_CBC algorithm. IV for the operation is the operation IV. * */ -void crypto_test_enc_alg_aes128_cbc_ovr_iv(void) +void crypto_test_enc_alg_aes_cbc_ovr_iv(void) { - unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / - sizeof(aes128_cbc_reference[0])); + unsigned int test_vec_num = (sizeof(aes_cbc_reference) / + sizeof(aes_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_ENCODE, ODP_CIPHER_ALG_AES_CBC, ODP_AUTH_ALG_NULL, - &aes128_cbc_reference[i], + &aes_cbc_reference[i], true); } } @@ -816,17 +816,17 @@ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes128_cbc(void) +void crypto_test_dec_alg_aes_cbc(void) { - unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / - sizeof(aes128_cbc_reference[0])); + unsigned int test_vec_num = (sizeof(aes_cbc_reference) / + sizeof(aes_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CBC, ODP_AUTH_ALG_NULL, - &aes128_cbc_reference[i], + &aes_cbc_reference[i], false); } } @@ -836,17 +836,17 @@ void crypto_test_dec_alg_aes128_cbc(void) * In addition the test verifies if the implementation can use the * packet buffer as completion event buffer. * */ -void crypto_test_dec_alg_aes128_cbc_ovr_iv(void) +void crypto_test_dec_alg_aes_cbc_ovr_iv(void) { - unsigned int test_vec_num = (sizeof(aes128_cbc_reference) / - sizeof(aes128_cbc_reference[0])); + unsigned int test_vec_num = (sizeof(aes_cbc_reference) / + sizeof(aes_cbc_reference[0])); unsigned int i; for (i = 0; i < test_vec_num; i++) { alg_test(ODP_CRYPTO_OP_DECODE, ODP_CIPHER_ALG_AES_CBC, ODP_AUTH_ALG_NULL, - &aes128_cbc_reference[i], + &aes_cbc_reference[i], true); } } @@ -1076,21 +1076,21 @@ odp_testinfo_t crypto_suite[] = { check_alg_3des_cbc), ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_cbc_ovr_iv, check_alg_3des_cbc), - ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes128_cbc, + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_cbc, check_alg_aes_cbc), - ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes128_cbc, + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cbc, check_alg_aes_cbc), - ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes128_cbc_ovr_iv, + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_cbc_ovr_iv, check_alg_aes_cbc), - ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes128_cbc_ovr_iv, + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_cbc_ovr_iv, check_alg_aes_cbc), - ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes128_gcm, + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm, check_alg_aes_gcm), - ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes128_gcm_ovr_iv, + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_aes_gcm_ovr_iv, check_alg_aes_gcm), - ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes128_gcm, + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_gcm, check_alg_aes_gcm), - ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes128_gcm_ovr_iv, + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_aes_gcm_ovr_iv, check_alg_aes_gcm), ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_hmac_md5, check_alg_hmac_md5), diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h index f9ca9eb5..652968be 100644 --- a/test/common_plat/validation/api/crypto/test_vectors.h +++ b/test/common_plat/validation/api/crypto/test_vectors.h @@ -70,12 +70,12 @@ static crypto_test_reference_t tdes_cbc_reference[] = { } }; -static crypto_test_reference_t aes128_cbc_reference[] = { +static crypto_test_reference_t aes_cbc_reference[] = { { .cipher_key_length = AES128_CBC_KEY_LEN, .cipher_key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06}, - .iv_length = AES128_CBC_IV_LEN, + .iv_length = AES_CBC_IV_LEN, .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, .length = 16, @@ -87,7 +87,7 @@ static crypto_test_reference_t aes128_cbc_reference[] = { .cipher_key_length = AES128_CBC_KEY_LEN, .cipher_key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a}, - .iv_length = AES128_CBC_IV_LEN, + .iv_length = AES_CBC_IV_LEN, .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, .length = 32, @@ -104,7 +104,7 @@ static crypto_test_reference_t aes128_cbc_reference[] = { .cipher_key_length = AES128_CBC_KEY_LEN, .cipher_key = { 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd}, - .iv_length = AES128_CBC_IV_LEN, + .iv_length = AES_CBC_IV_LEN, .iv = { 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb, 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81 }, .length = 48, @@ -120,7 +120,7 @@ static crypto_test_reference_t aes128_cbc_reference[] = { .cipher_key_length = AES128_CBC_KEY_LEN, .cipher_key = { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49}, - .iv_length = AES128_CBC_IV_LEN, + .iv_length = AES_CBC_IV_LEN, .iv = { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 }, .length = 64, @@ -140,18 +140,59 @@ static crypto_test_reference_t aes128_cbc_reference[] = { 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_CBC_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}, + .iv_length = AES_CBC_IV_LEN, + .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}, + }, + { + .cipher_key_length = AES256_CBC_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}, + .iv_length = AES_CBC_IV_LEN, + .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}, } }; /* AES-GCM test vectors extracted from * https://tools.ietf.org/html/draft-mcgrew-gcm-test-01#section-2 */ -static crypto_test_reference_t aes128_gcm_reference[] = { +static crypto_test_reference_t aes_gcm_reference[] = { { .cipher_key_length = AES128_GCM_KEY_LEN, .cipher_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, - .iv_length = AES128_GCM_IV_LEN, + .iv_length = AES_GCM_IV_LEN, .iv = { 0x2e, 0x44, 0x3b, 0x68, 0x49, 0x56, 0xed, 0x7e, 0x3b, 0x24, 0x4c, 0xfe }, .length = 72, @@ -176,7 +217,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { .aad_length = 12, .aad = { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, 0x00, 0x00, 0x00, 0x00 }, - .digest_length = AES128_GCM_DIGEST_LEN, + .digest_length = AES_GCM_DIGEST_LEN, .digest = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 } }, @@ -184,7 +225,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { .cipher_key_length = AES128_GCM_KEY_LEN, .cipher_key = { 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08}, - .iv_length = AES128_GCM_IV_LEN, + .iv_length = AES_GCM_IV_LEN, .iv = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88 }, .length = 64, @@ -206,7 +247,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { 0xec, 0x3b, 0x9b, 0xa9, 0x5d, 0x91, 0x8b, 0xd1}, .aad_length = 8, .aad = { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a }, - .digest_length = AES128_GCM_DIGEST_LEN, + .digest_length = AES_GCM_DIGEST_LEN, .digest = { 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a } }, @@ -214,7 +255,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { .cipher_key_length = AES128_GCM_KEY_LEN, .cipher_key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - .iv_length = AES128_GCM_IV_LEN, + .iv_length = AES_GCM_IV_LEN, .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, .length = 64, @@ -236,7 +277,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { 0x1d, 0x19, 0xd4, 0xd5, 0xc8, 0xc1, 0x8a, 0xf3}, .aad_length = 8, .aad = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }, - .digest_length = AES128_GCM_DIGEST_LEN, + .digest_length = AES_GCM_DIGEST_LEN, .digest = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d } }, @@ -244,7 +285,7 @@ static crypto_test_reference_t aes128_gcm_reference[] = { .cipher_key_length = AES128_GCM_KEY_LEN, .cipher_key = { 0x3d, 0xe0, 0x98, 0x74, 0xb3, 0x88, 0xe6, 0x49, 0x19, 0x88, 0xd0, 0xc3, 0x60, 0x7e, 0xae, 0x1f}, - .iv_length = AES128_GCM_IV_LEN, + .iv_length = AES_GCM_IV_LEN, .iv = { 0x57, 0x69, 0x0e, 0x43, 0x4e, 0x28, 0x00, 0x00, 0xa2, 0xfc, 0xa1, 0xa3 }, .length = 28, @@ -259,10 +300,65 @@ static crypto_test_reference_t aes128_gcm_reference[] = { .aad_length = 12, .aad = { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 }, - .digest_length = AES128_GCM_DIGEST_LEN, + .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_GCM_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}, + .iv_length = AES_GCM_IV_LEN, + .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_GCM_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}, + .iv_length = AES_GCM_IV_LEN, + .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 hmac_md5_reference[] = { diff --git a/test/common_plat/validation/api/crypto/test_vectors_len.h b/test/common_plat/validation/api/crypto/test_vectors_len.h index 427c564b..b1ce719e 100644 --- a/test/common_plat/validation/api/crypto/test_vectors_len.h +++ b/test/common_plat/validation/api/crypto/test_vectors_len.h @@ -17,14 +17,30 @@ #define TDES_CBC_KEY_LEN 24 #define TDES_CBC_IV_LEN 8 +/* AES-CBC common */ +#define AES_CBC_IV_LEN 16 + /* AES128-CBC */ #define AES128_CBC_KEY_LEN 16 -#define AES128_CBC_IV_LEN 16 + +/* AES192-CBC */ +#define AES192_CBC_KEY_LEN 24 + +/* AES256-CBC */ +#define AES256_CBC_KEY_LEN 32 + +/* AES-GCM common */ +#define AES_GCM_IV_LEN 12 +#define AES_GCM_DIGEST_LEN 16 /* AES128-GCM */ #define AES128_GCM_KEY_LEN 16 -#define AES128_GCM_IV_LEN 12 -#define AES128_GCM_DIGEST_LEN 16 + +/* AES192-GCM */ +#define AES192_GCM_KEY_LEN 24 + +/* AES256-GCM */ +#define AES256_GCM_KEY_LEN 32 /* HMAC-MD5 */ #define HMAC_MD5_KEY_LEN 16 From patchwork Tue Aug 1 02:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 109082 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp918715qge; Mon, 31 Jul 2017 19:08:39 -0700 (PDT) X-Received: by 10.233.221.131 with SMTP id r125mr24277723qkf.267.1501553319659; Mon, 31 Jul 2017 19:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501553319; cv=none; d=google.com; s=arc-20160816; b=yiW8fWDR3JxxBTcVJRdQ8py0k4wro5+qie8/xP4u6U5+Q1tUcUbuaULPV+mn99lUTr jnXfDfIO8jQP5sUc8radpGs69CMUHhn36Szdl3jfNOegHYFQyRI4TYHojrqKtaii46gw 4iuvcQ7W85vzjKBi9uw82TX1UmyI7bSnX4ltCOsuNrAg4O6DwmAhkvWXB1DJPF3extVs 0w9gvHHMPFEq7pVWx5lmdV/D/AduKx6dW2Osz25k/YKDHFvNsbjlJuutdMAD79yRXggJ icCRdpbgKU1iVHph2ii61rt4uYDQDsC6yKDl+D+CfwKev+d4aZuXZ9foC3AoryXdrjZw BeJQ== 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:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=8YrsaSHwIZz/x3EfvKLqERrql9losUM40YNxXhE5jco=; b=R6PdvqwN/6067w4NaiqxFDzncts7mYNjhyQ4l9YQ/xm+7rHLFmE5F7HFni01lTWLDy 7R7cvp6Jr3N80hvtPJroqOKHvVtna/6kdM4OGyxqN+ihdTCMi3ww7SQGHsfnZIVT+Uyw qxSnsfhKzT6TB+ZcWVKRVFg1RUsMVLwssZCLHXKObWekayZY/42ApNWAmT4aNoxVnw19 hQIWURgf6rYRvVBJ0mstIXVCfUwzpDH+ioB/vjg+EIaLE0LU3bP/JX4JuC/tAwVxxge1 tJ3FcEfZvsGD2VfrF60aIeMY3QfXEDLy8NjUb24HqjYLW2xHUtJO+qtvqX9f/W0zZYrp GzJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g6si12816400qkc.261.2017.07.31.19.08.39; Mon, 31 Jul 2017 19:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 5157365C7C; Tue, 1 Aug 2017 02:08:39 +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,URIBL_BLOCKED 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 0C63665CFA; Tue, 1 Aug 2017 02:01:48 +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 70DF865D07; Tue, 1 Aug 2017 02:01:28 +0000 (UTC) Received: from forward3p.cmail.yandex.net (forward3p.cmail.yandex.net [77.88.31.18]) by lists.linaro.org (Postfix) with ESMTPS id 5707B65C3D for ; Tue, 1 Aug 2017 02:00:29 +0000 (UTC) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [37.140.190.26]) by forward3p.cmail.yandex.net (Yandex) with ESMTP id 1967020C94 for ; Tue, 1 Aug 2017 05:00:27 +0300 (MSK) Received: from smtp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp1o.mail.yandex.net (Yandex) with ESMTP id E797F1300C28 for ; Tue, 1 Aug 2017 05:00:26 +0300 (MSK) Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id cw80aqSarU-0PtS9Cif; Tue, 01 Aug 2017 05:00:25 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 1 Aug 2017 05:00:09 +0300 Message-Id: <1501552809-14585-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> References: <1501552809-14585-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 94 Subject: [lng-odp] [PATCH API-NEXT v3 6/6] linux-gen: crypto: add support for AES-192 and AES-256 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 Add support for AES with keys of 192 and 256 bits. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 94 (lumag:crypto-long-keys) ** https://github.com/Linaro/odp/pull/94 ** Patch: https://github.com/Linaro/odp/pull/94.patch ** Base sha: c16f1363303cd5fc11324acbc4dfebe0a9680a41 ** Merge commit sha: 97de0c6543391f0a758ac472f48e0b407ad1d800 **/ platform/linux-generic/odp_crypto.c | 44 ++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index fa8b0a28..a72ebb25 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -44,10 +44,14 @@ static const odp_crypto_cipher_capability_t cipher_capa_trides_cbc[] = { {.key_len = 24, .iv_len = 8} }; static const odp_crypto_cipher_capability_t cipher_capa_aes_cbc[] = { -{.key_len = 16, .iv_len = 16} }; +{.key_len = 16, .iv_len = 16}, +{.key_len = 24, .iv_len = 16}, +{.key_len = 32, .iv_len = 16} }; static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = { -{.key_len = 16, .iv_len = 12} }; +{.key_len = 16, .iv_len = 12}, +{.key_len = 24, .iv_len = 12}, +{.key_len = 32, .iv_len = 12} }; /* * Authentication algorithm capabilities @@ -737,23 +741,47 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, case ODP_CIPHER_ALG_3DES_CBC: rc = process_cipher_param(session, EVP_des_ede3_cbc()); break; - case ODP_CIPHER_ALG_AES_CBC: #if ODP_DEPRECATED_API case ODP_CIPHER_ALG_AES128_CBC: + if (param->cipher_key.length == 16) + rc = process_cipher_param(session, EVP_aes_128_cbc()); + else + rc = -1; + break; #endif - rc = process_cipher_param(session, EVP_aes_128_cbc()); + case ODP_CIPHER_ALG_AES_CBC: + if (param->cipher_key.length == 16) + rc = process_cipher_param(session, EVP_aes_128_cbc()); + else if (param->cipher_key.length == 24) + rc = process_cipher_param(session, EVP_aes_192_cbc()); + else if (param->cipher_key.length == 32) + rc = process_cipher_param(session, EVP_aes_256_cbc()); + else + rc = -1; break; #if ODP_DEPRECATED_API case ODP_CIPHER_ALG_AES128_GCM: - if (param->auth_alg == ODP_AUTH_ALG_AES128_GCM) - aes_gcm = 1; - /* Fallthrough */ + /* AES-GCM requires to do both auth and + * cipher at the same time */ + if (param->auth_alg != ODP_AUTH_ALG_AES128_GCM) + rc = -1; + else if (param->cipher_key.length == 16) + rc = process_aes_gcm_param(session, EVP_aes_128_gcm()); + else + rc = -1; + break; #endif case ODP_CIPHER_ALG_AES_GCM: /* AES-GCM requires to do both auth and * cipher at the same time */ - if (param->auth_alg == ODP_AUTH_ALG_AES_GCM || aes_gcm) + if (param->auth_alg != ODP_AUTH_ALG_AES_GCM) + rc = -1; + else if (param->cipher_key.length == 16) rc = process_aes_gcm_param(session, EVP_aes_128_gcm()); + else if (param->cipher_key.length == 24) + rc = process_aes_gcm_param(session, EVP_aes_192_gcm()); + else if (param->cipher_key.length == 32) + rc = process_aes_gcm_param(session, EVP_aes_256_gcm()); else rc = -1; break;