Blame SOURCES/cyrus-sasl-2.1.27-cumulative-ossl3.patch

8b8af0
diff -uPr cyrus-sasl-2.1.27/configure.ac cyrus-sasl-2.1.27.ossl3/configure.ac
8b8af0
--- cyrus-sasl-2.1.27/configure.ac	2021-10-06 11:29:53.274375206 -0400
8b8af0
+++ cyrus-sasl-2.1.27.ossl3/configure.ac	2021-10-06 11:31:19.966726775 -0400
8b8af0
@@ -1115,7 +1115,11 @@
8b8af0
 	with_rc4=yes)
8b8af0
 
8b8af0
 if test "$with_rc4" != no; then
8b8af0
-    AC_DEFINE(WITH_RC4,[],[Use RC4])
8b8af0
+    if test "$with_openssl" = no; then
8b8af0
+        AC_WARN([OpenSSL not found -- RC4 will be disabled])
8b8af0
+    else
8b8af0
+        AC_DEFINE(WITH_RC4,[],[Use RC4])
8b8af0
+    fi
8b8af0
 fi
8b8af0
 
8b8af0
 building_for_macosx=no
8b8af0
diff -uPr cyrus-sasl-2.1.27/plugins/scram.c cyrus-sasl-2.1.27.ossl3/plugins/scram.c
8b8af0
--- cyrus-sasl-2.1.27/plugins/scram.c	2018-11-08 12:29:57.000000000 -0500
8b8af0
+++ cyrus-sasl-2.1.27.ossl3/plugins/scram.c	2021-10-06 11:31:04.407484201 -0400
8b8af0
@@ -65,7 +65,9 @@
8b8af0
 
8b8af0
 #include <openssl/sha.h>
8b8af0
 #include <openssl/evp.h>
8b8af0
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
8b8af0
 #include <openssl/hmac.h>
8b8af0
+#endif
8b8af0
 
8b8af0
 /*****************************  Common Section  *****************************/
8b8af0
 
8b8af0
@@ -267,6 +271,32 @@
8b8af0
 }
8b8af0
 #endif
8b8af0
 
8b8af0
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
8b8af0
+
8b8af0
+/* Decalre as void given functions never use the result */
8b8af0
+void *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
8b8af0
+                     const unsigned char *data, size_t data_len,
8b8af0
+                     unsigned char *md, unsigned int *md_len)
8b8af0
+{
8b8af0
+    const char *digest;
8b8af0
+    size_t digest_size;
8b8af0
+    size_t out_len;
8b8af0
+    void *ret = NULL;
8b8af0
+
8b8af0
+    digest = EVP_MD_get0_name(evp_md);
8b8af0
+    if (digest == NULL) {
8b8af0
+        return NULL;
8b8af0
+    }
8b8af0
+    digest_size = EVP_MD_size(evp_md);
8b8af0
+
8b8af0
+    ret = EVP_Q_mac(NULL, "hmac", NULL, digest, NULL, key, key_len,
8b8af0
+                    data, data_len, md, digest_size, &out_len);
8b8af0
+    if (ret != NULL) {
8b8af0
+        *md_len = (unsigned int)out_len;
8b8af0
+    }
8b8af0
+    return ret;
8b8af0
+}
8b8af0
+#endif
8b8af0
 
8b8af0
 /* The result variable need to point to a buffer big enough for the [SHA-1] hash */
8b8af0
 static void
8b8af0
diff -uPr cyrus-sasl-2.1.27/saslauthd/lak.c cyrus-sasl-2.1.27.ossl3/saslauthd/lak.c
8b8af0
--- cyrus-sasl-2.1.27/saslauthd/lak.c	2022-01-09 11:30:50.000000000 -0400
8b8af0
+++ cyrus-sasl-2.1.27.ossl3/saslauthd/lak.c	2022-01-09 11:30:50.000000001 -0400
8b8af0
@@ -1806,18 +1806,36 @@
8b8af0
 		return rc;
8b8af0
 	}
8b8af0
 
8b8af0
-	EVP_DigestInit(mdctx, md);
8b8af0
-	EVP_DigestUpdate(mdctx, passwd, strlen(passwd));
8b8af0
+	rc = EVP_DigestInit(mdctx, md);
8b8af0
+	if (rc != 1) {
8b8af0
+		rc = LAK_FAIL;
8b8af0
+		goto done;
8b8af0
+	}
8b8af0
+	rc = EVP_DigestUpdate(mdctx, passwd, strlen(passwd));
8b8af0
+	if (rc != 1) {
8b8af0
+		rc = LAK_FAIL;
8b8af0
+		goto done;
8b8af0
+	}
8b8af0
 	if (hrock->salted) {
8b8af0
-		EVP_DigestUpdate(mdctx, &cred[EVP_MD_size(md)],
8b8af0
-				 clen - EVP_MD_size(md));
8b8af0
+		rc = EVP_DigestUpdate(mdctx, &cred[EVP_MD_size(md)],
8b8af0
+				      clen - EVP_MD_size(md));
8b8af0
+		if (rc != 1) {
8b8af0
+		    rc = LAK_FAIL;
8b8af0
+		    goto done;
8b8af0
+		}
8b8af0
+	}
8b8af0
+	rc = EVP_DigestFinal(mdctx, digest, NULL);
8b8af0
+	if (rc != 1) {
8b8af0
+		rc = LAK_FAIL;
8b8af0
+		goto done;
8b8af0
 	}
8b8af0
-	EVP_DigestFinal(mdctx, digest, NULL);
8b8af0
-	EVP_MD_CTX_free(mdctx);
8b8af0
 
8b8af0
 	rc = memcmp((char *)cred, (char *)digest, EVP_MD_size(md));
8b8af0
+	rc = rc ? LAK_INVALID_PASSWORD : LAK_OK;
8b8af0
+done:
8b8af0
+	EVP_MD_CTX_free(mdctx);
8b8af0
 	free(cred);
8b8af0
-	return rc ? LAK_INVALID_PASSWORD : LAK_OK;
8b8af0
+	return rc;
8b8af0
 }
8b8af0
 
8b8af0
 #endif /* HAVE_OPENSSL */