From patchwork Wed Feb 1 13:26:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akuster808 X-Patchwork-Id: 18866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54AB3C636D3 for ; Wed, 1 Feb 2023 13:26:22 +0000 (UTC) Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by mx.groups.io with SMTP id smtpd.web10.22720.1675257976834421883 for ; Wed, 01 Feb 2023 05:26:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B4XxG579; spf=pass (domain: gmail.com, ip: 209.85.160.51, mailfrom: akuster808@gmail.com) Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-1636eae256cso19187346fac.0 for ; Wed, 01 Feb 2023 05:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=AajxYQ0aebsiRUXl8PLvxG/lXTrhiJyrndFKKHDygb4=; b=B4XxG579vAdbL7JppchdSC5GP7aPunJX4enbJTF/H1/sznga8v2+DG8OpbHtWnIpvU cwK/I76WAQXFSQBAFDPi2AhqSZdlP2PJzpSpeGaeq0IKXHwCte5FVGi9CZoM9Jbu+LuT m2Lp3uD/6KoukGUNds9W3PXOFtGeTqekaF7w8NgcF5QxU601p0fxebOqa4NpxToJ2bCB HDHhV/izivbCW7wUdzwpBSbBdReJi+TzV8gX03hrhVyki2vbK8Y6Ze2QHTUWqnCUQoFi EC9C4yfMhN45kQ1wntGBYMz8F07l4zxGY2qbJDXltB1wXEPfN4N2eNWNW1cmKI0nkAJ5 RZFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AajxYQ0aebsiRUXl8PLvxG/lXTrhiJyrndFKKHDygb4=; b=74tuhe419wIpntXuhKBV+AeJ1YH/t0hFGVf7NZAy+eJlmtbWLo38TMfpdPQ9KuDj0k FSb3V2TRjaiadJ4KWaQY2IPx7BXL2RJaz/DWO3Vttm43A0NwYDLCVgdQz5KPpm1t1rHN bLk6nZNXvPFyjlal9kzPvY/ztR6QV2IrdMQ88e4YeGSamk2IUSBPrzd5eQRUBQlvkRPF CjBgtlIJsIjpyErljlf4mv6w+sombkgQlFdJZN2WqMLQBUAc3WWBjR+sVr17kfJkigfI nJZX47GzsoDnEH2bjUJOrn/qirfPs49h3Mjc1PUoY7MpboHJehUlKcnhElZITNQlluVA S7TA== X-Gm-Message-State: AO0yUKVE+e9YpLTpYLAOFX0QqM365EIHk4pk9+xwEF+jC+lIF7nnPOZE IxYXRgMdKlz8PKFLmQEAlca4bmh/9Y4= X-Google-Smtp-Source: AK7set8meeTlXZEm+Jsr9PxHiqQ62bUw1cXEN++f9fVUpRZ821m4u+lblAxwgLSqbQs/pRZNYwAsKg== X-Received: by 2002:a05:6871:58e:b0:163:1c97:9a3b with SMTP id u14-20020a056871058e00b001631c979a3bmr1053441oan.45.1675257975821; Wed, 01 Feb 2023 05:26:15 -0800 (PST) Received: from mvwork.attlocal.net ([2600:1700:9190:ba10::32]) by smtp.gmail.com with ESMTPSA id y15-20020a4acb8f000000b0049fd5c02d25sm5010622ooq.12.2023.02.01.05.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 05:26:15 -0800 (PST) From: Armin Kuster To: yocto@lists.yoctoproject.org Subject: [kirkstone][meta-tpm][PATCH 1/3] oeqa/swtpm: add swtpm runtime Date: Wed, 1 Feb 2023 08:26:12 -0500 Message-Id: <20230201132614.2840970-1-akuster808@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 01 Feb 2023 13:26:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/59129 Signed-off-by: Armin Kuster (cherry picked from commit 50eff83d428598630d5277904eeeb4b668c31c22) Signed-off-by: Armin Kuster --- meta-tpm/lib/oeqa/runtime/cases/swtpm.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 meta-tpm/lib/oeqa/runtime/cases/swtpm.py diff --git a/meta-tpm/lib/oeqa/runtime/cases/swtpm.py b/meta-tpm/lib/oeqa/runtime/cases/swtpm.py new file mode 100644 index 0000000..df47b35 --- /dev/null +++ b/meta-tpm/lib/oeqa/runtime/cases/swtpm.py @@ -0,0 +1,24 @@ +# Copyright (C) 2022 Armin Kuster +# +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.runtime.decorator.package import OEHasPackage +from oeqa.core.decorator.data import skipIfNotFeature + +class SwTpmTest(OERuntimeTestCase): + @classmethod + def setUpClass(cls): + cls.tc.target.run('mkdir /tmp/myvtpm2') + cls.tc.target.run('chown tss:root /tmp/myvtpm2') + + @classmethod + def tearDownClass(cls): + cls.tc.target.run('rm -fr /tmp/myvtpm2') + + @skipIfNotFeature('tpm2','Test tpm2_swtpm_socket requires tpm2 to be in DISTRO_FEATURES') + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['swtpm']) + def test_swtpm2_ek_cert(self): + cmd = 'swtpm_setup --tpmstate /tmp/myvtpm2 --create-ek-cert --create-platform-cert --tpm2', + status, output = self.target.run(cmd) + self.assertEqual(status, 0, msg="swtpm create-ek-cert failed: %s" % output) From patchwork Wed Feb 1 13:26:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akuster808 X-Patchwork-Id: 18865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54A81C05027 for ; Wed, 1 Feb 2023 13:26:22 +0000 (UTC) Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) by mx.groups.io with SMTP id smtpd.web10.22721.1675257977308982260 for ; Wed, 01 Feb 2023 05:26:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nGNJguBs; spf=pass (domain: gmail.com, ip: 209.85.161.46, mailfrom: akuster808@gmail.com) Received: by mail-oo1-f46.google.com with SMTP id i11-20020a056820012b00b00517518d79f6so1119145ood.10 for ; Wed, 01 Feb 2023 05:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NvGELKTnIMKp0N0IjA6E6qzX52EB7HGMyJYxGFg73AA=; b=nGNJguBsZIGYEyICMYKY8oAOFwgVqdt2C+bmU/gitW3/XGmc8JBBChjpH/nU8DH1q2 1Hw4MS9OddogQfStGA0B3o0qege4eWinTuVgwZSpmRYbQEOCRYz3SRQiQAQvIn0BSQJY 2Yt5vgGnoqrTrQf2Hz28wuD9oPaI0qKX0/2RQkBUgYv7ICNl3QCuN+sC2RTqc/oSYifN 9MUv+N3AAVOaUhSEor0CqQMQwR4heSr8LOsLRWDBU7e4kCoiuO41xeo6CE6gVSpiAjBL TF9EduPp5hUfGVC+HWLPs/XffUUTkSZ7iVooZMWyjBiJEMfLABjXJXZXIqHgwi8pmzAo otlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NvGELKTnIMKp0N0IjA6E6qzX52EB7HGMyJYxGFg73AA=; b=EVuBKHa/sQj81+vHgc5wGXdOpamZ7wFOehwyT54yJ05lije0JkvPXfGHZR6CVu9dRa Jh1NxqtVGsrYwYRPIFqqZ/kR1acv3Z8m6fGotDsfN86EknQaQ+6plFFJNWDitAFNtF24 joNTLkHKlD6qndTpcepJBHrxvNo6A8ZZYPFHj/k6tt3p6mVwPam/4O7m5FNZUpxUgU2r bHQJ3SmZiJM9D8wHewEr0mdeOuoa+Bar8seKeYQrbxqmCIIyKnPW72xnIF5mB/a5uBOf znKlf9jINgoKfX6SgTTH549YKcP4HeBywl0/Y3IRtvkfBw4J7igbAjDi7Pj85ULifrC7 pH3g== X-Gm-Message-State: AO0yUKVvFDSDzb//MaFG8W2amfHwG4edv10ygcqs36E9xoFy5CYKE9HX UqdYTJ8S+JrnA5hF0BH+ppOA2eMpRaI= X-Google-Smtp-Source: AK7set+/c0hufXkbTYJN88mZJgqnkIFg6rk5JM0SxEp8L8oIXOsRqUqt9zvh7sVlWT+6D66S0XUQew== X-Received: by 2002:a05:6820:1a9e:b0:4a3:fbd7:c32a with SMTP id bt30-20020a0568201a9e00b004a3fbd7c32amr7712398oob.2.1675257976350; Wed, 01 Feb 2023 05:26:16 -0800 (PST) Received: from mvwork.attlocal.net ([2600:1700:9190:ba10::32]) by smtp.gmail.com with ESMTPSA id y15-20020a4acb8f000000b0049fd5c02d25sm5010622ooq.12.2023.02.01.05.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 05:26:16 -0800 (PST) From: Armin Kuster To: yocto@lists.yoctoproject.org Subject: [kirkstone][meta-tpm][PATCH 2/3] oeqa/tpm2: fix and cleanup tests Date: Wed, 1 Feb 2023 08:26:13 -0500 Message-Id: <20230201132614.2840970-2-akuster808@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230201132614.2840970-1-akuster808@gmail.com> References: <20230201132614.2840970-1-akuster808@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 01 Feb 2023 13:26:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/59130 Signed-off-by: Armin Kuster (cherry picked from commit 3db9e08300c3d5e3f7b6e4e6cb743a914ed3f00b) Signed-off-by: Armin Kuster --- meta-tpm/lib/oeqa/runtime/cases/tpm2.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py index c2c95e7..e64d19d 100644 --- a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py +++ b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py @@ -1,11 +1,19 @@ -# Copyright (C) 2019 Armin Kuster +# Copyright (C) 2019 - 2022 Armin Kuster # from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.runtime.decorator.package import OEHasPackage - +from oeqa.core.decorator.data import skipIfNotFeature class Tpm2Test(OERuntimeTestCase): + @classmethod + def setUpClass(cls): + cls.tc.target.run('mkdir /tmp/myvtpm2') + + @classmethod + def tearDownClass(cls): + cls.tc.target.run('rm -fr /tmp/myvtpm2') + def check_endlines(self, results, expected_endlines): for line in results.splitlines(): for el in expected_endlines: @@ -19,20 +27,19 @@ class Tpm2Test(OERuntimeTestCase): @OEHasPackage(['tpm2-tools']) @OEHasPackage(['tpm2-abrmd']) @OEHasPackage(['swtpm']) + @skipIfNotFeature('tpm2','Test tpm2_startup requires tpm2 to be in DISTRO_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) - def test_tpm2_swtpm_socket(self): + def test_tpm2_startup(self): cmds = [ - 'mkdir /tmp/myvtpm', - 'swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init &', - 'export TPM2TOOLS_TCTI="swtpm:port=2321"', - 'tpm2_startup -c' + 'swtpm socket -d --tpmstate dir=/tmp/myvtpm2 --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init', + 'tpm2_startup -c -T "swtpm:port=2321"', ] for cmd in cmds: status, output = self.target.run(cmd) self.assertEqual(status, 0, msg='\n'.join([cmd, output])) - @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) + @OETestDepends(['tpm2.Tpm2Test.test_tpm2_startup']) def test_tpm2_pcrread(self): (status, output) = self.target.run('tpm2_pcrread') expected_endlines = [] @@ -49,7 +56,7 @@ class Tpm2Test(OERuntimeTestCase): @OEHasPackage(['p11-kit']) @OEHasPackage(['tpm2-pkcs11']) - @OETestDepends(['tpm2.Tpm2Test.test_tpm2_swtpm_socket']) + @OETestDepends(['tpm2.Tpm2Test.test_tpm2_pcrread']) def test_tpm2_pkcs11(self): (status, output) = self.target.run('p11-kit list-modules -v') self.assertEqual(status, 0, msg="Modules missing: %s" % output) From patchwork Wed Feb 1 13:26:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akuster808 X-Patchwork-Id: 18867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BAB4C636CD for ; Wed, 1 Feb 2023 13:26:22 +0000 (UTC) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by mx.groups.io with SMTP id smtpd.web11.23031.1675257977943523387 for ; Wed, 01 Feb 2023 05:26:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WHmHUUI8; spf=pass (domain: gmail.com, ip: 209.85.161.52, mailfrom: akuster808@gmail.com) Received: by mail-oo1-f52.google.com with SMTP id b10-20020a4a9fca000000b004e6f734c6b4so1925421oom.9 for ; Wed, 01 Feb 2023 05:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+Jx2gZ21DkSCWU5o4PEnoVvMWuS70GByy1Hqs2SRuoQ=; b=WHmHUUI8pMj4qAzoZx5pyOZKiVYaGMpsoFGkjc9oShFy1XvrmZ3m0xUpvvpgoCBstD i+5bnbL5PdZaGZIWzHyKtvaGYn7Kj1KIeZ+Dom7erqEHIGZOcu4q6QOh9gFFqReXf2Eg lSaXoZdlVoOylJ0RKroZkbcfjCkZA8qyEvJmflnibU6FbDoxUhUF8mW3JR5TM5BYZYG4 LTZm7NbSYoMTx5br/b1O3vzJamcx/YFnp3cat3x8f/JEAIJciTNZQqgbrpKfSWfZU5Ie 4LYVxG9szVm6tIKnvPA9f57B8KemhJL+FhBG/QMSOmvPiXuggVjXO8kHsqJA1X/2wfho JylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Jx2gZ21DkSCWU5o4PEnoVvMWuS70GByy1Hqs2SRuoQ=; b=RYhHkg3qKoDOfzU+38aGHJRpToTipPcWpR+1gTxJLdL02XLhzsCSdcWY7m7n9tuJHW dIf9BeKTdhjV0AKmpNe8OAhUwTcTDwW/+uePOEi67bU/9IrjqXJM+Kh2UjlKjigwLSyE A5pAEEgsu8IOqBTvPkj6FqqwJ8MZVOuGZ7BiKS6ArMJ+3DstStRszrZmo7+n+qCyDuqR Zt6lyrSZmcd1+xAy+DTOxd7VpV0jqSrHsN2RcUp5WvdsCIYk3PFwC0p/CEyg8wL4TDRs 6apbpa6dc6ytkbGYUuPoE/t30gqxBefebxYh9u/9cPdugJ1FIExm/yqZVti09HKZtYuA cEiA== X-Gm-Message-State: AO0yUKUQHTqMmVM3hNxii4lZLpsYtT/+Zgk3A0ooOF+IDIPe7Gg0Vn9v 2DzNVljrMulCH/rYwy6hGGmRYo2UR/A= X-Google-Smtp-Source: AK7set/889TmL8aAdIfV0d/Wpoym+kRmLrOgdm+LBLtvIFuvBqBhC0kY+0VcxzjTsEJxBqbBK5VTOw== X-Received: by 2002:a4a:dc55:0:b0:517:67ba:586 with SMTP id q21-20020a4adc55000000b0051767ba0586mr995647oov.3.1675257977134; Wed, 01 Feb 2023 05:26:17 -0800 (PST) Received: from mvwork.attlocal.net ([2600:1700:9190:ba10::32]) by smtp.gmail.com with ESMTPSA id y15-20020a4acb8f000000b0049fd5c02d25sm5010622ooq.12.2023.02.01.05.26.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 05:26:16 -0800 (PST) From: Armin Kuster To: yocto@lists.yoctoproject.org Subject: [kirkstone][meta-tpm][PATCH 3/3] oeqa: meta-tpm shut swtpm down before and after testing Date: Wed, 1 Feb 2023 08:26:14 -0500 Message-Id: <20230201132614.2840970-3-akuster808@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230201132614.2840970-1-akuster808@gmail.com> References: <20230201132614.2840970-1-akuster808@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Wed, 01 Feb 2023 13:26:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/59131 fixes: swtpm: Could not open TCP socket: Address already in use Signed-off-by: Armin Kuster (cherry picked from commit b5642c519b90f83ab6ec1507db9b3b36db43c548) Signed-off-by: Armin Kuster --- meta-tpm/lib/oeqa/runtime/cases/swtpm.py | 2 ++ meta-tpm/lib/oeqa/runtime/cases/tpm2.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/meta-tpm/lib/oeqa/runtime/cases/swtpm.py b/meta-tpm/lib/oeqa/runtime/cases/swtpm.py index df47b35..0be5c59 100644 --- a/meta-tpm/lib/oeqa/runtime/cases/swtpm.py +++ b/meta-tpm/lib/oeqa/runtime/cases/swtpm.py @@ -8,11 +8,13 @@ from oeqa.core.decorator.data import skipIfNotFeature class SwTpmTest(OERuntimeTestCase): @classmethod def setUpClass(cls): + cls.tc.target.run('swtpm_ioctl -s --tcp :2322') cls.tc.target.run('mkdir /tmp/myvtpm2') cls.tc.target.run('chown tss:root /tmp/myvtpm2') @classmethod def tearDownClass(cls): + cls.tc.target.run('swtpm_ioctl -s --tcp :2322') cls.tc.target.run('rm -fr /tmp/myvtpm2') @skipIfNotFeature('tpm2','Test tpm2_swtpm_socket requires tpm2 to be in DISTRO_FEATURES') diff --git a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py index e64d19d..8e90dc9 100644 --- a/meta-tpm/lib/oeqa/runtime/cases/tpm2.py +++ b/meta-tpm/lib/oeqa/runtime/cases/tpm2.py @@ -8,10 +8,12 @@ from oeqa.core.decorator.data import skipIfNotFeature class Tpm2Test(OERuntimeTestCase): @classmethod def setUpClass(cls): + cls.tc.target.run('swtpm_ioctl -s --tcp :2322') cls.tc.target.run('mkdir /tmp/myvtpm2') @classmethod def tearDownClass(cls): + cls.tc.target.run('swtpm_ioctl -s --tcp :2322') cls.tc.target.run('rm -fr /tmp/myvtpm2') def check_endlines(self, results, expected_endlines):