mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-17 14:38:55 +00:00
8386600: Fix comparison checks in DHasKEM
Reviewed-by: mullan
This commit is contained in:
parent
e1ec755882
commit
95be3f9520
@ -268,17 +268,17 @@ public class DHasKEM implements KEMSpi {
|
||||
|
||||
// RFC 8446 section 7.4.2: checks for all-zero
|
||||
// X25519/X448 shared secret.
|
||||
if (kaAlgorithm.equals("X25519") ||
|
||||
kaAlgorithm.equals("X448")) {
|
||||
if (this == X25519 || this == X448) {
|
||||
byte[] s = secret.getEncoded();
|
||||
byte data = 0;
|
||||
for (byte b : s) {
|
||||
if (b != 0) {
|
||||
return secret;
|
||||
}
|
||||
data |= b;
|
||||
}
|
||||
if (data == 0) {
|
||||
// Trigger ILLEGAL_PARAMETER alert
|
||||
throw new IllegalArgumentException(
|
||||
"All-zero shared secret");
|
||||
}
|
||||
// Trigger ILLEGAL_PARAMETER alert
|
||||
throw new IllegalArgumentException(
|
||||
"All-zero shared secret");
|
||||
}
|
||||
|
||||
return secret;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user