Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -53,6 +53,7 @@
import sun.security.util.ConstraintsParameters;
import sun.security.util.Debug;
import sun.security.util.DisabledAlgorithmConstraints;
import sun.security.util.KeyUtil;
import sun.security.validator.Validator;
import sun.security.x509.AlgorithmId;
import sun.security.x509.X509CertImpl;
Expand Down Expand Up @@ -224,7 +225,8 @@ public void check(Certificate cert,
CertPathConstraintsParameters cp =
new CertPathConstraintsParameters(trustedPubKey, variant,
anchor, date);
dac.permits(trustedPubKey.getAlgorithm(), cp, true);
dac.permits(KeyUtil.getAlgorithm(trustedPubKey),
cp, true);
}
// Check the signature algorithm and parameters against constraints
CertPathConstraintsParameters cp =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,18 +35,15 @@
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPathValidatorException.BasicReason;
import java.security.interfaces.ECKey;
import java.security.interfaces.XECKey;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.InvalidParameterSpecException;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.NamedParameterSpec;
import java.security.spec.PSSParameterSpec;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
Expand Down Expand Up @@ -264,7 +261,7 @@ public final void permits(String algorithm, ConstraintsParameters cp,
if (checkKey) {
// Check if named curves in the key are disabled.
for (Key key : cp.getKeys()) {
for (String curve : getNamedCurveFromKey(key)) {
for (String curve : getNamedParametersFromKey(key)) {
if (!cachedCheckAlgorithm(curve)) {
throw new CertPathValidatorException(
"Algorithm constraints check failed on disabled " +
Expand All @@ -278,16 +275,19 @@ public final void permits(String algorithm, ConstraintsParameters cp,
algorithmConstraints.permits(algorithm, cp, checkKey);
}

private static List<String> getNamedCurveFromKey(Key key) {
if (key instanceof ECKey) {
NamedCurve nc = CurveDB.lookup(((ECKey)key).getParams());
return (nc == null ? List.of()
: Arrays.asList(nc.getNameAndAliases()));
} else if (key instanceof XECKey) {
return List.of(
((NamedParameterSpec)((XECKey)key).getParams()).getName());
private static List<String> getNamedParametersFromKey(Key key) {
if (key instanceof ECKey ecKey) {
NamedCurve nc = CurveDB.lookup(ecKey.getParams());
if (nc == null) {
return List.of();
}
return List.of(nc.getNameAndAliases());
} else {
return List.of();
String n = KeyUtil.getAlgorithm(key);
if (n.equalsIgnoreCase(key.getAlgorithm())) {
return List.of(n);
}
return List.of(key.getAlgorithm(), n);
}
}

Expand All @@ -312,12 +312,12 @@ private boolean checkConstraints(Set<CryptoPrimitive> primitives,
}

// check the key algorithm
if (!permits(primitives, key.getAlgorithm(), null)) {
if (!permits(primitives, KeyUtil.getAlgorithm(key), null)) {
return false;
}

// If this is an elliptic curve, check if it is disabled
for (String curve : getNamedCurveFromKey(key)) {
for (String curve : getNamedParametersFromKey(key)) {
if (!permits(primitives, curve, null)) {
return false;
}
Expand Down Expand Up @@ -471,7 +471,7 @@ private List<Constraint> getConstraints(String algorithm) {

// Check if KeySizeConstraints permit the specified key
public boolean permits(Key key) {
List<Constraint> list = getConstraints(key.getAlgorithm());
List<Constraint> list = getConstraints(KeyUtil.getAlgorithm(key));
if (list == null) {
return true;
}
Expand Down Expand Up @@ -525,7 +525,7 @@ public void permits(String algorithm, ConstraintsParameters cp,

if (checkKey) {
for (Key key : cp.getKeys()) {
algorithms.add(key.getAlgorithm());
algorithms.add(KeyUtil.getAlgorithm(key));
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/java.base/share/classes/sun/security/util/KeyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,33 @@ public static final int getKeySize(AlgorithmParameters parameters) {
return -1;
}

/**
* If the key is a sub-algorithm of a larger group of algorithms, this
* method will return that sub-algorithm. For example, key.getAlgorithm()
* returns "EdDSA", but the underlying key may be "Ed448". For
* DisabledAlgorithmConstraints (DAC), this distinction is important.
* "EdDSA" means all curves for DAC, but when using it with
* KeyPairGenerator, "EdDSA" means "Ed25519".
*/
public static String getAlgorithm(Key key) {
/*
if (key instanceof PrivateKey ak &&
ak.getParams() instanceof NamedParameterSpec nps) {
return nps.getName();
} else if (key instanceof PublicKey ak &&
ak.getParams() instanceof NamedParameterSpec nps) {
return nps.getName();
}
*/
if (key instanceof PrivateKey || key instanceof PublicKey) {
AlgorithmParameterSpec params = KeyUtil.getParams(key);
if (params instanceof NamedParameterSpec nps) {
return nps.getName();
}
}
return key.getAlgorithm();
}

/**
* Returns whether the key is valid or not.
* <P>
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/legal/zlib.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## zlib v1.3.2
## zlib v1.4

### zlib License
<pre>
Expand Down
31 changes: 31 additions & 0 deletions src/java.base/share/native/libzip/zlib/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@

ChangeLog file for zlib

Changes in 1.4 (4 Nov 2026)
- Change CMake library names on MSVC
- Return z_off_t default to long for portability
- Fail gzopen() with "x" if O_EXCL not available
- Deliver all gzip data before reporting error
- Fix gzwrite() buffer overflow (CVE-2026-85091)
- Fix inflateGetDictionary() write past buffer on invalid window size
- Fix window write overrun after inflateSync()
- Fix read before provided data after repeated inflatePrime()'s
- Fix write past pending buffer after repeated deflatePrime()'s
- Fix copy of uninitialized memory by inflateBack() on invalid data
- Fix copy of uninitialized memory after gzseek() as first write action
- Fix read outside window after a deflateResetKeep() mid-stream
- Avoid out-of-bounds pointer arithmetic in infback9() (CVE-2026-4738)
- Fix several vulnerabilities in contrib/minizip
- Fix truncated stream detection in gzread()
- Fix pending skip handling in gzread()
- Fix loss of zero fill on repeated gzseek()'s when writing
- Fix inaccurate total_in after Z_NEED_DICT returned
- Detect and report bad deflateSetDictionary() calls
- Avoid undefined behaviors in C language usage
- Fix minizip extra field overflows when almost full and need Zip64
- Don't assume NULL is defined in compress.c and uncompr.c
- Use the generated zconf.h when building test programs out of tree
- Improve portability and functionality of CMake builds
- Provide 64-bit file offsets on Windows with #defines as on Linux
- Improve portability to Android, AIX, PowerPC, s390x, and Windows
- Use a PCG random number generator instead of rand() in minizip
- Clarify documentation
- (See https://github.com/madler/zlib for all 195 commits)

Changes in 1.3.2 (17 Feb 2026)
- Continued rewrite of CMake build [Vollstrecker]
- Various portability improvements
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/native/libzip/zlib/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY

zlib 1.3.2 is a general purpose data compression library. All the code is
zlib 1.4 is a general purpose data compression library. All the code is
thread safe (though see the FAQ for caveats). The data format used by the zlib
library is described by RFCs (Request for Comments) 1950 to 1952 at
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
Expand Down Expand Up @@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://zlib.net/nelson/ .

The changes made in version 1.3.2 are documented in the file ChangeLog.
The changes made in version 1.4 are documented in the file ChangeLog.

Unsupported third party contributions are provided in directory contrib/ .

Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/native/libzip/zlib/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
const uInt max = (uInt)-1;
z_size_t left;

if ((sourceLen > 0 && source == NULL) ||
destLen == NULL || (*destLen > 0 && dest == NULL))
if ((sourceLen > 0 && source == Z_NULL) ||
destLen == Z_NULL || (*destLen > 0 && dest == Z_NULL))
return Z_STREAM_ERROR;

left = *destLen;
Expand Down
Loading
Loading