Accepting request 457075 from home:michals

Drop gross hack in bits.patch

OBS-URL: https://build.opensuse.org/request/show/457075
OBS-URL: https://build.opensuse.org/package/show/security/ibmswtpm2?expand=0&rev=5
This commit is contained in:
Marcus Meissner 2017-02-15 14:12:17 +00:00 committed by Git OBS Bridge
parent 0745d668f7
commit 8c38bf2c68
2 changed files with 5 additions and 50 deletions

View File

@ -26,53 +26,3 @@ diff -ur ibmtpm832/src/Clock.c ibmswtpm2-832/src/Clock.c
# define BOTTOM ((uint64_t)s_adjustRate * CLOCKS_PER_SEC)
// Save the value previously read from the system clock
For some reason on 32bit this does not build. The OpenSSL d is unsigned int
AFAICT and the swtpm d is uint32_t. gcc does not tell what pointer types it
compares when it gives a mismatch error. Use an inline function so the pointers
are passed as arguments and any mismatch is reported including exact type.
diff -ur ibmtpm832/src/TpmToOsslMath.c ibmswtpm2-832/src/TpmToOsslMath.c
--- ibmtpm832/src/TpmToOsslMath.c 2016-11-16 19:31:54.000000000 +0100
+++ ibmswtpm2-832/src/TpmToOsslMath.c 2017-01-31 19:27:28.229651500 +0100
@@ -88,6 +88,23 @@
}
}
#endif
+#if (RADIX_BITS == 32)
+#define ossl_crypt_uword_t unsigned int
+#elif (RADIX_BITS == 64)
+#define ossl_crypt_uword_t unsigned long int
+#endif
+
+static int d_equal(const ossl_crypt_uword_t * d1, const crypt_uword_t *d2)
+{
+ pAssert(sizeof(ossl_crypt_uword_t) == sizeof(crypt_uword_t));
+ return (const void *)d1 == (const void *)d2;
+}
+static void d_assign(ossl_crypt_uword_t ** d, const crypt_uword_t * src)
+{
+ pAssert(sizeof(ossl_crypt_uword_t) == sizeof(crypt_uword_t));
+ *d=(ossl_crypt_uword_t *)src;
+}
+
/* B.2.3.2.3.1. OsslToTpmBn() */
/* This function converts an OpenSSL() BIGNUM to a TPM bignum. In this implementation it is assumed
that OpenSSL() used the same format for a big number as does the TPM -- an array of native-endian
@@ -102,7 +119,7 @@
{
if(bn != NULL)
{
- if(osslBn->d != bn->d)
+ if(!d_equal(osslBn->d, bn->d))
{
int i;
pAssert((unsigned)osslBn->top <= BnGetAllocated(bn));
@@ -120,7 +137,7 @@
{
if(toInit == NULL || initializer == NULL)
return NULL;
- toInit->d = (crypt_uword_t *)&initializer->d[0];
+ d_assign(&toInit->d, initializer->d);
toInit->dmax = initializer->allocated;
toInit->top = initializer->size;
toInit->neg = 0;

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Feb 14 12:16:37 UTC 2017 - msuchanek@suse.com
- Drop a pointer cast hack in bits.patch. It builds without the hack.
-------------------------------------------------------------------
Wed Feb 8 09:38:18 UTC 2017 - jengelh@inai.de