From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAFB7C4338F for ; Thu, 29 Jul 2021 16:48:26 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3863760F43 for ; Thu, 29 Jul 2021 16:48:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3863760F43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0676483124; Thu, 29 Jul 2021 18:47:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="t7Cr0nkn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7960082F24; Thu, 29 Jul 2021 18:47:36 +0200 (CEST) Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8094A82F32 for ; Thu, 29 Jul 2021 18:47:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-oi1-x235.google.com with SMTP id o20so9180034oiw.12 for ; Thu, 29 Jul 2021 09:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O+PLtjcTTLdrpqZ9FhW/aCVepmNE7MBh0DuxEeLxEC0=; b=t7Cr0nkn+dmfgGRmr5c+6qga6keiGGyypcOanfBit0loxpGOuadZV3Wf4UvwSd+y7r MHwZLYF/ihxv4suCzRLCKN2P0RUzPpg1rroaI8YFrhDRb7d0OciPuaVgT3cLI7bsTNs/ t77Es74yJgzRqpxGPP+m8HFoJ59AGqOWr+6crg2hx5sBXco/vJcWODYwXLixdCw7EhtL KBFYAvPSRIP1YMafnuNJQVPV53rG8AQq78dWNGiep6RajePP0DQ3Y8LDi+etMXkJH63A iS9nZdZ5TnOynm6CBIwnUTjvhgD/TgjXY3hOjS26ciOCrwmwvjKy4svf5+zjmgSbhgDN hM7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O+PLtjcTTLdrpqZ9FhW/aCVepmNE7MBh0DuxEeLxEC0=; b=cwwtlq81wrOXPKdiNhxyrPJOV+VM8wdnRLsTZ8sdhzQtfqAQR4aNslquu7XsDLGxuv g6k5f0F0zapcxylZeKV4rpjAuBV6TTNDcV1lTNcws08MDxGBy3Sc80NYUQ6kEye7bGz4 1VILmyvBsvqAcw3pH9I2wIXGi8Le/wfwFJUfflFUnRa1bWJGOO4RMLzP0LKXHDSrluoT AA4NttJp0PqnWwVim2+NQdh7wzyZtCD2w8jO2N7dxg5DSGuytm3Lxkn+8vQLpmqS5a1z 50QP9absYSbYXVSNGHlWkEQGeQkcPT773PFibETlgEETGXhF+nf4D/eXQFJonJGfKhYb lTPw== X-Gm-Message-State: AOAM532lRLnZ3O+hGlzyp1NjvJW6RJCZes4MTqSSIl5xEt+89TvdYtqD xG+ZPSomwzHg+8wdZAxKWqlUgL0pTXg= X-Google-Smtp-Source: ABdhPJzv7nsqbYqM/DJ79CG8HJIJXj8aDJpOc6cYBa+AFBUbZPGCFbXe9+sU2ZzqtFKgDi7BOt0l2Q== X-Received: by 2002:a05:6808:14c2:: with SMTP id f2mr10597263oiw.100.1627577248817; Thu, 29 Jul 2021 09:47:28 -0700 (PDT) Received: from nuclearis3.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id i12sm623273otr.56.2021.07.29.09.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 09:47:28 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, patrick.delaunay@foss.st.com Cc: Alexandru Gagniuc , sjg@chromium.org, etienne.carriere@linaro.org, patrice.chotard@foss.st.com Subject: [PATCH 5/5] test: dm: Add test for ECDSA UCLASS support Date: Thu, 29 Jul 2021 11:47:19 -0500 Message-Id: <20210729164719.3490718-6-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210729164719.3490718-1-mr.nuke.me@gmail.com> References: <20210729164719.3490718-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This test verifies that ECDSA_UCLASS is implemented, and that ecdsa_verify() works as expected. The definition of "expected" is "does not find a device, and returns -ENODEV". The lack of a hardware-independent ECDSA implementation prevents us from having one in the sandbox, for now. Signed-off-by: Alexandru Gagniuc Reviewed-by: Simon Glass --- configs/sandbox_defconfig | 2 ++ test/dm/Makefile | 1 + test/dm/ecdsa.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 test/dm/ecdsa.c diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index bcd82f76ff..8bb981d6f5 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -299,3 +299,5 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_ECDSA=y +CONFIG_ECDSA_VERIFY=y diff --git a/test/dm/Makefile b/test/dm/Makefile index d5c42e7643..516f69d61c 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_DMA) += dma.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o obj-$(CONFIG_DM_DSA) += dsa.o +obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o obj-$(CONFIG_DM_ETH) += eth.o ifneq ($(CONFIG_EFI_PARTITION),) obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o diff --git a/test/dm/ecdsa.c b/test/dm/ecdsa.c new file mode 100644 index 0000000000..da535c98b5 --- /dev/null +++ b/test/dm/ecdsa.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include + +/* + * Basic test of the ECDSA uclass and ecdsa_verify() + * + * ECDSA implementations in u-boot are hardware-dependent. Until we have a + * software implementation that can be compiled into the sandbox, all we can + * test is the uclass support. + * + * The uclass_get() test is redundant since ecdsa_verify() would also fail. We + * run both functions in order to isolate the cause more clearly. i.e. is + * ecdsa_verify() failing because the UCLASS is absent/broken? + */ +static int dm_test_ecdsa_verify(struct unit_test_state *uts) +{ + struct uclass *ucp; + + struct checksum_algo algo = { + .checksum_len = 256, + }; + + struct image_sign_info info = { + .checksum = &algo, + }; + + ut_assertok(uclass_get(UCLASS_ECDSA, &ucp)); + ut_assertnonnull(ucp); + ut_asserteq(-ENODEV, ecdsa_verify(&info, NULL, 0, NULL, 0)); + + return 0; +} +DM_TEST(dm_test_ecdsa_verify, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -- 2.31.1