Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | Author: Philipp Kern <pkern@debian.org> |
| 2 | Subject: Fix openssl1.1 support in data_mgmt |
| 3 | Date: Tue, 31 Jan 2017 22:40:10 +0100 |
| 4 | |
| 5 | Upstream-Status: Backport |
| 6 | tpm-tools_1.3.9.1-0.1.debian.tar |
| 7 | |
| 8 | Signed-off-by: Armin kuster <akuster808@gmail.com> |
| 9 | |
| 10 | --- |
| 11 | src/data_mgmt/data_import.c | 60 ++++++++++++++++++++++++++++---------------- |
| 12 | 1 file changed, 39 insertions(+), 21 deletions(-) |
| 13 | |
| 14 | --- a/src/data_mgmt/data_import.c |
| 15 | +++ b/src/data_mgmt/data_import.c |
| 16 | @@ -372,7 +372,7 @@ readX509Cert( const char *a_pszFile, |
| 17 | goto out; |
| 18 | } |
| 19 | |
| 20 | - if ( EVP_PKEY_type( pKey->type ) != EVP_PKEY_RSA ) { |
| 21 | + if ( EVP_PKEY_base_id( pKey ) != EVP_PKEY_RSA ) { |
| 22 | logError( TOKEN_RSA_KEY_ERROR ); |
| 23 | |
| 24 | X509_free( pX509 ); |
| 25 | @@ -691,8 +691,13 @@ createRsaPubKeyObject( RSA |
| 26 | |
| 27 | int rc = -1; |
| 28 | |
| 29 | - int nLen = BN_num_bytes( a_pRsa->n ); |
| 30 | - int eLen = BN_num_bytes( a_pRsa->e ); |
| 31 | + const BIGNUM *bn; |
| 32 | + const BIGNUM *be; |
| 33 | + |
| 34 | + RSA_get0_key( a_pRsa, &bn, &be, NULL ); |
| 35 | + |
| 36 | + int nLen = BN_num_bytes( bn ); |
| 37 | + int eLen = BN_num_bytes( be ); |
| 38 | |
| 39 | CK_RV rv; |
| 40 | |
| 41 | @@ -732,8 +737,8 @@ createRsaPubKeyObject( RSA |
| 42 | } |
| 43 | |
| 44 | // Get binary representations of the RSA key information |
| 45 | - BN_bn2bin( a_pRsa->n, n ); |
| 46 | - BN_bn2bin( a_pRsa->e, e ); |
| 47 | + BN_bn2bin( bn, n ); |
| 48 | + BN_bn2bin( be, e ); |
| 49 | |
| 50 | // Create the RSA public key object |
| 51 | rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject ); |
| 52 | @@ -760,14 +765,27 @@ createRsaPrivKeyObject( RSA |
| 53 | |
| 54 | int rc = -1; |
| 55 | |
| 56 | - int nLen = BN_num_bytes( a_pRsa->n ); |
| 57 | - int eLen = BN_num_bytes( a_pRsa->e ); |
| 58 | - int dLen = BN_num_bytes( a_pRsa->d ); |
| 59 | - int pLen = BN_num_bytes( a_pRsa->p ); |
| 60 | - int qLen = BN_num_bytes( a_pRsa->q ); |
| 61 | - int dmp1Len = BN_num_bytes( a_pRsa->dmp1 ); |
| 62 | - int dmq1Len = BN_num_bytes( a_pRsa->dmq1 ); |
| 63 | - int iqmpLen = BN_num_bytes( a_pRsa->iqmp ); |
| 64 | + const BIGNUM *bn; |
| 65 | + const BIGNUM *be; |
| 66 | + const BIGNUM *bd; |
| 67 | + const BIGNUM *bp; |
| 68 | + const BIGNUM *bq; |
| 69 | + const BIGNUM *bdmp1; |
| 70 | + const BIGNUM *bdmq1; |
| 71 | + const BIGNUM *biqmp; |
| 72 | + |
| 73 | + RSA_get0_key( a_pRsa, &bn, &be, &bd); |
| 74 | + RSA_get0_factors( a_pRsa, &bp, &bq); |
| 75 | + RSA_get0_crt_params( a_pRsa, &bdmp1, &bdmq1, &biqmp ); |
| 76 | + |
| 77 | + int nLen = BN_num_bytes( bn ); |
| 78 | + int eLen = BN_num_bytes( be ); |
| 79 | + int dLen = BN_num_bytes( bd ); |
| 80 | + int pLen = BN_num_bytes( bp ); |
| 81 | + int qLen = BN_num_bytes( bq ); |
| 82 | + int dmp1Len = BN_num_bytes( bdmp1 ); |
| 83 | + int dmq1Len = BN_num_bytes( bdmq1 ); |
| 84 | + int iqmpLen = BN_num_bytes( biqmp ); |
| 85 | |
| 86 | CK_RV rv; |
| 87 | |
| 88 | @@ -821,14 +839,14 @@ createRsaPrivKeyObject( RSA |
| 89 | } |
| 90 | |
| 91 | // Get binary representations of the RSA key information |
| 92 | - BN_bn2bin( a_pRsa->n, n ); |
| 93 | - BN_bn2bin( a_pRsa->e, e ); |
| 94 | - BN_bn2bin( a_pRsa->d, d ); |
| 95 | - BN_bn2bin( a_pRsa->p, p ); |
| 96 | - BN_bn2bin( a_pRsa->q, q ); |
| 97 | - BN_bn2bin( a_pRsa->dmp1, dmp1 ); |
| 98 | - BN_bn2bin( a_pRsa->dmq1, dmq1 ); |
| 99 | - BN_bn2bin( a_pRsa->iqmp, iqmp ); |
| 100 | + BN_bn2bin( bn, n ); |
| 101 | + BN_bn2bin( be, e ); |
| 102 | + BN_bn2bin( bd, d ); |
| 103 | + BN_bn2bin( bp, p ); |
| 104 | + BN_bn2bin( bq, q ); |
| 105 | + BN_bn2bin( bdmp1, dmp1 ); |
| 106 | + BN_bn2bin( bdmq1, dmq1 ); |
| 107 | + BN_bn2bin( biqmp, iqmp ); |
| 108 | |
| 109 | // Create the RSA private key object |
| 110 | rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject ); |