Control: tags 977683 + patch
Control: tags 977683 + pending

Dear maintainer,
X-Debbugs-CC'ing as well Markus Koschany.

I've prepared an NMU for bouncycastle (versioned as 1.65-1.1) and
uploaded it to DELAYED/5. Please feel free to tell me if I
should delay it longer. Alternatively feel free to as well just
direclty reject it and do a maintainer upload (which anyway is
preferable).

The issue only affects bullseye and unstable, and it should be fixed
in time before the freeze ideally.

Regards,
Salvatore
diff -Nru bouncycastle-1.65/debian/changelog bouncycastle-1.65/debian/changelog
--- bouncycastle-1.65/debian/changelog	2020-05-11 00:05:37.000000000 +0200
+++ bouncycastle-1.65/debian/changelog	2021-01-03 21:12:39.000000000 +0100
@@ -1,3 +1,10 @@
+bouncycastle (1.65-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Corrected constant time equals (CVE-2020-28052) (Closes: #977683)
+
+ -- Salvatore Bonaccorso <car...@debian.org>  Sun, 03 Jan 2021 21:12:39 +0100
+
 bouncycastle (1.65-1) unstable; urgency=medium
 
   * Team upload.
diff -Nru bouncycastle-1.65/debian/patches/corrected-constant-time-equals.patch bouncycastle-1.65/debian/patches/corrected-constant-time-equals.patch
--- bouncycastle-1.65/debian/patches/corrected-constant-time-equals.patch	1970-01-01 01:00:00.000000000 +0100
+++ bouncycastle-1.65/debian/patches/corrected-constant-time-equals.patch	2021-01-03 21:10:00.000000000 +0100
@@ -0,0 +1,65 @@
+From: David Hook <d...@cryptoworkshop.com>
+Date: Wed, 28 Oct 2020 09:37:17 +1100
+Subject: corrected constant time equals.
+Origin: https://github.com/bcgit/bc-java/commit/97578f9b7ed277e6ecb58834e85e3d18385a4219
+Bug-Debian: https://bugs.debian.org/977683
+Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2020-28052
+
+---
+ .../crypto/generators/OpenBSDBCrypt.java      |  2 +-
+ .../crypto/test/OpenBSDBCryptTest.java        | 20 +++++++++++++++++++
+ 2 files changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/core/src/main/java/org/bouncycastle/crypto/generators/OpenBSDBCrypt.java b/core/src/main/java/org/bouncycastle/crypto/generators/OpenBSDBCrypt.java
+index 64391ea039f3..4f3235e629fc 100644
+--- a/core/src/main/java/org/bouncycastle/crypto/generators/OpenBSDBCrypt.java
++++ b/core/src/main/java/org/bouncycastle/crypto/generators/OpenBSDBCrypt.java
+@@ -309,7 +309,7 @@ private static boolean doCheckPassword(
+         boolean isEqual = sLength == newBcryptString.length();
+         for (int i = 0; i != sLength; i++)
+         {
+-            isEqual &= (bcryptString.indexOf(i) == newBcryptString.indexOf(i));
++            isEqual &= (bcryptString.charAt(i) == newBcryptString.charAt(i));
+         }
+         return isEqual;
+     }
+diff --git a/core/src/test/java/org/bouncycastle/crypto/test/OpenBSDBCryptTest.java b/core/src/test/java/org/bouncycastle/crypto/test/OpenBSDBCryptTest.java
+index 8ccb679d88b4..8453d2fdb8a5 100644
+--- a/core/src/test/java/org/bouncycastle/crypto/test/OpenBSDBCryptTest.java
++++ b/core/src/test/java/org/bouncycastle/crypto/test/OpenBSDBCryptTest.java
+@@ -1,5 +1,7 @@
+ package org.bouncycastle.crypto.test;
+ 
++import java.security.SecureRandom;
++
+ import org.bouncycastle.crypto.generators.OpenBSDBCrypt;
+ import org.bouncycastle.util.Strings;
+ import org.bouncycastle.util.test.SimpleTest;
+@@ -199,6 +201,24 @@ public void performTest()
+                 fail("twoBVec mismatch: " + "[" + i + "] " + password);
+             }
+         }
++
++
++        int costFactor = 4;
++        SecureRandom random = new SecureRandom();
++        salt = new byte[16];
++        for (int i = 0; i < 1000; i++)
++        {
++            random.nextBytes(salt);
++            final String tokenString = OpenBSDBCrypt
++                .generate("test-token".toCharArray(), salt, costFactor);
++
++            isTrue(OpenBSDBCrypt.checkPassword(tokenString, "test-token".toCharArray()));
++            isTrue(!OpenBSDBCrypt.checkPassword(tokenString, "wrong-token".toCharArray()));
++        }
+     }
++
++
++
++
+ }
+ 
+-- 
+2.30.0
+
diff -Nru bouncycastle-1.65/debian/patches/series bouncycastle-1.65/debian/patches/series
--- bouncycastle-1.65/debian/patches/series	2020-05-08 23:28:01.000000000 +0200
+++ bouncycastle-1.65/debian/patches/series	2021-01-03 21:11:52.000000000 +0100
@@ -1,3 +1,4 @@
 02_index.patch
 fix-encoding.patch
 backward-compatibility.patch
+corrected-constant-time-equals.patch

Reply via email to