From bce7904376beee2912932433a4634c1c25afe2f5 Mon Sep 17 00:00:00 2001 From: Daniel Kurtz Date: Fri, 30 Jun 2017 11:45:08 +0800 Subject: Update for openssl 1.1 OpenSSL 1.1 has made significant non-backwards compatible changes to its API as outlined in: https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes BRANCH=none BUG=chromium:738114 TEST=cros_workon --host start vboot_reference TEST=w/ openssl-1.0.2k: sudo emerge vboot_reference TEST=w/ openssl-1.1.0e: sudo emerge vboot_reference => both build ok $ futility version => command runs without error TEST=cros_workon --board=soraka start vboot_reference coreboot TEST=w/ openssl-1.0.2k: emerge-soraka vboot_reference coreboot TEST=w/ openssl-1.1.0e: emerge-soraka vboot_reference coreboot => All build ok Change-Id: I37cfc8cbb04a092eab7b0b3224f475b82609447c Reviewed-on: https://chromium-review.googlesource.com/557739 Commit-Ready: Daniel Kurtz Tested-by: Daniel Kurtz Reviewed-by: Randall Spangler Reviewed-by: Mike Frysinger --- utility/dumpRSAPublicKey.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'utility') diff --git a/utility/dumpRSAPublicKey.c b/utility/dumpRSAPublicKey.c index 26724d6e..9e90003f 100644 --- a/utility/dumpRSAPublicKey.c +++ b/utility/dumpRSAPublicKey.c @@ -14,14 +14,20 @@ #include #include +#include "openssl_compat.h" + /* Command line tool to extract RSA public keys from X.509 certificates * and output a pre-processed version of keys for use by RSA verification * routines. */ int check(RSA* key) { - int public_exponent = BN_get_word(key->e); - int modulus = BN_num_bits(key->n); + const BIGNUM *n, *e; + int public_exponent, modulus; + + RSA_get0_key(key, &n, &e, NULL); + public_exponent = BN_get_word(e); + modulus = BN_num_bits(n); if (public_exponent != 3 && public_exponent != 65537) { fprintf(stderr, @@ -41,7 +47,8 @@ int check(RSA* key) { */ void output(RSA* key) { int i, nwords; - BIGNUM *N = key->n; + const BIGNUM *key_n; + BIGNUM *N = NULL; BIGNUM *Big1 = NULL, *Big2 = NULL, *Big32 = NULL, *BigMinus1 = NULL; BIGNUM *B = NULL; BIGNUM *N0inv= NULL, *R = NULL, *RR = NULL, *RRTemp = NULL, *NnumBits = NULL; @@ -49,14 +56,15 @@ void output(RSA* key) { BN_CTX *bn_ctx = BN_CTX_new(); uint32_t n0invout; - N = key->n; /* Output size of RSA key in 32-bit words */ - nwords = BN_num_bits(N) / 32; + nwords = RSA_size(key) / 4; if (-1 == write(1, &nwords, sizeof(nwords))) goto failure; /* Initialize BIGNUMs */ + RSA_get0_key(key, &key_n, NULL, NULL); + N = BN_dup(key_n); Big1 = BN_new(); Big2 = BN_new(); Big32 = BN_new(); @@ -121,6 +129,7 @@ void output(RSA* key) { failure: /* Free BIGNUMs. */ + BN_free(N); BN_free(Big1); BN_free(Big2); BN_free(Big32); -- cgit v1.2.1