[balsa] Fix build against openssl-1.1.0



commit 2884d337a44649576235f6b8b81ed10dbfe0f135
Author: Pawel Salek <pawsa0 gmail com>
Date:   Sat Dec 10 21:23:40 2016 +0100

    Fix build against openssl-1.1.0

 ChangeLog                 |    7 +++++++
 Makefile.am               |    3 +--
 libbalsa/imap/auth-cram.c |   26 ++++++++++++++------------
 libbalsa/imap/pop3.c      |   11 ++++++-----
 4 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b2f7122..616ebf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-12-10  Pawel Salek <pawsa0 gmail com>
+
+       * Makefile.am: do not include mkinstalldirs any more
+       * libbalsa/imap/auth-cram.c:
+       * libbalsa/imap/pop3.c:  fix regression in CRAM-MD5 code; build against
+       openssl-1.1.0
+
 2016-12-09  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Version bump to 2.5.3
diff --git a/Makefile.am b/Makefile.am
index 08e5a4e..51591d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,8 +31,7 @@ balsa_extra_dist =            \
        gnome-balsa2.png        \
        intltool-extract.in     \
        intltool-merge.in       \
-       intltool-update.in      \
-       mkinstalldirs
+       intltool-update.in
 
 EXTRA_DIST =                   \
     $(balsa_extra_dist)
diff --git a/libbalsa/imap/auth-cram.c b/libbalsa/imap/auth-cram.c
index 62e076a..c29d327 100644
--- a/libbalsa/imap/auth-cram.c
+++ b/libbalsa/imap/auth-cram.c
@@ -131,7 +131,7 @@ static void
 hmac_md5 (const char* password, char* challenge,
           unsigned char* response)
 {  
-  EVP_MD_CTX ctx;
+  EVP_MD_CTX *ctx = EVP_MD_CTX_create();
   unsigned char ipad[MD5_BLOCK_LEN], opad[MD5_BLOCK_LEN];
   unsigned char secret[MD5_BLOCK_LEN+1];
   unsigned int secret_len, chal_len;
@@ -143,9 +143,9 @@ hmac_md5 (const char* password, char* challenge,
   /* passwords longer than MD5_BLOCK_LEN bytes are substituted with their MD5
    * digests */
   if (secret_len > MD5_BLOCK_LEN) {
-       EVP_DigestInit(&ctx, EVP_md5());
-       EVP_DigestUpdate(&ctx, (const unsigned char*) password, secret_len);
-       EVP_DigestFinal(&ctx, secret, &secret_len);
+       EVP_DigestInit(ctx, EVP_md5());
+       EVP_DigestUpdate(ctx, (const unsigned char*) password, secret_len);
+       EVP_DigestFinal(ctx, secret, &secret_len);
   }
   else
     strncpy ((char *) secret, password, sizeof (secret));
@@ -161,14 +161,16 @@ hmac_md5 (const char* password, char* challenge,
   }
 
   /* inner hash: challenge and ipadded secret */
-  EVP_DigestInit(&ctx, EVP_md5());
-  EVP_DigestUpdate(&ctx, ipad, MD5_BLOCK_LEN);
-  EVP_DigestUpdate(&ctx, (unsigned char*) challenge, chal_len);
-  EVP_DigestFinal(&ctx, response, NULL);
+  EVP_DigestInit(ctx, EVP_md5());
+  EVP_DigestUpdate(ctx, ipad, MD5_BLOCK_LEN);
+  EVP_DigestUpdate(ctx, (unsigned char*) challenge, chal_len);
+  EVP_DigestFinal(ctx, response, NULL);
 
   /* outer hash: inner hash and opadded secret */
-  EVP_DigestInit(&ctx, EVP_md5());
-  EVP_DigestUpdate(&ctx, opad, MD5_BLOCK_LEN);
-  EVP_DigestUpdate(&ctx, response, chal_len);
-  EVP_DigestFinal(&ctx, response, NULL);
+  EVP_DigestInit(ctx, EVP_md5());
+  EVP_DigestUpdate(ctx, opad, MD5_BLOCK_LEN);
+  EVP_DigestUpdate(ctx, response, MD5_DIGEST_LEN);
+  EVP_DigestFinal(ctx, response, NULL);
+
+  EVP_MD_CTX_destroy(ctx);
 }
diff --git a/libbalsa/imap/pop3.c b/libbalsa/imap/pop3.c
index 5cb6dd5..a72ce61 100644
--- a/libbalsa/imap/pop3.c
+++ b/libbalsa/imap/pop3.c
@@ -310,16 +310,17 @@ get_apop_stamp(const char *greeting, char *stamp)
 static void
 compute_auth_hash(char *stamp, char *hash, const char *passwd)
 {
-  EVP_MD_CTX ctx;
+  EVP_MD_CTX* ctx = EVP_MD_CTX_create();
   register unsigned char *dp;
   register char *cp;
   unsigned char *ep;
   unsigned char digest[16];
   
-  EVP_DigestInit(&ctx, EVP_md5());
-  EVP_DigestUpdate(&ctx, stamp, strlen(stamp));
-  EVP_DigestUpdate(&ctx, passwd, strlen(passwd));
-  EVP_DigestFinal(&ctx, digest, NULL);
+  EVP_DigestInit(ctx, EVP_md5());
+  EVP_DigestUpdate(ctx, stamp, strlen(stamp));
+  EVP_DigestUpdate(ctx, passwd, strlen(passwd));
+  EVP_DigestFinal(ctx, digest, NULL);
+  EVP_MD_CTX_destroy(ctx);
   
   cp = hash;
   dp = digest;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]