34
34
import sun .security .pkcs .PKCS9Attributes ;
35
35
import sun .security .timestamp .HttpTimestamper ;
36
36
import sun .security .tools .PathList ;
37
- import sun .security .tools .jarsigner .TimestampedSigner ;
38
37
import sun .security .util .Event ;
39
38
import sun .security .util .ManifestDigester ;
40
39
import sun .security .util .SignatureFileVerifier ;
@@ -122,7 +121,6 @@ public static class Builder {
122
121
String tSADigestAlg ;
123
122
boolean sectionsonly = false ;
124
123
boolean internalsf = false ;
125
- boolean directsign = false ;
126
124
String altSignerPath ;
127
125
String altSigner ;
128
126
@@ -358,10 +356,6 @@ public Builder eventHandler(BiConsumer<String,String> handler) {
358
356
* <li>"sectionsonly": "true" if the .SF file only contains the hash
359
357
* value for each section of the manifest and not for the whole
360
358
* manifest, "false" otherwise. Default "false".
361
- * <li>"directsign": "true" if the signature is calculated on the
362
- * content directly, "false" if it's calculated on signed attributes
363
- * which itself is calculated from the content and stored in the
364
- * signer's SignerInfo. Default "false".
365
359
* </ul>
366
360
* All property names are case-insensitive.
367
361
*
@@ -395,9 +389,6 @@ public Builder setProperty(String key, String value) {
395
389
case "sectionsonly" :
396
390
this .sectionsonly = parseBoolean ("sectionsonly" , value );
397
391
break ;
398
- case "directsign" :
399
- this .directsign = parseBoolean ("directsign" , value );
400
- break ;
401
392
case "altsignerpath" :
402
393
altSignerPath = value ;
403
394
break ;
@@ -510,7 +501,6 @@ public JarSigner build() {
510
501
private final String tSADigestAlg ;
511
502
private final boolean sectionsonly ; // do not "sign" the whole manifest
512
503
private final boolean internalsf ; // include the .SF inside the PKCS7 block
513
- private final boolean directsign ;
514
504
515
505
@ Deprecated (since ="16" , forRemoval =true )
516
506
private final String altSignerPath ;
@@ -561,9 +551,12 @@ private JarSigner(JarSigner.Builder builder) {
561
551
this .altSigner = builder .altSigner ;
562
552
this .altSignerPath = builder .altSignerPath ;
563
553
564
- this .directsign = this .altSigner != null
565
- ? true
566
- : builder .directsign ;
554
+ // altSigner cannot support modern algorithms like RSASSA-PSS and EdDSA
555
+ if (altSigner != null
556
+ && !sigalg .toUpperCase (Locale .ENGLISH ).contains ("WITH" )) {
557
+ throw new IllegalArgumentException (
558
+ "Customized ContentSigner is not supported for " + sigalg );
559
+ }
567
560
}
568
561
569
562
/**
@@ -666,8 +659,6 @@ public String getProperty(String key) {
666
659
return Boolean .toString (sectionsonly );
667
660
case "altsignerpath" :
668
661
return altSignerPath ;
669
- case "directsign" :
670
- return Boolean .toString (directsign );
671
662
case "altsigner" :
672
663
return altSigner ;
673
664
default :
@@ -855,20 +846,7 @@ private void sign0(ZipFile zipFile, OutputStream os)
855
846
sf .write (baos );
856
847
byte [] content = baos .toByteArray ();
857
848
858
- // Use new method if directSign is false or it's a modern
859
- // algorithm not supported by existing ContentSigner.
860
- // Make this always true after we remove ContentSigner.
861
- boolean useNewMethod = !directsign
862
- || !sigalg .toUpperCase (Locale .ENGLISH ).contains ("WITH" );
863
-
864
- // For newer sigalg without "with", always use the new PKCS7
865
- // generateToken method. Otherwise, use deprecated ContentSigner.
866
- if (useNewMethod ) {
867
- if (altSigner != null ) {
868
- throw new IllegalArgumentException (directsign
869
- ? ("Customized ContentSigner is not supported for " + sigalg )
870
- : "Customized ContentSigner does not support authenticated attributes" );
871
- }
849
+ if (altSigner == null ) {
872
850
Function <byte [], PKCS9Attributes > timestamper = null ;
873
851
if (tsaUrl != null ) {
874
852
timestamper = s -> {
@@ -889,7 +867,7 @@ private void sign0(ZipFile zipFile, OutputStream os)
889
867
}
890
868
// We now create authAttrs in block data, so "direct == false".
891
869
block = PKCS7 .generateNewSignedData (sigalg , sigProvider , privateKey , certChain ,
892
- content , internalsf , directsign , timestamper );
870
+ content , internalsf , false , timestamper );
893
871
} else {
894
872
Signature signer = SignatureUtil .fromKey (sigalg , privateKey , sigProvider );
895
873
signer .update (content );
@@ -901,9 +879,7 @@ private void sign0(ZipFile zipFile, OutputStream os)
901
879
tSADigestAlg , signature ,
902
880
signer .getAlgorithm (), certChain , content , zipFile );
903
881
@ SuppressWarnings ("removal" )
904
- ContentSigner signingMechanism = (altSigner != null )
905
- ? loadSigningMechanism (altSigner , altSignerPath )
906
- : new TimestampedSigner ();
882
+ ContentSigner signingMechanism = loadSigningMechanism (altSigner , altSignerPath );
907
883
block = signingMechanism .generateSignedData (
908
884
params ,
909
885
!internalsf ,
0 commit comments