]> git.pld-linux.org Git - packages/gssntlmssp.git/blob - gssntlmssp-openssl1.1.patch
5928b487d6bc1b55366c1b98396dfea262510eb5
[packages/gssntlmssp.git] / gssntlmssp-openssl1.1.patch
1 From e498737a96e8832a2cb9141ab1fe51e129185a48 Mon Sep 17 00:00:00 2001
2 From: Simo Sorce <simo@redhat.com>
3 Date: Wed, 29 Jun 2016 11:15:11 -0400
4 Subject: [PATCH] Add compatibility with OpenSSL 1.1.0
5
6 In their continued wisdom OpenSSL developers keep breaking APIs left and right
7 with very poor documentation and forward/backward source compatibility.
8
9 Signed-off-by: Simo Sorce <simo@redhat.com>
10 ---
11  src/crypto.c | 60 +++++++++++++++++++++++++++++++++++++++++-----------
12  1 file changed, 48 insertions(+), 12 deletions(-)
13
14 diff --git a/src/crypto.c b/src/crypto.c
15 index 9fe69f9..33a0c3e 100644
16 --- a/src/crypto.c
17 +++ b/src/crypto.c
18 @@ -27,6 +27,32 @@
19  
20  #include "crypto.h"
21  
22 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
23 +HMAC_CTX *HMAC_CTX_new(void)
24 +{
25 +    HMAC_CTX *ctx;
26 +
27 +    ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
28 +    if (!ctx) return NULL;
29 +
30 +    HMAC_CTX_init(ctx);
31 +
32 +    return ctx;
33 +}
34 +
35 +void HMAC_CTX_free(HMAC_CTX *ctx)
36 +{
37 +    if (ctx == NULL) return;
38 +
39 +    HMAC_CTX_cleanup(ctx);
40 +    OPENSSL_free(ctx);
41 +}
42 +
43 +#define EVP_MD_CTX_new EVP_MD_CTX_create
44 +#define EVP_MD_CTX_free EVP_MD_CTX_destroy
45 +
46 +#endif
47 +
48  int RAND_BUFFER(struct ntlm_buffer *random)
49  {
50      int ret;
51 @@ -42,30 +68,34 @@ int HMAC_MD5_IOV(struct ntlm_buffer *key,
52                   struct ntlm_iov *iov,
53                   struct ntlm_buffer *result)
54  {
55 -    HMAC_CTX hmac_ctx;
56 +    HMAC_CTX *hmac_ctx;
57      unsigned int len;
58      size_t i;
59      int ret = 0;
60  
61      if (result->length != 16) return EINVAL;
62  
63 -    HMAC_CTX_init(&hmac_ctx);
64 +    hmac_ctx = HMAC_CTX_new();
65 +    if (!hmac_ctx) {
66 +        ret = ERR_CRYPTO;
67 +        goto done;
68 +    }
69  
70 -    ret = HMAC_Init_ex(&hmac_ctx, key->data, key->length, EVP_md5(), NULL);
71 +    ret = HMAC_Init_ex(hmac_ctx, key->data, key->length, EVP_md5(), NULL);
72      if (ret == 0) {
73          ret = ERR_CRYPTO;
74          goto done;
75      }
76  
77      for (i = 0; i < iov->num; i++) {
78 -        ret = HMAC_Update(&hmac_ctx, iov->data[i]->data, iov->data[i]->length);
79 +        ret = HMAC_Update(hmac_ctx, iov->data[i]->data, iov->data[i]->length);
80          if (ret == 0) {
81              ret = ERR_CRYPTO;
82              goto done;
83          }
84      }
85  
86 -    ret = HMAC_Final(&hmac_ctx, result->data, &len);
87 +    ret = HMAC_Final(hmac_ctx, result->data, &len);
88      if (ret == 0) {
89          ret = ERR_CRYPTO;
90          goto done;
91 @@ -74,7 +104,7 @@ int HMAC_MD5_IOV(struct ntlm_buffer *key,
92      ret = 0;
93  
94  done:
95 -    HMAC_CTX_cleanup(&hmac_ctx);
96 +    HMAC_CTX_free(hmac_ctx);
97      return ret;
98  }
99  
100 @@ -93,26 +123,32 @@ static int mdx_hash(const EVP_MD *type,
101                      struct ntlm_buffer *payload,
102                      struct ntlm_buffer *result)
103  {
104 -    EVP_MD_CTX ctx;
105 +    EVP_MD_CTX *ctx;
106      unsigned int len;
107      int ret;
108  
109      if (result->length != 16) return EINVAL;
110  
111 -    EVP_MD_CTX_init(&ctx);
112 -    ret = EVP_DigestInit_ex(&ctx, type, NULL);
113 +    ctx = EVP_MD_CTX_new();
114 +    if (!ctx) {
115 +        ret = ERR_CRYPTO;
116 +        goto done;
117 +    }
118 +
119 +    EVP_MD_CTX_init(ctx);
120 +    ret = EVP_DigestInit_ex(ctx, type, NULL);
121      if (ret == 0) {
122          ret = ERR_CRYPTO;
123          goto done;
124      }
125  
126 -    ret = EVP_DigestUpdate(&ctx, payload->data, payload->length);
127 +    ret = EVP_DigestUpdate(ctx, payload->data, payload->length);
128      if (ret == 0) {
129          ret = ERR_CRYPTO;
130          goto done;
131      }
132  
133 -    ret = EVP_DigestFinal_ex(&ctx, result->data, &len);
134 +    ret = EVP_DigestFinal_ex(ctx, result->data, &len);
135      if (ret == 0) {
136          ret = ERR_CRYPTO;
137          goto done;
138 @@ -121,7 +157,7 @@ static int mdx_hash(const EVP_MD *type,
139      ret = 0;
140  
141  done:
142 -    EVP_MD_CTX_cleanup(&ctx);
143 +    if (ctx) EVP_MD_CTX_free(ctx);
144      return ret;
145  }
146  
This page took 0.068974 seconds and 2 git commands to generate.