summarylogtreecommitdiffstats
path: root/05-openssl1.1_fix_data_mgmt.patch
blob: 480f4db3a7743ab1a3b645a46b064f4106a4fc07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Author: Philipp Kern <pkern@debian.org>
Subject: Fix openssl1.1 support in data_mgmt
Date: Tue, 31 Jan 2017 22:40:10 +0100


---
 src/data_mgmt/data_import.c |   60 ++++++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 21 deletions(-)

--- a/src/data_mgmt/data_import.c
+++ b/src/data_mgmt/data_import.c
@@ -372,7 +372,7 @@ readX509Cert( const char  *a_pszFile,
 		goto out;
 	}
 
-	if ( EVP_PKEY_type( pKey->type ) != EVP_PKEY_RSA ) {
+	if ( EVP_PKEY_base_id( pKey ) != EVP_PKEY_RSA ) {
 		logError( TOKEN_RSA_KEY_ERROR );
 
 		X509_free( pX509 );
@@ -691,8 +691,13 @@ createRsaPubKeyObject( RSA
 
 	int  rc = -1;
 
-	int  nLen = BN_num_bytes( a_pRsa->n );
-	int  eLen = BN_num_bytes( a_pRsa->e );
+	const BIGNUM *bn;
+	const BIGNUM *be;
+
+	RSA_get0_key( a_pRsa, &bn, &be, NULL );
+
+	int  nLen = BN_num_bytes( bn );
+	int  eLen = BN_num_bytes( be );
 
 	CK_RV  rv;
 
@@ -732,8 +737,8 @@ createRsaPubKeyObject( RSA
 	}
 
 	// Get binary representations of the RSA key information
-	BN_bn2bin( a_pRsa->n, n );
-	BN_bn2bin( a_pRsa->e, e );
+	BN_bn2bin( bn, n );
+	BN_bn2bin( be, e );
 
 	// Create the RSA public key object
 	rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject );
@@ -760,14 +765,27 @@ createRsaPrivKeyObject( RSA
 
 	int  rc = -1;
 
-	int  nLen = BN_num_bytes( a_pRsa->n );
-	int  eLen = BN_num_bytes( a_pRsa->e );
-	int  dLen = BN_num_bytes( a_pRsa->d );
-	int  pLen = BN_num_bytes( a_pRsa->p );
-	int  qLen = BN_num_bytes( a_pRsa->q );
-	int  dmp1Len = BN_num_bytes( a_pRsa->dmp1 );
-	int  dmq1Len = BN_num_bytes( a_pRsa->dmq1 );
-	int  iqmpLen = BN_num_bytes( a_pRsa->iqmp );
+	const BIGNUM *bn;
+	const BIGNUM *be;
+	const BIGNUM *bd;
+	const BIGNUM *bp;
+	const BIGNUM *bq;
+	const BIGNUM *bdmp1;
+	const BIGNUM *bdmq1;
+	const BIGNUM *biqmp;
+
+	RSA_get0_key( a_pRsa, &bn, &be, &bd);
+	RSA_get0_factors( a_pRsa, &bp, &bq);
+	RSA_get0_crt_params( a_pRsa, &bdmp1, &bdmq1, &biqmp );
+
+	int  nLen = BN_num_bytes( bn );
+	int  eLen = BN_num_bytes( be );
+	int  dLen = BN_num_bytes( bd );
+	int  pLen = BN_num_bytes( bp );
+	int  qLen = BN_num_bytes( bq );
+	int  dmp1Len = BN_num_bytes( bdmp1 );
+	int  dmq1Len = BN_num_bytes( bdmq1 );
+	int  iqmpLen = BN_num_bytes( biqmp );
 
 	CK_RV  rv;
 
@@ -821,14 +839,14 @@ createRsaPrivKeyObject( RSA
 	}
 
 	// Get binary representations of the RSA key information
-	BN_bn2bin( a_pRsa->n, n );
-	BN_bn2bin( a_pRsa->e, e );
-	BN_bn2bin( a_pRsa->d, d );
-	BN_bn2bin( a_pRsa->p, p );
-	BN_bn2bin( a_pRsa->q, q );
-	BN_bn2bin( a_pRsa->dmp1, dmp1 );
-	BN_bn2bin( a_pRsa->dmq1, dmq1 );
-	BN_bn2bin( a_pRsa->iqmp, iqmp );
+	BN_bn2bin( bn, n );
+	BN_bn2bin( be, e );
+	BN_bn2bin( bd, d );
+	BN_bn2bin( bp, p );
+	BN_bn2bin( bq, q );
+	BN_bn2bin( bdmp1, dmp1 );
+	BN_bn2bin( bdmq1, dmq1 );
+	BN_bn2bin( biqmp, iqmp );
 
 	// Create the RSA private key object
 	rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject );