Marcus Meissner
f182629d0c
TPM 2.0 emulator (for testing ibmtss during build) OBS-URL: https://build.opensuse.org/request/show/453674 OBS-URL: https://build.opensuse.org/package/show/security/ibmswtpm2?expand=0&rev=1
79 lines
3.1 KiB
Diff
79 lines
3.1 KiB
Diff
diff -ur ibmtpm832/src/Implementation.h ibmswtpm2-832/src/Implementation.h
|
|
--- ibmtpm832/src/Implementation.h 2016-11-18 22:42:16.000000000 +0100
|
|
+++ ibmswtpm2-832/src/Implementation.h 2017-01-30 17:36:16.279264575 +0100
|
|
@@ -301,7 +301,11 @@
|
|
/* From Vendor-Specific: Table 7 - Defines for Implementation Values */
|
|
#define FIELD_UPGRADE_IMPLEMENTED NO
|
|
#ifdef TPM_POSIX
|
|
+#if defined(__LP64__) || defined(_LP64)
|
|
#define RADIX_BITS 64 /* kgold */
|
|
+#else
|
|
+#define RADIX_BITS 32 /* kgold */
|
|
+#endif
|
|
#endif
|
|
#ifdef TPM_WINDOWS
|
|
#define RADIX_BITS 32 /* kgold */
|
|
diff -ur ibmtpm832/src/Clock.c ibmswtpm2-832/src/Clock.c
|
|
--- ibmtpm832/src/Clock.c 2016-11-18 22:41:02.000000000 +0100
|
|
+++ ibmswtpm2-832/src/Clock.c 2017-01-30 17:55:23.251624384 +0100
|
|
@@ -164,7 +164,7 @@
|
|
clock_t timeDiff;
|
|
uint64_t adjusted;
|
|
/* TOP is a base line or reference point, and BOTTOM is the current scale factor. */
|
|
-# define TOP (CLOCKS_PER_SEC * CLOCK_NOMINAL) /* kgold */
|
|
+# define TOP ((uint64_t)CLOCKS_PER_SEC * CLOCK_NOMINAL) /* kgold */
|
|
/* # define BOTTOM ((uint64_t)s_adjustRate * CLOCKS_PER_SEC) */
|
|
# 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;
|