Skip to content

Commit db6bef7

Browse files
authored
bugfix: avoid extra encoding/decoding PLD params (#10187)
The params and response from the PLD library are being encoded/decoded unnecessarily. Removing this extra processing which is making the password leak check to fail. Change-Id: I7cd4a7baa25677689ea7e4a50f539fff8a035a4c
1 parent 39962cb commit db6bef7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

recaptcha_enterprise/snippets/src/main/java/recaptcha/passwordleak/CreatePasswordLeakAssessment.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.List;
3131
import java.util.concurrent.ExecutionException;
3232
import java.util.stream.Collectors;
33-
import org.bouncycastle.util.encoders.Base64;
3433

3534
public class CreatePasswordLeakAssessment {
3635

@@ -93,9 +92,8 @@ public static void checkPasswordLeak(
9392
PasswordCheckVerification verification =
9493
passwordLeak.createVerification(username, password).get();
9594

96-
byte[] lookupHashPrefix = Base64.encode(verification.getLookupHashPrefix());
97-
byte[] encryptedUserCredentialsHash = Base64.encode(
98-
verification.getEncryptedUserCredentialsHash());
95+
byte[] lookupHashPrefix = verification.getLookupHashPrefix();
96+
byte[] encryptedUserCredentialsHash = verification.getEncryptedUserCredentialsHash();
9997

10098
// Pass the credentials to the createPasswordLeakAssessment() to get back
10199
// the matching database entry for the hash prefix.
@@ -108,15 +106,15 @@ public static void checkPasswordLeak(
108106
// Convert to appropriate input format.
109107
List<byte[]> leakMatchPrefixes =
110108
credentials.getEncryptedLeakMatchPrefixesList().stream()
111-
.map(x -> Base64.decode(x.toByteArray()))
109+
.map(x -> x.toByteArray())
112110
.collect(Collectors.toList());
113111

114112
// Verify if the encrypted credentials are present in the obtained match list.
115113
PasswordCheckResult result =
116114
passwordLeak
117115
.verify(
118116
verification,
119-
Base64.decode(credentials.getReencryptedUserCredentialsHash().toByteArray()),
117+
credentials.getReencryptedUserCredentialsHash().toByteArray(),
120118
leakMatchPrefixes)
121119
.get();
122120

recaptcha_enterprise/snippets/src/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>com.google.cloud.samples</groupId>
1616
<artifactId>shared-configuration</artifactId>
17-
<version>1.2.0</version>
17+
<version>1.2.2</version>
1818
</parent>
1919

2020
<properties>

0 commit comments

Comments
 (0)