Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -67,6 +67,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import jdk.security.jarsigner.JarSigner;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.util.JarUtils;
Expand Down Expand Up @@ -1430,7 +1431,9 @@ private SignItem digestAlgorithm(String digestAlgorithm) {
String expectedDigestAlg() {
return digestAlgorithm != null
? digestAlgorithm
: jdkInfo.majorVersion >= 20 ? "SHA-384" : "SHA-256";
: jdkInfo.majorVersion >= 20
? JarSigner.Builder.getDefaultDigestAlgorithm()
: "SHA-256";
}

private SignItem tsaDigestAlgorithm(String tsaDigestAlgorithm) {
Expand All @@ -1439,7 +1442,11 @@ private SignItem tsaDigestAlgorithm(String tsaDigestAlgorithm) {
}

String expectedTsaDigestAlg() {
return tsaDigestAlgorithm != null ? tsaDigestAlgorithm : "SHA-256";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually get it from jdk.security.jarsigner.JarSigner.Builder.getDefaultDigestAlgorithm().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code to use getDefaultDigestAlgorithm but I still need the version-check because this test invokes jarsigner in different JDKs that use different default algorithms.

return tsaDigestAlgorithm != null
? tsaDigestAlgorithm
: jdkInfo.majorVersion >= 20
? JarSigner.Builder.getDefaultDigestAlgorithm()
: "SHA-256";
}

private SignItem tsaIndex(int tsaIndex) {
Expand Down