|
|
28a59a |
From 61989b4c0a2da337a5c8df56e68c83e73259ed75 Mon Sep 17 00:00:00 2001
|
|
|
28a59a |
From: Petr Gotthard <petr.gotthard@centrum.cz>
|
|
|
28a59a |
Date: Sat, 7 Aug 2021 11:39:52 +0200
|
|
|
28a59a |
Subject: [PATCH 04/17] openssl: Remove support for OpenSSL < 1.1.0
|
|
|
28a59a |
|
|
|
28a59a |
The OpenSSL 1.0.2 is no longer maintained. Supporting an EOL crypto
|
|
|
28a59a |
library is not a good idea.
|
|
|
28a59a |
|
|
|
28a59a |
- Compared to the upstream commit 1e439d85 changes related to functions
|
|
|
28a59a |
and features not previously backported were ommited.
|
|
|
28a59a |
|
|
|
28a59a |
Signed-off-by: Petr Gotthard <petr.gotthard@centrum.cz>
|
|
|
28a59a |
---
|
|
|
28a59a |
configure.ac | 2 +-
|
|
|
28a59a |
doc/CHANGELOG.md | 5 +++
|
|
|
28a59a |
doc/INSTALL.md | 2 +-
|
|
|
28a59a |
doc/RELEASE.md | 7 ----
|
|
|
28a59a |
lib/tpm2_openssl.c | 87 ----------------------------------------------
|
|
|
28a59a |
lib/tpm2_openssl.h | 10 ------
|
|
|
28a59a |
6 files changed, 7 insertions(+), 106 deletions(-)
|
|
|
28a59a |
|
|
|
28a59a |
diff --git a/configure.ac b/configure.ac
|
|
|
28a59a |
index a3988e15..9561fa86 100644
|
|
|
28a59a |
--- a/configure.ac
|
|
|
28a59a |
+++ b/configure.ac
|
|
|
28a59a |
@@ -58,7 +58,7 @@ PKG_CHECK_MODULES([TSS2_TCTILDR], [tss2-tctildr])
|
|
|
28a59a |
PKG_CHECK_MODULES([TSS2_MU], [tss2-mu])
|
|
|
28a59a |
PKG_CHECK_MODULES([TSS2_RC], [tss2-rc])
|
|
|
28a59a |
PKG_CHECK_MODULES([TSS2_SYS], [tss2-sys])
|
|
|
28a59a |
-PKG_CHECK_MODULES([CRYPTO], [libcrypto >= 1.0.2g])
|
|
|
28a59a |
+PKG_CHECK_MODULES([CRYPTO], [libcrypto >= 1.1.0])
|
|
|
28a59a |
PKG_CHECK_MODULES([CURL], [libcurl])
|
|
|
28a59a |
PKG_CHECK_MODULES([UUID], [uuid])
|
|
|
28a59a |
|
|
|
28a59a |
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
|
|
|
28a59a |
index 87573fd7..b244dfee 100644
|
|
|
28a59a |
--- a/doc/CHANGELOG.md
|
|
|
28a59a |
+++ b/doc/CHANGELOG.md
|
|
|
28a59a |
@@ -1,5 +1,10 @@
|
|
|
28a59a |
## Changelog
|
|
|
28a59a |
|
|
|
28a59a |
+### next
|
|
|
28a59a |
+
|
|
|
28a59a |
+ * openssl:
|
|
|
28a59a |
+ - Dropped support for OpenSSL < 1.1.0
|
|
|
28a59a |
+
|
|
|
28a59a |
### 5.0 - 2020-11-16
|
|
|
28a59a |
|
|
|
28a59a |
#### Non Backwards Compatible Changes
|
|
|
28a59a |
diff --git a/doc/INSTALL.md b/doc/INSTALL.md
|
|
|
28a59a |
index b23b8d61..ab160581 100644
|
|
|
28a59a |
--- a/doc/INSTALL.md
|
|
|
28a59a |
+++ b/doc/INSTALL.md
|
|
|
28a59a |
@@ -19,7 +19,7 @@ To build and install the tpm2-tools software the following software is required:
|
|
|
28a59a |
* C compiler
|
|
|
28a59a |
* C Library Development Libraries and Header Files (for pthreads headers)
|
|
|
28a59a |
* ESAPI - TPM2.0 TSS ESAPI library (tss2-esys) and header files
|
|
|
28a59a |
- * OpenSSL libcrypto library and header files
|
|
|
28a59a |
+ * OpenSSL libcrypto library and header files (version >= 1.1.0)
|
|
|
28a59a |
* Curl library and header files
|
|
|
28a59a |
* Universally Unique ID library (UUID)
|
|
|
28a59a |
|
|
|
28a59a |
diff --git a/doc/RELEASE.md b/doc/RELEASE.md
|
|
|
28a59a |
index e2c72a67..8769b57d 100644
|
|
|
28a59a |
--- a/doc/RELEASE.md
|
|
|
28a59a |
+++ b/doc/RELEASE.md
|
|
|
28a59a |
@@ -23,13 +23,6 @@ the next release.
|
|
|
28a59a |
- [3.0.X](https://github.com/tpm2-software/tpm2-tools/tree/3.0.X): EOL after
|
|
|
28a59a |
3.2.1 release.
|
|
|
28a59a |
|
|
|
28a59a |
-## OpenSSL
|
|
|
28a59a |
-
|
|
|
28a59a |
-tpm2-tools relies heavily on OpenSSL. OpenSSL will be EOL'ing 1.0.2 at the end
|
|
|
28a59a |
-of 2019, see: https://www.openssl.org/blog/blog/2018/05/18/new-lts/. When this
|
|
|
28a59a |
-occurs, we will remove OSSL 1.0.2 support from the tpm2-tools repository as
|
|
|
28a59a |
-supporting an EOL crypto library is not a good idea.
|
|
|
28a59a |
-
|
|
|
28a59a |
# Release Information
|
|
|
28a59a |
|
|
|
28a59a |
Releases shall be tagged following semantic version guidelines found at:
|
|
|
28a59a |
diff --git a/lib/tpm2_openssl.c b/lib/tpm2_openssl.c
|
|
|
28a59a |
index e769d6df..877d2764 100644
|
|
|
28a59a |
--- a/lib/tpm2_openssl.c
|
|
|
28a59a |
+++ b/lib/tpm2_openssl.c
|
|
|
28a59a |
@@ -72,58 +72,6 @@ const EVP_MD *tpm2_openssl_halg_from_tpmhalg(TPMI_ALG_HASH algorithm) {
|
|
|
28a59a |
/* no return, not possible */
|
|
|
28a59a |
}
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
-int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) {
|
|
|
28a59a |
-
|
|
|
28a59a |
- if ((r->n == NULL && n == NULL) || (r->e == NULL && e == NULL)) {
|
|
|
28a59a |
- return 0;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- if (n != NULL) {
|
|
|
28a59a |
- BN_free(r->n);
|
|
|
28a59a |
- r->n = n;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- if (e != NULL) {
|
|
|
28a59a |
- BN_free(r->e);
|
|
|
28a59a |
- r->e = e;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- if (d != NULL) {
|
|
|
28a59a |
- BN_free(r->d);
|
|
|
28a59a |
- r->d = d;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- return 1;
|
|
|
28a59a |
-}
|
|
|
28a59a |
-
|
|
|
28a59a |
-void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) {
|
|
|
28a59a |
- if(p) {
|
|
|
28a59a |
- *p = r->p;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- if (q) {
|
|
|
28a59a |
- *q = r->q;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-}
|
|
|
28a59a |
-
|
|
|
28a59a |
-int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) {
|
|
|
28a59a |
-
|
|
|
28a59a |
- if (!r || !s) {
|
|
|
28a59a |
- return 0;
|
|
|
28a59a |
- }
|
|
|
28a59a |
-
|
|
|
28a59a |
- BN_clear_free(sig->r);
|
|
|
28a59a |
- BN_clear_free(sig->s);
|
|
|
28a59a |
-
|
|
|
28a59a |
- sig->r = r;
|
|
|
28a59a |
- sig->s = s;
|
|
|
28a59a |
-
|
|
|
28a59a |
- return 1;
|
|
|
28a59a |
-}
|
|
|
28a59a |
-
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
-
|
|
|
28a59a |
bool tpm2_openssl_hash_compute_data(TPMI_ALG_HASH halg, BYTE *buffer,
|
|
|
28a59a |
UINT16 length, TPM2B_DIGEST *digest) {
|
|
|
28a59a |
|
|
|
28a59a |
@@ -422,54 +370,28 @@ out:
|
|
|
28a59a |
|
|
|
28a59a |
HMAC_CTX *tpm2_openssl_hmac_new() {
|
|
|
28a59a |
HMAC_CTX *ctx;
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- ctx = malloc(sizeof(*ctx));
|
|
|
28a59a |
-#else
|
|
|
28a59a |
ctx = HMAC_CTX_new();
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
if (!ctx)
|
|
|
28a59a |
return NULL;
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- HMAC_CTX_init(ctx);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
-
|
|
|
28a59a |
return ctx;
|
|
|
28a59a |
}
|
|
|
28a59a |
|
|
|
28a59a |
void tpm2_openssl_hmac_free(HMAC_CTX *ctx) {
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- HMAC_CTX_cleanup(ctx);
|
|
|
28a59a |
- free(ctx);
|
|
|
28a59a |
-#else
|
|
|
28a59a |
HMAC_CTX_free(ctx);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
}
|
|
|
28a59a |
|
|
|
28a59a |
EVP_CIPHER_CTX *tpm2_openssl_cipher_new(void) {
|
|
|
28a59a |
EVP_CIPHER_CTX *ctx;
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- ctx = malloc(sizeof(*ctx));
|
|
|
28a59a |
-#else
|
|
|
28a59a |
ctx = EVP_CIPHER_CTX_new();
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
if (!ctx)
|
|
|
28a59a |
return NULL;
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- EVP_CIPHER_CTX_init(ctx);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
-
|
|
|
28a59a |
return ctx;
|
|
|
28a59a |
}
|
|
|
28a59a |
|
|
|
28a59a |
void tpm2_openssl_cipher_free(EVP_CIPHER_CTX *ctx) {
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- EVP_CIPHER_CTX_cleanup(ctx);
|
|
|
28a59a |
- free(ctx);
|
|
|
28a59a |
-#else
|
|
|
28a59a |
EVP_CIPHER_CTX_free(ctx);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
}
|
|
|
28a59a |
|
|
|
28a59a |
digester tpm2_openssl_halg_to_digester(TPMI_ALG_HASH halg) {
|
|
|
28a59a |
@@ -680,12 +602,7 @@ static bool load_public_RSA_from_key(RSA *k, TPM2B_PUBLIC *pub) {
|
|
|
28a59a |
const BIGNUM *n; /* modulus */
|
|
|
28a59a |
const BIGNUM *e; /* public key exponent */
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- n = k->n;
|
|
|
28a59a |
- e = k->e;
|
|
|
28a59a |
-#else
|
|
|
28a59a |
RSA_get0_key(k, &n, &e, NULL);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
|
|
|
28a59a |
/*
|
|
|
28a59a |
* The size of the modulus is the key size in RSA, store this as the
|
|
|
28a59a |
@@ -1006,11 +923,7 @@ static bool load_private_RSA_from_key(RSA *k, TPM2B_SENSITIVE *priv) {
|
|
|
28a59a |
|
|
|
28a59a |
const BIGNUM *p; /* the private key exponent */
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
- p = k->p;
|
|
|
28a59a |
-#else
|
|
|
28a59a |
RSA_get0_factors(k, &p, NULL);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
|
|
|
28a59a |
TPMT_SENSITIVE *sa = &priv->sensitiveArea;
|
|
|
28a59a |
|
|
|
28a59a |
diff --git a/lib/tpm2_openssl.h b/lib/tpm2_openssl.h
|
|
|
28a59a |
index 46c8f9c0..8e3e0c17 100644
|
|
|
28a59a |
--- a/lib/tpm2_openssl.h
|
|
|
28a59a |
+++ b/lib/tpm2_openssl.h
|
|
|
28a59a |
@@ -13,10 +13,6 @@
|
|
|
28a59a |
|
|
|
28a59a |
#include "pcr.h"
|
|
|
28a59a |
|
|
|
28a59a |
-#if (OPENSSL_VERSION_NUMBER < 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) /* OpenSSL 1.1.0 */
|
|
|
28a59a |
-#define LIB_TPM2_OPENSSL_OPENSSL_PRE11
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
-
|
|
|
28a59a |
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
|
|
|
28a59a |
#define EC_POINT_set_affine_coordinates_tss(group, tpm_pub_key, bn_x, bn_y, dmy) \
|
|
|
28a59a |
EC_POINT_set_affine_coordinates(group, tpm_pub_key, bn_x, bn_y, dmy)
|
|
|
28a59a |
@@ -32,12 +28,6 @@
|
|
|
28a59a |
EC_POINT_get_affine_coordinates_GFp(group, tpm_pub_key, bn_x, bn_y, dmy)
|
|
|
28a59a |
#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
|
|
|
28a59a |
|
|
|
28a59a |
-#if defined(LIB_TPM2_OPENSSL_OPENSSL_PRE11)
|
|
|
28a59a |
-int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
|
|
|
28a59a |
-void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
|
|
|
28a59a |
-int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);
|
|
|
28a59a |
-#endif
|
|
|
28a59a |
-
|
|
|
28a59a |
/**
|
|
|
28a59a |
* Function prototype for a hashing routine.
|
|
|
28a59a |
*
|
|
|
28a59a |
--
|
|
|
28a59a |
2.31.1
|
|
|
28a59a |
|