diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2017-06-30 11:45:08 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-07 00:57:17 -0700 |
commit | bce7904376beee2912932433a4634c1c25afe2f5 (patch) | |
tree | bba8df33dab5fb6d3c64b13ac3a290e8da03c780 /utility | |
parent | 06beb42e11733670eb1894f12586443a37a5af7c (diff) | |
download | vboot-bce7904376beee2912932433a4634c1c25afe2f5.tar.gz |
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 <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Diffstat (limited to 'utility')
-rw-r--r-- | utility/dumpRSAPublicKey.c | 19 |
1 files changed, 14 insertions, 5 deletions
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 <string.h> #include <unistd.h> +#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); |