diff --git a/make/data/cacerts/entrustevca b/make/data/cacerts/entrustevca
deleted file mode 100644
index 6c2c50968b96..000000000000
--- a/make/data/cacerts/entrustevca
+++ /dev/null
@@ -1,34 +0,0 @@
-Owner: CN=Entrust Root Certification Authority, OU="(c) 2006 Entrust, Inc.", OU=www.entrust.net/CPS is incorporated by reference, O="Entrust, Inc.", C=US
-Issuer: CN=Entrust Root Certification Authority, OU="(c) 2006 Entrust, Inc.", OU=www.entrust.net/CPS is incorporated by reference, O="Entrust, Inc.", C=US
-Serial number: 456b5054
-Valid from: Mon Nov 27 20:23:42 GMT 2006 until: Fri Nov 27 20:53:42 GMT 2026
-Signature algorithm name: SHA1withRSA
-Subject Public Key Algorithm: 2048-bit RSA key
-Version: 3
------BEGIN CERTIFICATE-----
-MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC
-VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0
-Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW
-KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl
-cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw
-NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw
-NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy
-ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV
-BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ
-KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo
-Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4
-4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9
-KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI
-rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi
-94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB
-sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi
-gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo
-kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE
-vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
-A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t
-O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua
-AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP
-9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/
-eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m
-0vdXcDazv/wor3ElhVsT/h5/WrQ8
------END CERTIFICATE-----
diff --git a/src/java.base/share/classes/java/lang/StringLatin1.java b/src/java.base/share/classes/java/lang/StringLatin1.java
index 726e51322d07..ca3b0bb4b5db 100644
--- a/src/java.base/share/classes/java/lang/StringLatin1.java
+++ b/src/java.base/share/classes/java/lang/StringLatin1.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
diff --git a/src/java.base/share/classes/java/lang/invoke/VarHandles.java b/src/java.base/share/classes/java/lang/invoke/VarHandles.java
index 97d53c7bbb03..81ee9ad3ab51 100644
--- a/src/java.base/share/classes/java/lang/invoke/VarHandles.java
+++ b/src/java.base/share/classes/java/lang/invoke/VarHandles.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -201,7 +201,7 @@ static VarHandle makeArrayElementHandle(Class> arrayClass) {
Class> componentType = arrayClass.getComponentType();
- int aoffset = UNSAFE.arrayBaseOffset(arrayClass);
+ int aoffset = (int) UNSAFE.arrayBaseOffset(arrayClass);
int ascale = UNSAFE.arrayIndexScale(arrayClass);
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);
diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 71c59d3ae17a..fce4c751c5da 100644
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
@@ -6363,7 +6363,7 @@ public final void compute() {
= U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy");
private static final long CELLVALUE
= U.objectFieldOffset(CounterCell.class, "value");
- private static final int ABASE = U.arrayBaseOffset(Node[].class);
+ private static final long ABASE = U.arrayBaseOffset(Node[].class);
private static final int ASHIFT;
static {
diff --git a/src/java.base/share/classes/java/util/zip/CRC32C.java b/src/java.base/share/classes/java/util/zip/CRC32C.java
index fa138d4d3f65..e629950819a2 100644
--- a/src/java.base/share/classes/java/util/zip/CRC32C.java
+++ b/src/java.base/share/classes/java/util/zip/CRC32C.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -219,9 +219,9 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
// align on 8 bytes
- int alignLength
+ long alignLength
= (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
- for (int alignEnd = off + alignLength; off < alignEnd; off++) {
+ for (long alignEnd = off + alignLength; off < alignEnd; off++) {
crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
}
@@ -235,11 +235,11 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
int secondHalf;
if (Unsafe.ADDRESS_SIZE == 4) {
// On 32 bit platforms read two ints instead of a single 64bit long
- firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
- secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
+ secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ Integer.BYTES);
} else {
- long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
+ long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
firstHalf = (int) value;
secondHalf = (int) (value >>> 32);
diff --git a/src/java.base/share/classes/java/util/zip/ZipUtils.java b/src/java.base/share/classes/java/util/zip/ZipUtils.java
index b33d8b31d8c4..2424434cac50 100644
--- a/src/java.base/share/classes/java/util/zip/ZipUtils.java
+++ b/src/java.base/share/classes/java/util/zip/ZipUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
diff --git a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
index 910b5864f73b..849f63f387c1 100644
--- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
+++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -1037,8 +1037,11 @@ private void checkWritebackEnabled() {
* This constant differs from all results that will ever be returned from
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
* or {@link #arrayBaseOffset}.
+ *
+ * The static type is @code long} to emphasize that long arithmetic should
+ * always be used for offset calculations to avoid overflows.
*/
- public static final int INVALID_FIELD_OFFSET = -1;
+ public static final long INVALID_FIELD_OFFSET = -1;
/**
* Reports the location of a given field in the storage allocation of its
@@ -1161,11 +1164,15 @@ public void ensureClassInitialized(Class> c) {
* for the same class, you may use that scale factor, together with this
* base offset, to form new offsets to access elements of arrays of the
* given class.
+ *
+ * The return value is in the range of a {@code int}. The return type is
+ * {@code long} to emphasize that long arithmetic should always be used
+ * for offset calculations to avoid overflows.
*
* @see #getInt(Object, long)
* @see #putInt(Object, long, int)
*/
- public int arrayBaseOffset(Class> arrayClass) {
+ public long arrayBaseOffset(Class> arrayClass) {
if (arrayClass == null) {
throw new NullPointerException();
}
@@ -1175,39 +1182,39 @@ public int arrayBaseOffset(Class> arrayClass) {
/** The value of {@code arrayBaseOffset(boolean[].class)} */
- public static final int ARRAY_BOOLEAN_BASE_OFFSET
+ public static final long ARRAY_BOOLEAN_BASE_OFFSET
= theUnsafe.arrayBaseOffset(boolean[].class);
/** The value of {@code arrayBaseOffset(byte[].class)} */
- public static final int ARRAY_BYTE_BASE_OFFSET
+ public static final long ARRAY_BYTE_BASE_OFFSET
= theUnsafe.arrayBaseOffset(byte[].class);
/** The value of {@code arrayBaseOffset(short[].class)} */
- public static final int ARRAY_SHORT_BASE_OFFSET
+ public static final long ARRAY_SHORT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(short[].class);
/** The value of {@code arrayBaseOffset(char[].class)} */
- public static final int ARRAY_CHAR_BASE_OFFSET
+ public static final long ARRAY_CHAR_BASE_OFFSET
= theUnsafe.arrayBaseOffset(char[].class);
/** The value of {@code arrayBaseOffset(int[].class)} */
- public static final int ARRAY_INT_BASE_OFFSET
+ public static final long ARRAY_INT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(int[].class);
/** The value of {@code arrayBaseOffset(long[].class)} */
- public static final int ARRAY_LONG_BASE_OFFSET
+ public static final long ARRAY_LONG_BASE_OFFSET
= theUnsafe.arrayBaseOffset(long[].class);
/** The value of {@code arrayBaseOffset(float[].class)} */
- public static final int ARRAY_FLOAT_BASE_OFFSET
+ public static final long ARRAY_FLOAT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(float[].class);
/** The value of {@code arrayBaseOffset(double[].class)} */
- public static final int ARRAY_DOUBLE_BASE_OFFSET
+ public static final long ARRAY_DOUBLE_BASE_OFFSET
= theUnsafe.arrayBaseOffset(double[].class);
/** The value of {@code arrayBaseOffset(Object[].class)} */
- public static final int ARRAY_OBJECT_BASE_OFFSET
+ public static final long ARRAY_OBJECT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(Object[].class);
/**
@@ -1216,6 +1223,9 @@ public int arrayBaseOffset(Class> arrayClass) {
* will generally not work properly with accessors like {@link
* #getByte(Object, long)}, so the scale factor for such classes is reported
* as zero.
+ *
+ * The computation of the actual memory offset should always use {@code
+ * long} arithmetic to avoid overflows.
*
* @see #arrayBaseOffset
* @see #getInt(Object, long)
@@ -3823,7 +3833,7 @@ private void putShortParts(Object o, long offset, byte i0, byte i1) {
private native Object staticFieldBase0(Field f);
private native boolean shouldBeInitialized0(Class> c);
private native void ensureClassInitialized0(Class> c);
- private native int arrayBaseOffset0(Class> arrayClass);
+ private native int arrayBaseOffset0(Class> arrayClass); // public version returns long to promote correct arithmetic
private native int arrayIndexScale0(Class> arrayClass);
private native int getLoadAverage0(double[] loadavg, int nelems);
// SapMachine 2025-02-05: Report error for DirectMemoryOom to exit the VM
diff --git a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
index b09dbdfe493a..f1c9f231c4f7 100644
--- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
+++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java
@@ -192,8 +192,8 @@ public static int mismatch(boolean[] a, int aFromIndex,
if (length > 7) {
if (a[aFromIndex] != b[bFromIndex])
return 0;
- int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
- int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
+ long aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
+ long bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
i = vectorizedMismatch(
a, aOffset,
b, bOffset,
@@ -285,8 +285,8 @@ public static int mismatch(byte[] a, int aFromIndex,
if (length > 7) {
if (a[aFromIndex] != b[bFromIndex])
return 0;
- int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
- int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
+ long aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
+ long bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
i = vectorizedMismatch(
a, aOffset,
b, bOffset,
diff --git a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
index 977bf88292c7..3718a174f212 100644
--- a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
+++ b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -551,8 +551,23 @@ public void encodeSignedData(DerOutputStream out)
* @exception SignatureException on signature handling errors.
*/
public SignerInfo verify(SignerInfo info, byte[] bytes)
- throws NoSuchAlgorithmException, SignatureException {
- return info.verify(this, bytes);
+ throws NoSuchAlgorithmException, SignatureException {
+ return info.verify(this, bytes, null);
+ }
+
+ /**
+ * This verifies a given SignerInfo.
+ *
+ * @param info the signer information.
+ * @param bytes the DER encoded content information.
+ * @param cert certificate used to verify; find one inside the block if null
+ *
+ * @exception NoSuchAlgorithmException on unrecognized algorithms.
+ * @exception SignatureException on signature handling errors.
+ */
+ public SignerInfo verify(SignerInfo info, byte[] bytes, X509Certificate cert)
+ throws NoSuchAlgorithmException, SignatureException {
+ return info.verify(this, bytes, cert);
}
/**
@@ -750,6 +765,19 @@ public boolean isOldStyle() {
return this.oldStyle;
}
+ // Generate signed data without a specified digAlgID.
+ public static byte[] generateNewSignedData(
+ String sigalg, Provider sigProvider,
+ PrivateKey privateKey, X509Certificate[] signerChain,
+ byte[] content, boolean internalsf, boolean directsign,
+ Function ts)
+ throws SignatureException, InvalidKeyException, IOException,
+ NoSuchAlgorithmException {
+ return generateSignedData(sigalg, sigProvider, privateKey, signerChain,
+ content, internalsf, directsign,
+ null, ts);
+ }
+
/**
* Generate a PKCS7 data block.
*
@@ -760,6 +788,7 @@ public boolean isOldStyle() {
* @param content the content to sign
* @param internalsf whether the content should be include in output
* @param directsign if the content is signed directly or thru authattrs
+ * @param digAlgID digest alg to use; derive from other arguments if null
* @param ts (optional) timestamper
* @return the pkcs7 output in an array
* @throws SignatureException if signing failed
@@ -767,18 +796,21 @@ public boolean isOldStyle() {
* @throws IOException should not happen here, all byte array
* @throws NoSuchAlgorithmException if siglag is bad
*/
- public static byte[] generateNewSignedData(
+ public static byte[] generateSignedData(
String sigalg, Provider sigProvider,
PrivateKey privateKey, X509Certificate[] signerChain,
byte[] content, boolean internalsf, boolean directsign,
+ AlgorithmId digAlgID,
Function ts)
throws SignatureException, InvalidKeyException, IOException,
NoSuchAlgorithmException {
Signature signer = SignatureUtil.fromKey(sigalg, privateKey, sigProvider);
- AlgorithmId digAlgID = SignatureUtil.getDigestAlgInPkcs7SignerInfo(
- signer, sigalg, privateKey, directsign);
+ if (digAlgID == null) {
+ digAlgID = SignatureUtil.getDigestAlgInPkcs7SignerInfo(
+ signer, sigalg, privateKey, directsign);
+ }
AlgorithmId sigAlgID = SignatureUtil.fromSignature(signer, privateKey);
PKCS9Attributes authAttrs = null;
@@ -786,8 +818,9 @@ public static byte[] generateNewSignedData(
// MessageDigest
byte[] md;
String digAlgName = digAlgID.getName();
- if (digAlgName.equals("SHAKE256") || digAlgName.equals("SHAKE256-LEN")) {
- // No MessageDigest impl for SHAKE256 yet
+ if (digAlgName.equals("SHAKE256-LEN")) {
+ // We don't check the LEN here. Usually it is returned
+ // by SignatureUtil.getDigestAlgInPkcs7SignerInfo
var shaker = new SHAKE256(64);
shaker.update(content, 0, content.length);
md = shaker.digest();
diff --git a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
index 255cf8157bcb..11d532229906 100644
--- a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
+++ b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
@@ -323,15 +323,20 @@ public ArrayList getCertificateChain(PKCS7 block)
return certList;
}
- /* Returns null if verify fails, this signerInfo if
- verify succeeds. */
- SignerInfo verify(PKCS7 block, byte[] data)
- throws NoSuchAlgorithmException, SignatureException {
+ /**
+ * Verify this signerInfo in a PKCS7 block.
+ *
+ * @param block the PKCS7 object
+ * @param data the content to verify against; read from block if null
+ * @param cert certificate to verify with; read from block if null
+ * @return null if verify fails, this signerInfo if verify succeeds.
+ */
+ SignerInfo verify(PKCS7 block, byte[] data, X509Certificate cert)
+ throws NoSuchAlgorithmException, SignatureException {
try {
- Timestamp timestamp = null;
try {
- timestamp = getTimestamp();
+ getTimestamp();
} catch (Exception e) {
// Log exception and continue. This allows for the case
// where, if there are no other errors, the code is
@@ -391,22 +396,19 @@ SignerInfo verify(PKCS7 block, byte[] data)
return null;
byte[] computedMessageDigest;
- if (digestAlgName.equals("SHAKE256")
- || digestAlgName.equals("SHAKE256-LEN")) {
- if (digestAlgName.equals("SHAKE256-LEN")) {
- // RFC8419: for EdDSA in CMS, the id-shake256-len
- // algorithm id must contain parameter value 512
- // encoded as a positive integer value
- byte[] params = digestAlgorithmId.getEncodedParams();
- if (params == null) {
- throw new SignatureException(
- "id-shake256-len oid missing length");
- }
- int v = new DerValue(params).getInteger();
- if (v != 512) {
- throw new SignatureException(
- "Unsupported id-shake256-" + v);
- }
+ if (digestAlgName.equals("SHAKE256-LEN")) {
+ // RFC8419: for EdDSA in CMS, the id-shake256-len
+ // algorithm id must contain parameter value 512
+ // encoded as a positive integer value
+ byte[] params = digestAlgorithmId.getEncodedParams();
+ if (params == null) {
+ throw new SignatureException(
+ "id-shake256-len oid missing length");
+ }
+ int v = new DerValue(params).getInteger();
+ if (v != 512) {
+ throw new SignatureException(
+ "Unsupported id-shake256-" + v);
}
var md = new SHAKE256(64);
md.update(data, 0, data.length);
@@ -446,9 +448,11 @@ SignerInfo verify(PKCS7 block, byte[] data)
"SignerInfo digestEncryptionAlgorithm field", true));
}
- X509Certificate cert = getCertificate(block);
if (cert == null) {
- return null;
+ cert = getCertificate(block);
+ if (cert == null) {
+ return null;
+ }
}
PublicKey key = cert.getPublicKey();
@@ -517,9 +521,9 @@ SignerInfo verify(PKCS7 block, byte[] data)
* The digest algorithm is in the form "DIG", and the encryption
* algorithm can be in any of the 3 forms:
*
- * 1. Old style key algorithm like RSA, DSA, EC, this method returns
+ * 1. Simple key algorithm like RSA, DSA, EC, this method returns
* DIGwithKEY.
- * 2. New style signature algorithm in the form of HASHwithKEY, this
+ * 2. Traditional signature algorithm in the form of HASHwithKEY, this
* method returns DIGwithKEY. Please note this is not HASHwithKEY.
* 3. Modern signature algorithm like RSASSA-PSS and EdDSA, this method
* returns the signature algorithm itself but ensures digAlgId is
@@ -547,32 +551,65 @@ public static String makeSigAlg(AlgorithmId digAlgId, AlgorithmId encAlgId,
}
if (!AlgorithmId.get(spec.getDigestAlgorithm()).equals(digAlgId)) {
- throw new NoSuchAlgorithmException("Incompatible digest algorithm");
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
}
return encAlg;
case "Ed25519":
- if (!digAlgId.equals(SignatureUtil.EdDSADigestAlgHolder.sha512)) {
- throw new NoSuchAlgorithmException("Incompatible digest algorithm");
+ if (!digAlgId.equalsOID(AlgorithmId.SHA512_oid)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
}
return encAlg;
case "Ed448":
if (directSign) {
- if (!digAlgId.equals(SignatureUtil.EdDSADigestAlgHolder.shake256)) {
- throw new NoSuchAlgorithmException("Incompatible digest algorithm");
+ if (!digAlgId.equalsOID(AlgorithmId.SHAKE256_512_oid)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
}
} else {
- if (!digAlgId.equals(SignatureUtil.EdDSADigestAlgHolder.shake256$512)) {
- throw new NoSuchAlgorithmException("Incompatible digest algorithm");
+ if (!digAlgId.equals(SignatureUtil.DigestAlgHolder.shake256lenWith512)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
}
}
return encAlg;
+ case "ML-DSA-44":
+ // Following 3 from Table 1 inside
+ // https://datatracker.ietf.org/doc/html/rfc9882#name-signerinfo-content
+ if (!digAlgId.equalsOID(AlgorithmId.SHA256_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA384_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_256_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_384_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHAKE128_256_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHAKE256_512_oid)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
+ }
+ return encAlg;
+ case "ML-DSA-65":
+ if (!digAlgId.equalsOID(AlgorithmId.SHA384_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_384_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHAKE256_512_oid)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
+ }
+ return encAlg;
+ case "ML-DSA-87":
+ if (!digAlgId.equalsOID(AlgorithmId.SHA512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHA3_512_oid)
+ && !digAlgId.equalsOID(AlgorithmId.SHAKE256_512_oid)) {
+ throw new NoSuchAlgorithmException("Incompatible digest algorithm " + digAlgId);
+ }
+ return encAlg;
default:
- String digAlg = digAlgId.getName();
String keyAlg = SignatureUtil.extractKeyAlgFromDwithE(encAlg);
- if (keyAlg == null) {
- // The encAlg used to be only the key alg
- keyAlg = encAlg;
+ if (keyAlg == null) { // No "WITH" inside
+ if (encAlg.equals("RSA") || encAlg.equals("DSA") || encAlg.equals("EC")) {
+ keyAlg = encAlg; // Sometimes encAlgId is just the enc alg
+ } else {
+ return encAlg; // Must be a modern algorithm like EdDSA or ML-DSA
+ }
}
+ String digAlg = digAlgId.getName();
if (digAlg.startsWith("SHA-")) {
digAlg = "SHA" + digAlg.substring(4);
}
@@ -584,7 +621,7 @@ public static String makeSigAlg(AlgorithmId digAlgId, AlgorithmId encAlgId,
/* Verify the content of the pkcs7 block. */
SignerInfo verify(PKCS7 block)
throws NoSuchAlgorithmException, SignatureException {
- return verify(block, null);
+ return verify(block, null, null);
}
public BigInteger getVersion() {
diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
index 420c93c02bf6..fb493fb9829e 100644
--- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
+++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
@@ -191,21 +191,20 @@ public static boolean isBlockOrSF(String s) {
/**
* Returns the signed JAR block file extension for a key.
*
+ * Returns "DSA" for unknown algorithms. This is safe because the
+ * signature verification process does not require the extension to
+ * match the key algorithm as long as it is "RSA", "DSA", or "EC."
+ *
* @param key the key used to sign the JAR file
* @return the extension
* @see #isBlockOrSF(String)
*/
public static String getBlockExtension(PrivateKey key) {
- String keyAlgorithm = key.getAlgorithm().toUpperCase(Locale.ENGLISH);
- if (keyAlgorithm.equals("RSASSA-PSS")) {
- return "RSA";
- } else if (keyAlgorithm.equals("EDDSA")
- || keyAlgorithm.equals("ED25519")
- || keyAlgorithm.equals("ED448")) {
- return "EC";
- } else {
- return keyAlgorithm;
- }
+ return switch (key.getAlgorithm().toUpperCase(Locale.ENGLISH)) {
+ case "RSA", "RSASSA-PSS" -> "RSA";
+ case "EC", "EDDSA", "ED25519", "ED448" -> "EC";
+ default -> "DSA";
+ };
}
/**
diff --git a/src/java.base/share/classes/sun/security/util/SignatureUtil.java b/src/java.base/share/classes/sun/security/util/SignatureUtil.java
index f1b0f9b31da0..b53d874770e6 100644
--- a/src/java.base/share/classes/sun/security/util/SignatureUtil.java
+++ b/src/java.base/share/classes/sun/security/util/SignatureUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -193,16 +193,16 @@ public static void initSignWithParam(Signature s, PrivateKey key,
SharedSecrets.getJavaSecuritySignatureAccess().initSign(s, key, params, sr);
}
- public static class EdDSADigestAlgHolder {
+ public static class DigestAlgHolder {
public static final AlgorithmId sha512;
- public static final AlgorithmId shake256;
- public static final AlgorithmId shake256$512;
+ public static final AlgorithmId shake256_512;
+ public static final AlgorithmId shake256lenWith512;
static {
try {
- sha512 = new AlgorithmId(ObjectIdentifier.of(KnownOIDs.SHA_512));
- shake256 = new AlgorithmId(ObjectIdentifier.of(KnownOIDs.SHAKE256_512));
- shake256$512 = new AlgorithmId(
+ sha512 = new AlgorithmId(AlgorithmId.SHA512_oid);
+ shake256_512 = new AlgorithmId(AlgorithmId.SHAKE256_512_oid);
+ shake256lenWith512 = new AlgorithmId(
ObjectIdentifier.of(KnownOIDs.SHAKE256_LEN),
new DerValue((byte) 2, new byte[]{2, 0})); // int 512
} catch (IOException e) {
@@ -235,18 +235,22 @@ public static AlgorithmId getDigestAlgInPkcs7SignerInfo(
// https://www.rfc-editor.org/rfc/rfc8419.html#section-3
switch (kAlg.toUpperCase(Locale.ENGLISH)) {
case "ED25519":
- digAlgID = EdDSADigestAlgHolder.sha512;
+ digAlgID = DigestAlgHolder.sha512;
break;
case "ED448":
if (directsign) {
- digAlgID = EdDSADigestAlgHolder.shake256;
+ digAlgID = DigestAlgHolder.shake256_512;
} else {
- digAlgID = EdDSADigestAlgHolder.shake256$512;
+ digAlgID = DigestAlgHolder.shake256lenWith512;
}
break;
default:
throw new AssertionError("Unknown curve name: " + kAlg);
}
+ } else if (kAlg.toUpperCase(Locale.ENGLISH).startsWith("ML-DSA")) {
+ // https://datatracker.ietf.org/doc/html/rfc9882#name-signerinfo-content
+ // Just use SHA-512
+ digAlgID = DigestAlgHolder.sha512;
} else {
if (sigalg.equalsIgnoreCase("RSASSA-PSS")) {
try {
@@ -496,6 +500,7 @@ public static void checkKeyAndSigAlgMatch(PrivateKey key, String sAlg) {
public static String getDefaultSigAlgForKey(PrivateKey k) {
String kAlg = k.getAlgorithm();
return switch (kAlg.toUpperCase(Locale.ENGLISH)) {
+ case "DH", "XDH", "X25519", "X448" -> null;
case "DSA", "RSA" -> ifcFfcStrength(KeyUtil.getKeySize(k))
+ "with" + kAlg;
case "EC" -> ecStrength(KeyUtil.getKeySize(k))
@@ -503,8 +508,10 @@ public static String getDefaultSigAlgForKey(PrivateKey k) {
case "EDDSA" -> k instanceof EdECPrivateKey
? ((EdECPrivateKey) k).getParams().getName()
: kAlg;
- case "RSASSA-PSS", "ED25519", "ED448" -> kAlg;
- default -> null;
+ default -> kAlg.contains("KEM") ? null : kAlg;
+ // All modern signature algorithms use the same name across
+ // key algorithms and signature algorithms, for example,
+ // RSASSA-PSS, ED25519, ED448, HSS/LMS, etc
};
}
diff --git a/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java b/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java
index efb84ac8bc99..ae1bcb8be9f3 100644
--- a/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java
+++ b/src/java.base/share/classes/sun/security/validator/EntrustTLSPolicy.java
@@ -40,12 +40,6 @@ final class EntrustTLSPolicy {
// SHA-256 certificate fingerprints of distrusted roots
private static final Set FINGERPRINTS = Set.of(
- // cacerts alias: entrustevca
- // DN: CN=Entrust Root Certification Authority,
- // OU=(c) 2006 Entrust, Inc.,
- // OU=www.entrust.net/CPS is incorporated by reference,
- // O=Entrust, Inc., C=US
- "73C176434F1BC6D5ADF45B0E76E727287C8DE57616C1E6E6141A2B2CBC7D8E4C",
// cacerts alias: entrustrootcaec1
// DN: CN=Entrust Root Certification Authority - EC1,
// OU=(c) 2012 Entrust, Inc. - for authorized use only,
diff --git a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
index bb93ee5040ec..ea81afc6f1fc 100644
--- a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
+++ b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
@@ -309,6 +309,14 @@ public boolean equals(AlgorithmId other) {
Arrays.equals(encodedParams, other.encodedParams);
}
+ /**
+ * Returns true if this AlgorithmID only has the specified ObjectIdentifier
+ * and a NULL params. Note the encoded params might be ASN.1 NULL or absent.
+ */
+ public boolean equalsOID(ObjectIdentifier oid) {
+ return algid.equals(oid) && encodedParams == null;
+ }
+
/**
* Compares this AlgorithmID to another. If algorithm parameters are
* available, they are compared. Otherwise, just the object IDs
@@ -630,6 +638,12 @@ private static ConcurrentHashMap collectOIDAliases() {
public static final ObjectIdentifier SHA3_512_oid =
ObjectIdentifier.of(KnownOIDs.SHA3_512);
+ public static final ObjectIdentifier SHAKE128_256_oid =
+ ObjectIdentifier.of(KnownOIDs.SHAKE128_256);
+
+ public static final ObjectIdentifier SHAKE256_512_oid =
+ ObjectIdentifier.of(KnownOIDs.SHAKE256_512);
+
public static final ObjectIdentifier DSA_oid =
ObjectIdentifier.of(KnownOIDs.DSA);
diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java b/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java
index f3ef562fe425..8f81edb63a32 100644
--- a/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -189,7 +189,7 @@ public int read(String name, ByteBuffer dst) throws IOException {
int n = read(name, address, rem);
// copy from buffer into backing array
- long off = dst.arrayOffset() + pos + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ long off = dst.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET;
unsafe.copyMemory(null, address, dst.array(), off, n);
dst.position(pos + n);
@@ -251,7 +251,7 @@ public int write(String name, ByteBuffer src) throws IOException {
if (src.hasArray()) {
// copy from backing array into buffer
- long off = src.arrayOffset() + pos + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ long off = src.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET;
unsafe.copyMemory(src.array(), off, null, address, rem);
} else {
// backing array not accessible so transfer via temporary array
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java
index 755d6cb14dc2..546fa406f4c1 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java
@@ -45,7 +45,7 @@
public abstract class HeapMemorySegmentImpl extends AbstractMemorySegmentImpl {
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
- private static final int BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class);
+ private static final long BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class);
final long offset;
final H base;
@@ -74,7 +74,7 @@ ByteBuffer makeByteBuffer() {
throw new UnsupportedOperationException("Not an address to an heap-allocated byte array");
}
JavaNioAccess nioAccess = SharedSecrets.getJavaNioAccess();
- return nioAccess.newHeapByteBuffer((byte[]) base(), (int)min() - BYTE_ARR_BASE, (int) byteSize(), null);
+ return nioAccess.newHeapByteBuffer((byte[]) base(), (int)(min() - BYTE_ARR_BASE), (int) byteSize(), null);
}
// factories
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
index 731be0591097..4c130b451e94 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -3680,7 +3680,7 @@ static long booleanArrayAddress(boolean[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
index dc8e03ba88ee..c045de9d0f73 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -3287,7 +3287,7 @@ static long arrayAddress(double[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
index 7ca86ed6b174..c4ade519d20f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -3274,7 +3274,7 @@ static long arrayAddress(float[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
index 70c30c7103f4..7bd0da683cb5 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
@@ -3383,7 +3383,7 @@ static long arrayAddress(int[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
index 0142a930e02d..27566de2197f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -3286,7 +3286,7 @@ static long arrayAddress(long[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
index ec2e524fdfd1..409e02b2d08f 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -3672,7 +3672,7 @@ static long charArrayAddress(char[] a, int index) {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
index 0d53dfddcbbc..f25e9f66fec8 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -4655,7 +4655,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
@ForceInline
static long byteArrayAddress(byte[] a, int index) {
- return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
+ return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;
}
// ================================================
diff --git a/src/jdk.jartool/share/man/jarsigner.1 b/src/jdk.jartool/share/man/jarsigner.1
index ab7a7959dea0..1d11fb12d060 100644
--- a/src/jdk.jartool/share/man/jarsigner.1
+++ b/src/jdk.jartool/share/man/jarsigner.1
@@ -362,7 +362,7 @@ SHA512withECDSA
T}@T{
T}
T{
-RSASSA\-PSS
+RSASSA\-PSS[1]
T}@T{
<= 3072
T}@T{
@@ -385,23 +385,25 @@ RSASSA\-PSS (with SHA\-512)
T}@T{
T}
T{
-EdDSA
+EdDSA[2]
T}@T{
255
T}@T{
-Ed25519
+EdDSA
T}@T{
\&.EC
T}
T{
+ML-DSA[2]
T}@T{
-448
T}@T{
-Ed448
+ML-DSA
T}@T{
+\&.DSA
T}
.TE
-.IP \[bu] 2
+.PP
+1.
If an RSASSA\-PSS key is encoded with parameters, then jarsigner will
use the same parameters in the signature.
Otherwise, jarsigner will use parameters that are determined by the size
@@ -409,6 +411,17 @@ of the key as specified in the table above.
For example, an 3072\-bit RSASSA\-PSS key will use RSASSA\-PSS as the
signature algorithm and SHA\-256 as the hash and MGF1 algorithms.
.PP
+2.
+Modern digital signature algorithms such as EdDSA and ML-DSA use the same
+name for both the key and signature algorithms.
+Only the signature algorithm with the same name can be used with a given
+key algorithm.
+The specific signature parameter set (for example, Ed25519 or Ed448 for
+EdDSA) is the same as that of the key.
+.PP
+If a key algorithm is not listed in this table, the \f[V].DSA\f[R] block
+file extension is always used.
+.PP
These default signature algorithms can be overridden by using the
\f[CB]\-sigalg\f[R] option.
.PP
diff --git a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
index e0ab5f3dffad..611962ba61fa 100644
--- a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
+++ b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -615,7 +615,7 @@ public void freeMemory(long address) {
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
* or {@link #arrayBaseOffset}.
*/
- public static final int INVALID_FIELD_OFFSET = jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET;
+ public static final int INVALID_FIELD_OFFSET = (int) jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET;
/**
* Reports the location of a given field in the storage allocation of its
@@ -755,35 +755,35 @@ public void ensureClassInitialized(Class> c) {
*/
@ForceInline
public int arrayBaseOffset(Class> arrayClass) {
- return theInternalUnsafe.arrayBaseOffset(arrayClass);
+ return (int) theInternalUnsafe.arrayBaseOffset(arrayClass);
}
/** The value of {@code arrayBaseOffset(boolean[].class)} */
- public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
+ public static final int ARRAY_BOOLEAN_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(byte[].class)} */
- public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ public static final int ARRAY_BYTE_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(short[].class)} */
- public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
+ public static final int ARRAY_SHORT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(char[].class)} */
- public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
+ public static final int ARRAY_CHAR_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(int[].class)} */
- public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
+ public static final int ARRAY_INT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(long[].class)} */
- public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
+ public static final int ARRAY_LONG_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(float[].class)} */
- public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
+ public static final int ARRAY_FLOAT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(double[].class)} */
- public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
+ public static final int ARRAY_DOUBLE_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
/** The value of {@code arrayBaseOffset(Object[].class)} */
- public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
+ public static final int ARRAY_OBJECT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET;
/**
* Reports the scale factor for addressing elements in the storage
diff --git a/test/hotspot/jtreg/compiler/c2/Test6968348.java b/test/hotspot/jtreg/compiler/c2/Test6968348.java
index 17a2d61716b0..488bcfcac589 100644
--- a/test/hotspot/jtreg/compiler/c2/Test6968348.java
+++ b/test/hotspot/jtreg/compiler/c2/Test6968348.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, 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
@@ -39,7 +39,7 @@
public class Test6968348 {
static Unsafe unsafe = Unsafe.getUnsafe();
static final long[] buffer = new long[4096];
- static int array_long_base_offset;
+ static long array_long_base_offset;
public static void main(String[] args) throws Exception {
array_long_base_offset = unsafe.arrayBaseOffset(long[].class);
diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java
index e0c43b055295..64c52446c368 100644
--- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java
+++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -50,7 +50,7 @@ public class TestIntUnsafeCAS {
private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe = Unsafe.getUnsafe();
- private static final int BASE;
+ private static final long BASE;
static {
try {
BASE = unsafe.arrayBaseOffset(int[].class);
diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java
index b7354c88dae5..342b146a0c89 100644
--- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java
+++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -50,7 +50,7 @@ public class TestIntUnsafeOrdered {
private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe = Unsafe.getUnsafe();
- private static final int BASE;
+ private static final long BASE;
static {
try {
BASE = unsafe.arrayBaseOffset(int[].class);
diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java
index 3ff0a1323798..3ea812a9e79f 100644
--- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java
+++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -50,7 +50,7 @@ public class TestIntUnsafeVolatile {
private static final int UNALIGN_OFF = 5;
private static final Unsafe unsafe = Unsafe.getUnsafe();
- private static final int BASE;
+ private static final long BASE;
static {
try {
BASE = unsafe.arrayBaseOffset(int[].class);
diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java
index 71d9050160f5..e8ac61d27361 100644
--- a/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java
+++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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
diff --git a/test/hotspot/jtreg/compiler/runtime/Test8010927.java b/test/hotspot/jtreg/compiler/runtime/Test8010927.java
index 74aa824f2da0..3e90dc0c67cb 100644
--- a/test/hotspot/jtreg/compiler/runtime/Test8010927.java
+++ b/test/hotspot/jtreg/compiler/runtime/Test8010927.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -74,7 +74,7 @@ public class Test8010927 {
static final Test8010927 elem = new Test8010927();
static final WhiteBox wb = WhiteBox.getWhiteBox();
- static final int obj_header_size = U.ARRAY_OBJECT_BASE_OFFSET;
+ static final int obj_header_size = (int) U.ARRAY_OBJECT_BASE_OFFSET;
static final int heap_oop_size = wb.getHeapOopSize();
static final int card_size = 512;
static final int one_card = (card_size - obj_header_size) / heap_oop_size;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
index 98f638abe2d5..2a4015daca20 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestBoolean {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
index e149f6bd07bb..8b188cb7cb52 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestByte {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
index 62d926b66a1d..4b5b876d5072 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestChar {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
index 2f90f0d7c7b0..5334da98714d 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestDouble {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
index f0256e7815d5..946f6d7d5ded 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestFloat {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
index 038cd2151b1b..93ed85805d5b 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestInt {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
index cffec14ad725..7a6d2bfc033f 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestLong {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
index 0c74c295e213..2fe5d7f3ae05 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestObject {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
index 770677a98d39..47a700d9313c 100644
--- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
+++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestShort {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
index c176277d2bad..fcb0b3fbef37 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestBoolean {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
index b205b1d33764..7343463c41d8 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestByte {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
index 114ed7e9b5a7..4c5e02bea266 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestChar {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
index d813ea73e702..5503dcd1840f 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestDouble {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
index f0482c826376..f050c5bb17b8 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestFloat {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
index 9326539f4efe..85f82915e03a 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestInt {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
index 30bc9551dd50..1a73cfe30865 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestLong {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
index add15ff77fdd..1aab41ddc9b6 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestObject {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
index 4ea81f026e73..123b655220c6 100644
--- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
+++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestShort {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template
index 2fc22fa360ab..f5eadc218e44 100644
--- a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template
+++ b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -64,7 +64,7 @@ public class $Qualifier$UnsafeAccessTest$Type$ {
static final long STATIC_V_OFFSET;
- static int ARRAY_OFFSET;
+ static long ARRAY_OFFSET;
static int ARRAY_SHIFT;
diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
index 7e91fe60cfb7..b7f13306387e 100644
--- a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
+++ b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -140,7 +140,7 @@ public static class RatioVerifier {
// Size of byte array that will be allocated
public static final int CHUNK_SIZE = 1024;
// Length of byte array, that will be added to "garbage" list.
- public static final int ARRAY_LENGTH = CHUNK_SIZE - Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ public static final int ARRAY_LENGTH = CHUNK_SIZE - (int) Unsafe.ARRAY_BYTE_BASE_OFFSET;
// Amount of tries to force heap shrinking/expansion using GC
public static final int GC_TRIES = 10;
diff --git a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java
index 8f8b4aa10877..3af3781a6cc3 100644
--- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java
+++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -256,7 +256,7 @@ public static class TargetSurvivorRatioVerifier {
// Desired size of memory allocated at once
public static final int CHUNK_SIZE = 1024;
// Length of byte[] array that will have occupy CHUNK_SIZE bytes in heap
- public static final int ARRAY_LENGTH = CHUNK_SIZE - Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ public static final int ARRAY_LENGTH = CHUNK_SIZE - (int) Unsafe.ARRAY_BYTE_BASE_OFFSET;
public static void main(String args[]) throws Exception {
if (args.length != 1) {
diff --git a/test/hotspot/jtreg/runtime/Unsafe/GetField.java b/test/hotspot/jtreg/runtime/Unsafe/GetField.java
index 3772fa6e8db7..88ac98135f1a 100644
--- a/test/hotspot/jtreg/runtime/Unsafe/GetField.java
+++ b/test/hotspot/jtreg/runtime/Unsafe/GetField.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -37,11 +37,11 @@
public class GetField {
public static void main(String args[]) throws Exception {
Unsafe unsafe = Unsafe.getUnsafe();
- // Unsafe.INVALID_FIELD_OFFSET is a static final int field,
+ // Unsafe.INVALID_FIELD_OFFSET is a static final long field,
// make sure getField returns the correct field
Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET");
assertNotEquals(field.getModifiers() & Modifier.FINAL, 0);
assertNotEquals(field.getModifiers() & Modifier.STATIC, 0);
- assertEquals(field.getType(), int.class);
+ assertEquals(field.getType(), long.class);
}
}
diff --git a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
index 17d1b75977e8..12cd046e92ce 100644
--- a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
+++ b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 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
@@ -143,8 +143,9 @@ public static void test(MappedByteBuffer buffer, Unsafe unsafe, long mapAddr, lo
buffer.get(new byte[8]);
break;
case 1:
- // testing Unsafe.copySwapMemory, trying to access next page after truncation.
- unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], 16, 2000, 2);
+ // testing Unsafe.copySwapMemory, trying to access next page after truncation.
+ long destOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], destOffset, 2000, 2);
break;
case 2:
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
index 5799c4c2b0e0..f5f8fc3adadc 100644
--- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
+++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
@@ -29,7 +29,7 @@
* 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654
* 8305975 8304760 8307134 8295894 8314960 8317373 8317374 8318759 8319187
* 8321408 8316138 8341057 8303770 8350498 8359170 8361212 8372351 8387123
- * 8386371 8392771 8395690
+ * 8386371 8392771 8395690 8303772
* @summary Check root CA entries in cacerts file
*/
import java.io.ByteArrayInputStream;
@@ -49,13 +49,13 @@ public class VerifyCACerts {
// The numbers of certs now.
// SapMachine 2021-09-23: Additional certificate for SAP
- private static final int COUNT = 108;
+ private static final int COUNT = 107;
// SHA-256 of cacerts, can be generated with
// shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95
// SapMachine 2021-09-23: Additional certificate for SAP
private static final String CHECKSUM
- = "29:1F:EF:5B:E9:8A:04:46:CE:03:31:44:9F:E8:F3:D4:C1:32:7B:09:1F:74:60:E3:77:DD:6D:62:D9:E8:03:6D";
+ = "6B:14:B4:19:81:7A:73:33:85:26:E8:45:DE:9F:87:93:FF:83:5A:C9:97:BC:DB:91:18:59:AA:B5:E7:BC:6F:BB";
// Hex formatter to upper case with ":" delimiter
private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase();
@@ -193,8 +193,6 @@ public class VerifyCACerts {
"6D:C4:71:72:E0:1C:BC:B0:BF:62:58:0D:89:5F:E2:B8:AC:9A:D4:F8:73:80:1E:0C:10:B9:C8:37:D2:1E:B1:77");
put("entrustrootcag2 [jdk]",
"43:DF:57:74:B0:3E:7F:EF:5F:E4:0D:93:1A:7B:ED:F1:BB:2E:6B:42:73:8C:4E:6D:38:41:10:3D:3A:A7:F3:39");
- put("entrustevca [jdk]",
- "73:C1:76:43:4F:1B:C6:D5:AD:F4:5B:0E:76:E7:27:28:7C:8D:E5:76:16:C1:E6:E6:14:1A:2B:2C:BC:7D:8E:4C");
put("ttelesecglobalrootclass3ca [jdk]",
"FD:73:DA:D3:1C:64:4F:F1:B4:3B:EF:0C:CD:DA:96:71:0B:9C:D9:87:5E:CA:7E:31:70:7A:F3:E9:6D:52:2B:BD");
put("ttelesecglobalrootclass2ca [jdk]",
diff --git a/test/jdk/sun/security/pkcs/pkcs7/MLDSADigestConformance.java b/test/jdk/sun/security/pkcs/pkcs7/MLDSADigestConformance.java
new file mode 100644
index 000000000000..80aa0c96281b
--- /dev/null
+++ b/test/jdk/sun/security/pkcs/pkcs7/MLDSADigestConformance.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8349732
+ * @summary ML-DSA digest alg conformance check
+ * @modules java.base/sun.security.pkcs
+ * java.base/sun.security.tools.keytool
+ * java.base/sun.security.x509
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Asserts;
+import sun.security.pkcs.PKCS7;
+import sun.security.tools.keytool.CertAndKeyGen;
+import sun.security.x509.AlgorithmId;
+import sun.security.x509.X500Name;
+
+import java.nio.charset.StandardCharsets;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+import java.util.List;
+import java.util.Map;
+
+public class MLDSADigestConformance {
+
+ static String[] ALL_KEY_ALGS = {"ML-DSA-44", "ML-DSA-65", "ML-DSA-87"};
+ static String[] ALL_DIGEST_ALGS = {
+ "SHA-1", "SHA-224", "SHA-256", "SHA-384", "SHA-512",
+ "SHA3-224", "SHA3-256", "SHA3-384", "SHA3-512",
+ "SHAKE128-256", "SHAKE256-512"};
+ static Map> SUPPORTED = Map.of(
+ "ML-DSA-44", List.of("SHA-256", "SHA-384", "SHA-512",
+ "SHA3-256", "SHA3-384", "SHA3-512",
+ "SHAKE128-256", "SHAKE256-512"),
+ "ML-DSA-65", List.of("SHA-384", "SHA-512",
+ "SHA3-384", "SHA3-512", "SHAKE256-512"),
+ "ML-DSA-87", List.of("SHA-512", "SHA3-512", "SHAKE256-512")
+ );
+
+ public static void main(String[] args) throws Exception {
+ testSig("ML-DSA-44");
+ testSig("ML-DSA-65");
+ testSig("ML-DSA-87");
+ }
+
+ static void testSig(String keyAlg) throws Exception {
+ System.out.println("Testing " + keyAlg);
+ var cag = new CertAndKeyGen(keyAlg, keyAlg);
+ cag.generate(keyAlg);
+ var sk = cag.getPrivateKey();
+ var certs = new X509Certificate[] {
+ cag.getSelfCertificate(new X500Name("CN=Me"), 1000)
+ };
+ var count = testDigest(keyAlg, sk, certs, null);
+ System.out.println(" digestAlg default: " + count);
+ Asserts.assertEQ(count, 1);
+ for (var da : ALL_DIGEST_ALGS) {
+ count = testDigest(keyAlg, sk, certs, da);
+ System.out.println(" digestAlg " + da + ": " + count);
+ if (SUPPORTED.get(keyAlg).contains(da)) {
+ Asserts.assertEQ(count, 1);
+ } else {
+ Asserts.assertEQ(count, 0);
+ }
+ }
+ }
+
+ static int testDigest(String keyAlg, PrivateKey sk,
+ X509Certificate[] certs, String digestAlg) throws Exception {
+ var content = "hello".getBytes(StandardCharsets.UTF_8);
+ var p7 = PKCS7.generateSignedData(keyAlg, null,
+ sk, certs,
+ content, true, false,
+ digestAlg == null ? null : AlgorithmId.get(digestAlg),
+ null);
+ try {
+ return new PKCS7(p7).verify(null).length;
+ } catch (NoSuchAlgorithmException e) {
+ return 0;
+ }
+ }
+}
diff --git a/test/jdk/sun/security/provider/acvp/Launcher.java b/test/jdk/sun/security/provider/acvp/Launcher.java
index 799f145bb26c..2ee0ff96bd1b 100644
--- a/test/jdk/sun/security/provider/acvp/Launcher.java
+++ b/test/jdk/sun/security/provider/acvp/Launcher.java
@@ -37,6 +37,8 @@
/*
* @test
* @bug 8342442 8345057
+ * @summary Test default implementation. Use othervm because
+ * ML_DSA_Impls.version might be modified
* @library /test/lib
* @modules java.base/sun.security.provider
* java.base/sun.security.util
@@ -46,8 +48,8 @@
/*
* @test
- * @summary Test verifying the intrinsic implementation.
* @bug 8342442 8345057
+ * @summary Test verifying the intrinsic implementation.
* @library /test/lib
* @modules java.base/sun.security.provider
* java.base/sun.security.util
diff --git a/test/jdk/sun/security/provider/pqc/ML_DSA_CMS.java b/test/jdk/sun/security/provider/pqc/ML_DSA_CMS.java
new file mode 100644
index 000000000000..f7469847b3fa
--- /dev/null
+++ b/test/jdk/sun/security/provider/pqc/ML_DSA_CMS.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8349732
+ * @library /test/lib
+ * @summary Add support for JARs signed with ML-DSA
+ * @modules java.base/sun.security.pkcs
+ */
+import jdk.test.lib.Asserts;
+import jdk.test.lib.security.RepositoryFileReader;
+import sun.security.pkcs.PKCS7;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Base64;
+import java.util.stream.Collectors;
+
+import static jdk.test.lib.security.RepositoryFileReader.*;
+
+public class ML_DSA_CMS {
+ public static void main(String[] args) throws Exception {
+ // Example signed-data encodings from RFC 9882, Appendix B
+ // (https://datatracker.ietf.org/doc/html/rfc9882#name-examples), which
+ // can be verified by example certificates from RFC 9881, Appendix C.3
+ // (https://datatracker.ietf.org/doc/html/rfc9881#name-example-certificates)
+ //
+ // These data can be retrieved from the following GitHub releases:
+ // https://github.com/lamps-wg/cms-ml-dsa/releases/tag/draft-ietf-lamps-cms-ml-dsa-07
+ // https://github.com/lamps-wg/dilithium-certificates/releases/tag/draft-ietf-lamps-dilithium-certificates-13
+ //
+ // Although the release tags include "draft", these values are the
+ // same as those in the final RFCs 9881 and 9882.
+ try (var cmsReader = RepositoryFileReader.of(CMS_ML_DSA.class,
+ "cms-ml-dsa-draft-ietf-lamps-cms-ml-dsa-07/");
+ var dsaReader = RepositoryFileReader.of(DILITHIUM_CERTIFICATES.class,
+ "dilithium-certificates-draft-ietf-lamps-dilithium-certificates-13/")) {
+ test(readCMS(cmsReader, "mldsa44-signed-attrs.pem"),
+ readCert(dsaReader, "ML-DSA-44.crt"));
+ test(readCMS(cmsReader, "mldsa65-signed-attrs.pem"),
+ readCert(dsaReader, "ML-DSA-65.crt"));
+ test(readCMS(cmsReader, "mldsa87-signed-attrs.pem"),
+ readCert(dsaReader, "ML-DSA-87.crt"));
+ }
+ }
+
+ /// Verifies a signed file.
+ /// @param data the signed data in PKCS #7 format
+ /// @param cert the certificate used to verify
+ static void test(byte[] data, X509Certificate cert) throws Exception {
+ var p7 = new PKCS7(data);
+ for (var si : p7.getSignerInfos()) {
+ Asserts.assertTrue(p7.verify(si, null, cert).getIssuerName() != null);
+ }
+ }
+
+ // Read data in https://datatracker.ietf.org/doc/html/rfc9882#name-examples
+ static byte[] readCMS(RepositoryFileReader f, String entry) throws IOException {
+ var data = f.read("examples/" + entry);
+ var pem = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(data)))
+ .lines()
+ .filter(s -> !s.contains("-----"))
+ .collect(Collectors.joining());
+ return Base64.getMimeDecoder().decode(pem);
+ }
+
+ // Read data in https://datatracker.ietf.org/doc/html/rfc9881#name-example-certificates
+ static X509Certificate readCert(RepositoryFileReader f, String entry) throws Exception {
+ var data = f.read("examples/" + entry);
+ var cf = CertificateFactory.getInstance("X.509");
+ return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(data));
+ }
+}
diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java
index 3f25ab4a2132..837de29d66d1 100644
--- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java
+++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/Entrust.java
@@ -28,7 +28,7 @@
/**
* @test
- * @bug 8337664 8341059 8361212 8386371
+ * @bug 8337664 8341059 8361212 8386371 8303772
* @summary Check that TLS Server certificates chaining back to distrusted
* Entrust roots are invalid
* @library /test/lib
@@ -46,7 +46,7 @@ public class Entrust {
// Each of the roots have a test certificate chain stored in a file
// named "-chain.pem".
private static final String[] ROOTS_TO_TEST = new String[]{
- "entrustevca", "entrustrootcaec1", "entrustrootcag2", "entrust2048ca"};
+ "entrustrootcaec1", "entrustrootcag2", "entrust2048ca"};
// Date after the restrictions took effect when distrust was first announced
private static final ZonedDateTime DISTRUST_DATE =
diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustevca-chain.pem b/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustevca-chain.pem
deleted file mode 100644
index e9c06b19c694..000000000000
--- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/distrust/chains/entrust/entrustevca-chain.pem
+++ /dev/null
@@ -1,79 +0,0 @@
-Root Certificate:
- Version: 3 (0x2)
- Serial Number: 1164660820 (0x456b5054)
- Signature Algorithm: sha1WithRSAEncryption
- Issuer: C=US, O=Entrust, Inc., OU=www.entrust.net/CPS is incorporated by reference, OU=(c) 2006 Entrust, Inc., CN=Entrust Root Certification Authority
- Validity
- Not Before: Nov 27 20:23:42 2006 GMT
- Not After : Nov 27 20:53:42 2026 GMT
-
------BEGIN CERTIFICATE-----
-MIIHEjCCBfqgAwIBAgIQFhH4VGskTR+tQK3JbN63kTANBgkqhkiG9w0BAQsFADCB
-sTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsT
-MHd3dy5lbnRydXN0Lm5ldC9ycGEgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5j
-ZTEfMB0GA1UECxMWKGMpIDIwMDkgRW50cnVzdCwgSW5jLjEuMCwGA1UEAxMlRW50
-cnVzdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEwxRTAeFw0yNDA2MjgyMTQw
-NDVaFw0yNTA3MjgyMTQwNDRaMIHIMQswCQYDVQQGEwJDQTEQMA4GA1UECBMHT250
-YXJpbzEPMA0GA1UEBxMGT3R0YXdhMRMwEQYLKwYBBAGCNzwCAQMTAkNBMRgwFgYL
-KwYBBAGCNzwCAQITB09udGFyaW8xGDAWBgNVBAoTD0VudHJ1c3QgTGltaXRlZDEd
-MBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24xEDAOBgNVBAUTBzE5MTM2MDUx
-HDAaBgNVBAMTE3ZhbGlkZXYuZW50cnVzdC5uZXQwggEiMA0GCSqGSIb3DQEBAQUA
-A4IBDwAwggEKAoIBAQDL2vkrBEZ5qeVdac1C01bcNnoeCU3AVU3Fh1Ifldic9/Gw
-xqNVOFYQNzTk8M62FnPUvas4MnXmeBkPhhym+dnjsM22EeS2p6gTlvOGtJFVr+Ix
-vq1UAKtqK0gYGriW6SexroSYiG1O0aeqEnKSLlEBHYhmacj2jlbx0ToxMfdBMRRq
-4UjnIrh/CBochxt7aKv525tChnZGMT06QKAjx71w2cou0C05v83KJ75EI4EAmTfE
-z9sKJeST5pH5MI3WKcP6ZmXynKYSIpIGb4Z8B9Ftp8HdzdR9EafOSlRlbIkEn3lm
-nq4UCph48/PsUcJoViBCoY6zDLcPGt3gGQVIjq3vAgMBAAGjggMLMIIDBzAMBgNV
-HRMBAf8EAjAAMB0GA1UdDgQWBBRF6MZkqXf3sICXuvbrBH1R9I8bAjAfBgNVHSME
-GDAWgBRbQYqyxEPBvb/IVEFVneCWrf+5oTBlBggrBgEFBQcBAQRZMFcwIwYIKwYB
-BQUHMAGGF2h0dHA6Ly9vY3NwLmVudHJ1c3QubmV0MDAGCCsGAQUFBzAChiRodHRw
-Oi8vYWlhLmVudHJ1c3QubmV0L2wxZS1jaGFpbi5jZXIwMwYDVR0fBCwwKjAooCag
-JIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9sZXZlbDFlLmNybDAeBgNVHREEFzAV
-ghN2YWxpZGV2LmVudHJ1c3QubmV0MA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAU
-BggrBgEFBQcDAQYIKwYBBQUHAwIwSwYDVR0gBEQwQjAHBgVngQwBATA3BgpghkgB
-hvpsCgECMCkwJwYIKwYBBQUHAgEWG2h0dHBzOi8vd3d3LmVudHJ1c3QubmV0L3Jw
-YTCCAX0GCisGAQQB1nkCBAIEggFtBIIBaQFnAHUAEvFONL1TckyEBhnDjz96E/jn
-tWKHiJxtMAWE6+WGJjoAAAGQYMsp8gAABAMARjBEAiAL794Fw7wyzricvRl+2AON
-FbGf2hwDB3wh8RkGLBRQ7AIgTCarii0atho7ZeUO3h66Ug7s7WxnF9onDZrtoMrH
-U9MAdQAN4fIwK9MNwUBiEgnqVS78R3R8sdfpMO8OQh60fk6qNAAAAZBgyyoMAAAE
-AwBGMEQCIFaXc4M9C9mNukrV68Sc2E5lw9srQ80nMBCGseY99nFxAiAppQmR9FKC
-TE/ROlgZRfimx61W4k+SaQ52eek4JNWXXwB3ABoE/0nQVB1Ar/agw7/x2MRnL07s
-7iNAaJhrF0Au3Il9AAABkGDLKi0AAAQDAEgwRgIhAPFUevU47H5uJqYL5y1ClFS7
-mEve7E8350JKnR1VykGLAiEArn7VAJcmRNNCDAegsHCCLlpasz9PLHFd9XHQAwvL
-IFwwDQYJKoZIhvcNAQELBQADggEBAHfMCQP5Y+7IYzqOh5D/81WqHagmWOqkJYsN
-33uux44fhVGqiG1O5ImTQsxJpt/HmDuK1qLEjG31Y9q89U91KAqLQauCQ5iMXrBg
-TlwK8kzO1XYC5KkpO5ZWanqfjOahM9mkEKHPV9srwj6xTbInCq9DabRwuWyohj3b
-EKrmB016TOT0hJ94jCb8PWl15oQJdsGlEfrG7amtDSRuoDHVA3nXJIJqx5LVnErB
-glfsAmP8TPkWYY8kuNE2Rjr2M6P5LRLEvtRELCQF3lPuY0+xxGksGVM207YqhYKv
-GzMmA8c7tF3ZclbE0rUA2T8FuBuweAV8tnWq2TaeAHWIJ4nY17s=
------END CERTIFICATE-----
------BEGIN CERTIFICATE-----
-MIIFHjCCBAagAwIBAgIRAIZmsCrBy1RAAAAAAFHTWJwwDQYJKoZIhvcNAQELBQAw
-gbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkwNwYDVQQL
-EzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
-Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVu
-dHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xOTA2MTkxNjUy
-MDhaFw0yNjExMTkxNzIyMDhaMIGxMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNRW50
-cnVzdCwgSW5jLjE5MDcGA1UECxMwd3d3LmVudHJ1c3QubmV0L3JwYSBpcyBpbmNv
-cnBvcmF0ZWQgYnkgcmVmZXJlbmNlMR8wHQYDVQQLExYoYykgMjAwOSBFbnRydXN0
-LCBJbmMuMS4wLAYDVQQDEyVFbnRydXN0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
-IC0gTDFFMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtlsEVHfdDiRm
-3Cqh24DMXcdf/VIWWNpflAapuLa5YwxHIILsx5VOi7h3Umo9tYep1uHMdOWmyMDU
-Vk+NLtYIPgxMQz7wQZNeRu8559llKgx2UCe9Ww0zMwfg96KpnOERM61m/NIseqqj
-cxa+k4V1D9c3jPojt2T440xu7bMFveI223zedkTagnJ2tm7/lKHQhvcQzUpai7B1
-jGZSgE5ITEmDpkDXd4ETTV5yfkhGIqoP4j5llDjhcnH+SnEJujV/VYk9gdW4KAEQ
-dzZaEIXSvWCEK0lhlAzeTEBqKsR5YIQkgjJpSphL4lYQugNFUSDTz9qOVBtFtnq6
-l5pa2MbRXwIDAQABo4IBLjCCASowDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG
-CCsGAQUFBwMBBggrBgEFBQcDAjASBgNVHRMBAf8ECDAGAQH/AgEAMDMGCCsGAQUF
-BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD
-VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9yb290Y2ExLmNy
-bDA7BgNVHSAENDAyMDAGBFUdIAAwKDAmBggrBgEFBQcCARYaaHR0cDovL3d3dy5l
-bnRydXN0Lm5ldC9ycGEwHQYDVR0OBBYEFFtBirLEQ8G9v8hUQVWd4Jat/7mhMB8G
-A1UdIwQYMBaAFGiQ5GekplOAx4ZmpPH3S0P7hL1tMA0GCSqGSIb3DQEBCwUAA4IB
-AQAPUNBX97sqIXZl/zLu53iv7a0HK7prvD0cVaZM0yRfVptvARgjIZZzTtv32v6X
-wSr4fDeRmpLaTWtipBGSqh3fNkTSVT8GGBq6+h1lrPEYv6jnStDf7VLQxVliKt2w
-h34JjgRUx9rdia30tk/EpPavkxxPks8vjoLN3f4dbkIY/sfljyZbseqVLx9kl/we
-OvqL6jZgaQOapFQLZJze7VwLiPVuUnW8ddK3JIE1a5YCZs0irIW5+96ttznIgPK2
-aUOmHQp/zasi7SFl49HrKGKWtZuyDB9U56e01H6PDTpSSSTPyLsSVg3JALHBPDzS
-bBraAU3wuAyc3BQ4OIOmwwnT
------END CERTIFICATE-----
diff --git a/test/jdk/sun/security/tools/jarsigner/ML_DSA.java b/test/jdk/sun/security/tools/jarsigner/ML_DSA.java
new file mode 100644
index 000000000000..55758b761b3e
--- /dev/null
+++ b/test/jdk/sun/security/tools/jarsigner/ML_DSA.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8298387
+ * @summary signing with ML-DSA
+ * @library /test/lib
+ * @modules java.base/sun.security.util
+ */
+
+import jdk.security.jarsigner.JarSigner;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.Proc;
+import jdk.test.lib.security.DerUtils;
+import jdk.test.lib.util.JarUtils;
+import sun.security.util.KnownOIDs;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.KeyStore;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.zip.ZipFile;
+
+public class ML_DSA {
+
+ static List SIGNERS = List.of("44", "65", "87");
+
+ public static void main(String[] args) throws Exception {
+ if (args.length > 0) {
+ // Launched by testDisabled() in a sub-process to count signers
+ var expectedCount = Integer.parseInt(args[0]);
+ try (var jf = new JarFile("a.jar")) {
+ var je = jf.getJarEntry("a");
+ jf.getInputStream(je).readAllBytes();
+ var signers = je.getCodeSigners();
+ var count = signers == null ? 0 : signers.length;
+ if (expectedCount != count) {
+ throw new RuntimeException("Expected: " + expectedCount
+ + ", actual " + count);
+ }
+ }
+ } else {
+ prepare();
+ testAPI();
+ testTool(); // call this last, as it modifies a.jar.
+ testDisabled();
+ }
+ }
+
+ private static void prepare() throws Exception {
+ for (var signer : SIGNERS) {
+ SecurityTools.keytool("-keystore ks -storepass changeit -genkeypair -alias "
+ + signer + " -keyalg ML-DSA-" + signer + " -dname CN=" + signer)
+ .shouldHaveExitValue(0);
+ }
+ JarUtils.createJarFile(Path.of("a.jar"), Path.of("."),
+ Files.write(Path.of("a"), new byte[10]));
+ }
+
+ static void testAPI() throws Exception {
+ var pass = "changeit".toCharArray();
+ var ks = KeyStore.getInstance(new File("ks"), pass);
+ for (var signer : SIGNERS) {
+ var jsb = new JarSigner.Builder((KeyStore.PrivateKeyEntry)
+ ks.getEntry(signer, new KeyStore.PasswordProtection(pass)));
+ try (var zf = new ZipFile("a.jar");
+ var of = Files.newOutputStream(Path.of(signer + ".jar"))) {
+ jsb.signerName(signer).build().sign(zf, of);
+ }
+ try (var jf = new JarFile(signer + ".jar")) {
+ var je = jf.getJarEntry("a");
+ jf.getInputStream(je).readAllBytes();
+ Asserts.assertEquals(1, je.getCodeSigners().length);
+ checkDigestAlgorithm(jf, signer, KnownOIDs.SHA_512);
+ }
+ }
+ }
+
+ static void testTool() throws Exception {
+ for (var signer : SIGNERS) {
+ SecurityTools.jarsigner("-keystore ks -storepass changeit a.jar " + signer)
+ .shouldHaveExitValue(0);
+ }
+ SecurityTools.jarsigner("-verify a.jar -verbose -certs")
+ .shouldHaveExitValue(0)
+ .shouldContain("jar verified");
+
+ try (var jf = new JarFile("a.jar")) {
+ var je = jf.getJarEntry("a");
+ jf.getInputStream(je).readAllBytes();
+ Asserts.assertEquals(3, je.getCodeSigners().length);
+ for (var signer : SIGNERS) {
+ checkDigestAlgorithm(jf, signer, KnownOIDs.SHA_512);
+ }
+ }
+ }
+
+ static void testDisabled() throws Exception {
+
+ // All disabled
+ Files.writeString(Paths.get("my.security"),
+ "jdk.jar.disabledAlgorithms=ML-DSA");
+ SecurityTools.jarsigner("-J-Djava.security.properties=my.security" +
+ " -keystore ks -storepass changeit" +
+ " -verify a.jar -verbose -certs -strict")
+ .shouldHaveExitValue(16)
+ .shouldContain("ML-DSA-44 key (disabled)")
+ .shouldContain("ML-DSA-65 key (disabled)")
+ .shouldContain("ML-DSA-87 key (disabled)")
+ .shouldContain("The jar will be treated as unsigned");
+ // Need to launch in a new process because security property is
+ // read at the beginning
+ Proc.create("ML_DSA")
+ .secprop("jdk.jar.disabledAlgorithms", "ML-DSA")
+ .args("0")
+ .start()
+ .waitFor(0);
+
+ // One disabled, one made weak
+ Files.writeString(Paths.get("my.security"), """
+ jdk.jar.disabledAlgorithms=ML-DSA-44
+ jdk.security.legacyAlgorithms=ML-DSA-65
+ """);
+ SecurityTools.jarsigner("-J-Djava.security.properties=my.security" +
+ " -keystore ks -storepass changeit" +
+ " -verify a.jar -verbose -certs -strict")
+ .shouldHaveExitValue(0)
+ .shouldContain("ML-DSA-44 key (disabled)")
+ .shouldContain("ML-DSA-65 key (weak)")
+ .shouldContain("ML-DSA-87 key")
+ .shouldNotContain("ML-DSA-87 key (disabled)")
+ .shouldContain("jar verified.");
+ Proc.create("ML_DSA")
+ .secprop("jdk.jar.disabledAlgorithms", "ML-DSA-44")
+ .secprop("jdk.security.legacyAlgorithms", "ML-DSA-65")
+ .args("2") // weak still considered signer, disabled not
+ .start()
+ .waitFor(0);
+ }
+
+ static void checkDigestAlgorithm(JarFile jf, String alias, KnownOIDs digAlg)
+ throws Exception {
+ var p7 = jf.getInputStream(jf.getEntry("META-INF/" + alias + ".DSA"))
+ .readAllBytes();
+ // SignedData - digestAlgorithms
+ DerUtils.checkAlg(p7, "10100", digAlg);
+ // SignedData - signerInfos - digestAlgorithm
+ DerUtils.checkAlg(p7, "104020", digAlg);
+ // SignedData - signerInfos - signatureAlgorithm
+ DerUtils.checkAlg(p7, "104040", KnownOIDs.valueOf("ML_DSA_" + alias));
+ // SignedData - signerInfos - signedAttrs - CMSAlgorithmProtection - digestAlgorithm
+ DerUtils.checkAlg(p7, "1040321000", digAlg);
+ // SignedData - signerInfos - signedAttrs - CMSAlgorithmProtection - signatureAlgorithm
+ DerUtils.checkAlg(p7, "1040321010", KnownOIDs.valueOf("ML_DSA_" + alias));
+ }
+}
diff --git a/test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java b/test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java
index ac92e9429cae..9c41b177379a 100644
--- a/test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java
+++ b/test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
@@ -60,7 +60,7 @@ public class BulkOps {
static final int[] bytes = new int[ELEM_SIZE];
static final MemorySegment bytesSegment = MemorySegment.ofArray(bytes);
- static final int UNSAFE_INT_OFFSET = unsafe.arrayBaseOffset(int[].class);
+ static final long UNSAFE_INT_OFFSET = unsafe.arrayBaseOffset(int[].class);
// large(ish) segments/buffers with same content, 0, for mismatch, non-multiple-of-8 sized
static final int SIZE_WITH_TAIL = (1024 * 1024) + 7;
diff --git a/test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java b/test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java
index 2b2be067fdcd..e6efbb998290 100644
--- a/test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java
+++ b/test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
@@ -61,7 +61,7 @@ public class LoopOverNonConstantHeap {
static final int ELEM_SIZE = 1_000_000;
static final int CARRIER_SIZE = (int)JAVA_INT.byteSize();
static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE;
- static final int UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class);
+ static final long UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class);
static final VarHandle VH_int = MemoryLayout.sequenceLayout(JAVA_INT).varHandle(int.class, sequenceElement());
MemorySegment segment;