summaryrefslogtreecommitdiff
path: root/security/tpm-tools/files/patch-src-data_mgmt-data_import.c
blob: 310193d03239abe421c69a9cf8d33b10dbbce9bd (plain) (blame)
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
--- src/data_mgmt/data_import.c.orig	2017-02-21 02:12:00 UTC
+++ src/data_mgmt/data_import.c
@@ -39,6 +39,16 @@
 #include <openssl/evp.h>
 #include <openssl/err.h>
 
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+#define	RSA_get0_n(x)	((x)->n)
+#define	RSA_get0_e(x)	((x)->e)
+#define	RSA_get0_d(x)	((x)->d)
+#define	RSA_get0_p(x)	((x)->p)
+#define	RSA_get0_q(x)	((x)->q)
+#define	RSA_get0_dmp1(x)	((x)->dmp1)
+#define	RSA_get0_dmq1(x)	((x)->dmq1)
+#define	RSA_get0_iqmp(x)	((x)->iqmp)
+#endif
 
 /*
  * Global variables
@@ -372,7 +382,7 @@ readX509Cert( const char  *a_pszFile,
 		goto out;
 	}
 
-	if ( EVP_PKEY_type( pKey->type ) != EVP_PKEY_RSA ) {
+	if ( EVP_PKEY_type( EVP_PKEY_id(pKey) ) != EVP_PKEY_RSA ) {
 		logError( TOKEN_RSA_KEY_ERROR );
 
 		X509_free( pX509 );
@@ -691,8 +701,8 @@ createRsaPubKeyObject( RSA               *a_pRsa,
 
 	int  rc = -1;
 
-	int  nLen = BN_num_bytes( a_pRsa->n );
-	int  eLen = BN_num_bytes( a_pRsa->e );
+	int  nLen = BN_num_bytes( RSA_get0_n(a_pRsa) );
+	int  eLen = BN_num_bytes( RSA_get0_e(a_pRsa) );
 
 	CK_RV  rv;
 
@@ -732,8 +742,8 @@ createRsaPubKeyObject( RSA               *a_pRsa,
 	}
 
 	// Get binary representations of the RSA key information
-	BN_bn2bin( a_pRsa->n, n );
-	BN_bn2bin( a_pRsa->e, e );
+	BN_bn2bin( RSA_get0_n(a_pRsa), n );
+	BN_bn2bin( RSA_get0_e(a_pRsa), e );
 
 	// Create the RSA public key object
 	rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject );
@@ -760,14 +770,14 @@ createRsaPrivKeyObject( RSA               *a_pRsa,
 
 	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 );
+	int  nLen = BN_num_bytes( RSA_get0_n(a_pRsa) );
+	int  eLen = BN_num_bytes( RSA_get0_e(a_pRsa) );
+	int  dLen = BN_num_bytes( RSA_get0_d(a_pRsa) );
+	int  pLen = BN_num_bytes( RSA_get0_p(a_pRsa) );
+	int  qLen = BN_num_bytes( RSA_get0_q(a_pRsa) );
+	int  dmp1Len = BN_num_bytes( RSA_get0_dmp1(a_pRsa) );
+	int  dmq1Len = BN_num_bytes( RSA_get0_dmq1(a_pRsa) );
+	int  iqmpLen = BN_num_bytes( RSA_get0_iqmp(a_pRsa) );
 
 	CK_RV  rv;
 
@@ -821,14 +831,14 @@ createRsaPrivKeyObject( RSA               *a_pRsa,
 	}
 
 	// 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( RSA_get0_n(a_pRsa), n );
+	BN_bn2bin( RSA_get0_e(a_pRsa), e );
+	BN_bn2bin( RSA_get0_d(a_pRsa), d );
+	BN_bn2bin( RSA_get0_p(a_pRsa), p );
+	BN_bn2bin( RSA_get0_q(a_pRsa), q );
+	BN_bn2bin( RSA_get0_dmp1(a_pRsa), dmp1 );
+	BN_bn2bin( RSA_get0_dmq1(a_pRsa), dmq1 );
+	BN_bn2bin( RSA_get0_iqmp(a_pRsa), iqmp );
 
 	// Create the RSA private key object
 	rv = createObject( a_hSession, tAttr, ulAttrCount, a_hObject );