Package: fis-gtm / 6.3-000A-1

upstream_encryption_libs_openssl110_compatible Patch series | download
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
From: Amul Shah <Amul.Shah@fisglobal.com>
Forwarded: not-needed
Summary: Update encryption plugin for OpenSSL 1.1.0
Description: #828300 resulted in a FTBFS for fis-gtm with openssl 1.1.0. These
  changes adapt the upstream fixes for OpenSSL 1.1.0 to V63000A
Applied-Upstream: V6.3-001
Last-Update: 2016-12-06

--- a/sr_unix/gtm_tls_impl.c
+++ b/sr_unix/gtm_tls_impl.c
@@ -1675,7 +1675,13 @@
 			if (NULL != peer)
 			{
 				pubkey = X509_get_pubkey(peer);
-				SNPRINTF(conn_info->cert_algo, SIZEOF(conn_info->cert_algo), "%s", OBJ_nid2ln(pubkey->type));
+#				if OPENSSL_VERSION_NUMBER >= 0x10000001L
+				SNPRINTF(conn_info->cert_algo, SIZEOF(conn_info->cert_algo), "%s",
+						OBJ_nid2ln(EVP_PKEY_base_id(pubkey)));
+#				else
+				SNPRINTF(conn_info->cert_algo, SIZEOF(conn_info->cert_algo), "%s",
+						OBJ_nid2ln(pubkey->type));
+#				endif
 			} else
 				conn_info->cert_algo[0] = '\0';
 			/* Is Secure Renegotiation Supported? */
--- a/sr_unix/gtmcrypt_dbk_ref.c
+++ b/sr_unix/gtmcrypt_dbk_ref.c
@@ -770,7 +770,7 @@
 int keystore_new_cipher_ctx(gtm_keystore_t *entry, char *iv, int length, int action)
 {
 	int			rv;
-	crypt_key_t		handle;
+	crypt_key_t		handle = NULL;
 	gtm_cipher_ctx_t	*ctx;
 	unsigned char		iv_array[GTMCRYPT_IV_LEN];
 
@@ -809,8 +809,7 @@
 
 	assert(NULL != ctx);
 	status = 0;
-	if (-1 == gc_sym_destroy_cipher_handle(ctx->handle))
-		status = -1;
+	gc_sym_destroy_cipher_handle(ctx->handle);
 	next = ctx->next;
 	prev = ctx->prev;
 	if (NULL != prev)
@@ -888,8 +887,7 @@
 	while (NULL != curr)
 	{
 		temp = curr->next;
-		if (-1 == gc_sym_destroy_cipher_handle(curr->handle))
-			status = -1;
+		gc_sym_destroy_cipher_handle(curr->handle);
 		FREE(curr);
 		curr = temp;
 	}
--- a/sr_unix/gtmcrypt_dbk_ref.h
+++ b/sr_unix/gtmcrypt_dbk_ref.h
@@ -151,7 +151,7 @@
 	struct gtm_keystore_unres_key_link_struct	*next;				/* Pointer to next element. */
 } gtm_keystore_unres_key_link_t;
 
-STATICFNDEF int			keystore_refresh();
+STATICFNDEF int			keystore_refresh(void);
 STATICFNDEF int 		read_files_section(config_t *cfgp);
 STATICFNDEF int 		read_database_section(config_t *cfgp);
 STATICFNDEF int			gtm_keystore_cleanup_node(gtm_keystore_t *);
--- a/sr_unix/gtmcrypt_ref.h
+++ b/sr_unix/gtmcrypt_ref.h
@@ -16,7 +16,7 @@
 # include <openssl/sha.h>
 # include <openssl/evp.h>
 # include <openssl/err.h>
-typedef EVP_CIPHER_CTX		crypt_key_t;
+typedef EVP_CIPHER_CTX		*crypt_key_t;
 #else
 # include <gcrypt.h>
 typedef gcry_cipher_hd_t	crypt_key_t;
--- a/sr_unix/gtmcrypt_sym_ref.c
+++ b/sr_unix/gtmcrypt_sym_ref.c
@@ -67,22 +67,18 @@
  *
  * Arguments:	handle	Encryption / decryption state object to destroy.
  *
- * Returns:	1 if the cipher handle was successfully destroyed; -1 otherwise.
+ * Returns:	N/A neither OpenSSL nor GCrypt destructors return a status.
  */
-int gc_sym_destroy_cipher_handle(crypt_key_t handle)
+void gc_sym_destroy_cipher_handle(crypt_key_t handle)
 {
-#	ifdef USE_OPENSSL
-	if (!EVP_CIPHER_CTX_cleanup(&handle))
-	{
-		GC_APPEND_OPENSSL_ERROR("Failed to destroy encryption key handle.");
-		return -1;
-	}
-#	endif
-#	ifdef USE_GCRYPT
-	if (handle)
+	if (NULL != handle)
+#ifdef USE_OPENSSL
+		EVP_CIPHER_CTX_free(handle);
+#elif defined(USE_GCRYPT)
 		gcry_cipher_close(handle);
-#	endif
-	return 0;
+#else
+	error Encryption library not defined, please use either -DUSE_OPENSSL or -DUSE_GCRYPT
+#endif
 }
 
 /*
@@ -103,11 +99,13 @@
 	int rv, plain_text_length;
 
 #	ifdef USE_OPENSSL
-	if (!reuse)
+	if (NULL == *handle)
+		*handle = EVP_CIPHER_CTX_new();
+	else if (!reuse)
 	{
-		EVP_CIPHER_CTX_init(handle);
+		EVP_CIPHER_CTX_init(*handle);
 	}
-	if (!EVP_CipherInit_ex(handle, ALGO, NULL, raw_key, iv, direction))
+	if (!EVP_CipherInit_ex(*handle, ALGO, NULL, raw_key, iv, direction))
 	{
 		GC_APPEND_OPENSSL_ERROR("Failed to initialize encryption key handle.");
 		return -1;
@@ -168,12 +166,12 @@
 	}
 #	endif
 #	ifdef USE_OPENSSL
-	if (!EVP_CipherUpdate(key, out_block, &out_block_len, in_block, in_block_len))
+	if (!EVP_CipherUpdate(*key, out_block, &out_block_len, in_block, in_block_len))
 	{
 		GC_APPEND_OPENSSL_ERROR("OpenSSL function 'EVP_CipherUpdate' failed.")
 		return -1;
 	}
-	if (!EVP_CipherFinal_ex(key, out_block + out_block_len, &tmp_len))
+	if (!EVP_CipherFinal_ex(*key, out_block + out_block_len, &tmp_len))
 	{
 		GC_APPEND_OPENSSL_ERROR("OpenSSL function 'EVP_CipherFinal_ex' failed.")
 		return -1;
--- a/sr_unix/gtmcrypt_sym_ref.h
+++ b/sr_unix/gtmcrypt_sym_ref.h
@@ -45,6 +45,6 @@
 #endif
 int gc_sym_destroy_key_handles(gtm_keystore_t *entry);
 int gc_sym_create_cipher_handle(unsigned char *raw_key, unsigned char *iv, crypt_key_t *handle, int direction, int reuse);
-int gc_sym_destroy_cipher_handle(crypt_key_t handle);
+void gc_sym_destroy_cipher_handle(crypt_key_t handle);
 int gc_sym_encrypt_decrypt(crypt_key_t *key, unsigned char *in_block, int in_block_len, unsigned char *out_block, int flag);
 #endif /* GTMCRYPT_SYM_REF_H */