Rebase to 2.3.0

Resolves: RHEL-45223

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
This commit is contained in:
Štěpán Horáček 2024-07-25 15:23:06 +02:00
parent 68253b7b54
commit 79e43659a5
7 changed files with 80 additions and 128 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/tpm2-pytss-1.2.0.tar.gz
/tpm2-pytss-2.1.0.tar.gz
/tpm2-pytss-2.3.0.tar.gz

View File

@ -0,0 +1,36 @@
From 3cd9d2e5f9b4760c4c178c6e6c23247249012611 Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Wed, 3 Jul 2024 18:26:34 +0200
Subject: [PATCH 1/2] tests: Use p384 instead of p192
The p192 is not available on all platforms, such as Fedora.
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
test/test_cryptography.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/test_cryptography.py b/test/test_cryptography.py
index ed3dd6f..7f1bad5 100644
--- a/test/test_cryptography.py
+++ b/test/test_cryptography.py
@@ -297,14 +297,14 @@ class TestCryptography(TSS2_EsapiTest):
)
privkey = tpm_ecc_private_key(self.ectx, handle)
- peer_key = ec.generate_private_key(ec.SECP192R1())
+ peer_key = ec.generate_private_key(ec.SECP384R1())
peer_public_key = peer_key.public_key()
with self.assertRaises(ValueError) as e:
privkey.exchange(ec.ECDH(), peer_public_key)
self.assertEqual(
str(e.exception),
- "curve mismatch for peer key, got secp192r1, expected secp256r1",
+ "curve mismatch for peer key, got secp384r1, expected secp256r1",
)
def test_ecc_no_sign(self):
--
2.45.2

View File

@ -0,0 +1,35 @@
From 8e4ee856ac15bb1e1c3818d2d6956f76ee3c673a Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Wed, 3 Jul 2024 18:26:44 +0200
Subject: [PATCH 2/2] tests: Fix typo in the curve name
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
test/test_policy.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/test_policy.py b/test/test_policy.py
index 5f56e21..af0c45f 100644
--- a/test/test_policy.py
+++ b/test/test_policy.py
@@ -531,7 +531,7 @@ class TestPolicy(TSS2_EsapiTest):
def test_exec_sign_callback(self):
if not self._has_secp192r1:
- self.skipTest("cryptography doesn't have secp129r1")
+ self.skipTest("cryptography doesn't have secp192r1")
private_key = textwrap.dedent(
"""
-----BEGIN PRIVATE KEY-----
@@ -605,7 +605,7 @@ class TestPolicy(TSS2_EsapiTest):
def test_exec_polauth_callback(self):
if not self._has_secp192r1:
- self.skipTest("cryptography doesn't have secp129r1")
+ self.skipTest("cryptography doesn't have secp192r1")
private_key = textwrap.dedent(
"""
-----BEGIN PRIVATE KEY-----
--
2.45.2

View File

@ -1,84 +0,0 @@
diff -up tpm2-pytss-1.2.0/test/test_crypto.py.old tpm2-pytss-1.2.0/test/test_crypto.py
--- tpm2-pytss-1.2.0/test/test_crypto.py.old 2022-10-17 15:26:41.205419193 +0200
+++ tpm2-pytss-1.2.0/test/test_crypto.py 2022-10-17 15:28:29.717379140 +0200
@@ -581,7 +581,7 @@ class CryptoTest(TSS2_EsapiTest):
def test_ecc_bad_curves(self):
with self.assertRaises(ValueError) as e:
TPMT_PUBLIC.from_pem(ecc_bad_curve)
- self.assertEqual(str(e.exception), "unsupported curve: sect163r2")
+ self.assertEqual(str(e.exception), "Unsupported key format")
pub = TPMT_PUBLIC.from_pem(ecc_public_key)
pub.parameters.eccDetail.curveID = TPM2_ECC.NONE
diff -up tpm2-pytss-2.1.0/test/test_policy.py.old tpm2-pytss-2.1.0/test/test_policy.py
--- tpm2-pytss-2.1.0/test/test_policy.py.old 2023-08-07 18:42:18.825991709 +0200
+++ tpm2-pytss-2.1.0/test/test_policy.py 2023-08-07 18:42:38.690410796 +0200
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-2
import unittest
+import pytest
import textwrap
import json
from tpm2_pytss import *
@@ -521,6 +522,7 @@ class TestPolicy(TSS2_EsapiTest):
p.execute(self.ectx, session)
self.assertEqual(str(e.exception), "callback exception")
+ @pytest.mark.skip(reason="Fedora does not support P192v1 curve")
def test_exec_sign_callback(self):
private_key = textwrap.dedent(
"""
@@ -593,6 +595,7 @@ class TestPolicy(TSS2_EsapiTest):
p.execute(self.ectx, session)
self.assertEqual(str(e.exception), "callback exception")
+ @pytest.mark.skip(reason="Fedora does not support P192v1 curve")
def test_exec_polauth_callback(self):
private_key = textwrap.dedent(
"""
From e4006e6066c015d9ed55befa9b98247fbdcafd7d Mon Sep 17 00:00:00 2001
From: Erik Larsson <who+github@cnackers.org>
Date: Mon, 26 Jun 2023 12:15:41 +0200
Subject: [PATCH] test: add check for renamed cryptography types
Some types have changed their names in newer cryptography release, so add them to the tests
Signed-off-by: Erik Larsson <who+github@cnackers.org>
---
test/test_crypto.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/test/test_crypto.py b/test/test_crypto.py
index 92cda009..7d7466e2 100644
--- a/test/test_crypto.py
+++ b/test/test_crypto.py
@@ -596,11 +596,23 @@ def test_unsupported_key(self):
with self.assertRaises(ValueError) as e:
TPMT_SENSITIVE.from_pem(der)
- self.assertEqual(str(e.exception), "unsupported key type: _DSAPrivateKey")
+ self.assertIn(
+ str(e.exception),
+ (
+ "unsupported key type: _DSAPrivateKey",
+ "unsupported key type: DSAPrivateKey",
+ ),
+ )
with self.assertRaises(ValueError) as e:
TPMT_PUBLIC.from_pem(dsa_public_key)
- self.assertEqual(str(e.exception), "unsupported key type: _DSAPublicKey")
+ self.assertIn(
+ str(e.exception),
+ (
+ "unsupported key type: _DSAPublicKey",
+ "unsupported key type: DSAPublicKey",
+ ),
+ )
def test_from_pem_with_symmetric(self):
sym = TPMT_SYM_DEF_OBJECT(algorithm=TPM2_ALG.AES)

View File

@ -1,36 +0,0 @@
From 916c47ef6c30c2c6688f207bb780a2f4e6ef5384 Mon Sep 17 00:00:00 2001
From: Alberto Planas <aplanas@suse.com>
Date: Fri, 17 Feb 2023 13:58:18 +0100
Subject: [PATCH] setup: define __float128 for pycparse
When compiling in 32bit stddef.h makes use of the __float128 type, that
pycparse cannot recognize.
This patch define the type as "long double", fixing the issue in 32bits
platforms.
Fix #497
Signed-off-by: Alberto Planas <aplanas@suse.com>
---
setup.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 17736597..4554db0b 100644
--- a/setup.py
+++ b/setup.py
@@ -204,7 +204,11 @@ def get_mappings(self):
if policy_header_path:
pdata = preprocess_file(
policy_header_path,
- cpp_args=["-D__extension__=", "-D__attribute__(x)="],
+ cpp_args=[
+ "-D__extension__=",
+ "-D__attribute__(x)=",
+ "-D__float128=long double",
+ ],
)
parser = c_parser.CParser()
past = parser.parse(pdata, "tss2_policy.h")

View File

@ -2,18 +2,15 @@
%global _name tpm2_pytss
Name: python-%{pypi_name}
Version: 2.1.0
Release: 6%{?dist}
Version: 2.3.0
Release: 1%{?dist}
Summary: TPM 2.0 TSS Bindings for Python
License: BSD-2-Clause
URL: https://github.com/tpm2-software/tpm2-pytss
Source: %{pypi_source %{pypi_name}}
# https://github.com/tpm2-software/tpm2-pytss/issues/527
# https://github.com/tpm2-software/tpm2-pytss/commit/e4006e6066c015d9ed55befa9b98247fbdcafd7d
Patch0: python-tpm2-pytss-1.2.0-openssl.patch
# https://github.com/tpm2-software/tpm2-pytss/commit/916c47ef6c30c2c6688f207bb780a2f4e6ef5384
Patch1: python-tpm2-pytss-2.1.0-i686.patch
Patch0: 0001-tests-Use-p384-instead-of-p192.patch
Patch1: 0002-tests-Fix-typo-in-the-curve-name.patch
BuildRequires: python3-devel
BuildRequires: python3-pytest
@ -74,6 +71,9 @@ Summary: %{summary}
%changelog
* Thu Aug 8 Štěpán Horáček <shoracek@redhat.com> - 2.3.0-1
- Update to 2.3.0
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 2.1.0-6
- Bump release for June 2024 mass rebuild

View File

@ -1 +1 @@
SHA512 (tpm2-pytss-2.1.0.tar.gz) = b4d8b3a0124e67278f08ff72d3635221e84ae26b6a5489ee159e641931aa9045b4b5111ed02d5ff86d69bd89b8460b2592a3fdb94742562351e41783c78184ba
SHA512 (tpm2-pytss-2.3.0.tar.gz) = d0f76aec77afa773ec0ed7878a0ca4ef3b3475aa64f219d7a5afd89cbca795457536b0a9b5ffa14704200dcb35a89df36f9fc799694f7cc3cfbf98ea551628b1