1
1
/*
2
- * Copyright (c) 2005, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2005, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -603,21 +603,21 @@ static void test_create_signature_enveloped_dsa(int size) throws Exception {
603
603
static void test_create_signature_enveloping_b64_dsa () throws Exception {
604
604
System .out .println ("* Generating signature-enveloping-b64-dsa.xml" );
605
605
test_create_signature_enveloping
606
- (sha1 , dsaSha1 , dsa1024 , signingKey , kvks , true );
606
+ (sha1 , dsaSha1 , dsa1024 , signingKey , kvks , true , true );
607
607
System .out .println ();
608
608
}
609
609
610
610
static void test_create_signature_enveloping_dsa () throws Exception {
611
611
System .out .println ("* Generating signature-enveloping-dsa.xml" );
612
612
test_create_signature_enveloping
613
- (sha1 , dsaSha1 , dsa1024 , signingKey , kvks , false );
613
+ (sha1 , dsaSha1 , dsa1024 , signingKey , kvks , false , true );
614
614
System .out .println ();
615
615
}
616
616
617
617
static void test_create_signature_enveloping_sha256_dsa () throws Exception {
618
618
System .out .println ("* Generating signature-enveloping-sha256-dsa.xml" );
619
619
test_create_signature_enveloping
620
- (sha256 , dsaSha1 , dsa1024 , signingKey , kvks , false );
620
+ (sha256 , dsaSha1 , dsa1024 , signingKey , kvks , false , true );
621
621
System .out .println ();
622
622
}
623
623
@@ -626,7 +626,7 @@ static void test_create_signature_enveloping_hmac_sha1_40()
626
626
System .out .println ("* Generating signature-enveloping-hmac-sha1-40.xml" );
627
627
try {
628
628
test_create_signature_enveloping (sha1 , hmacSha1 , null ,
629
- getSecretKey ("secret" .getBytes ("ASCII" )), sks , false );
629
+ getSecretKey ("secret" .getBytes ("ASCII" )), sks , false , true );
630
630
} catch (Exception e ) {
631
631
if (!(e instanceof XMLSignatureException )) {
632
632
throw e ;
@@ -639,199 +639,199 @@ static void test_create_signature_enveloping_hmac_sha256()
639
639
throws Exception {
640
640
System .out .println ("* Generating signature-enveloping-hmac-sha256.xml" );
641
641
test_create_signature_enveloping (sha1 , hmacSha256 , null ,
642
- getSecretKey ("secret" .getBytes ("ASCII" )), sks , false );
642
+ getSecretKey ("secret" .getBytes ("ASCII" )), sks , false , true );
643
643
System .out .println ();
644
644
}
645
645
646
646
static void test_create_signature_enveloping_hmac_sha224 ()
647
647
throws Exception {
648
648
System .out .println ("* Generating signature-enveloping-hmac-sha224.xml" );
649
649
test_create_signature_enveloping (sha1 , hmacSha224 , null ,
650
- getSecretKey ("secret" .getBytes ("ASCII" )), sks , false );
650
+ getSecretKey ("secret" .getBytes ("ASCII" )), sks , false , true );
651
651
System .out .println ();
652
652
}
653
653
654
654
static void test_create_signature_enveloping_hmac_sha384 ()
655
655
throws Exception {
656
656
System .out .println ("* Generating signature-enveloping-hmac-sha384.xml" );
657
657
test_create_signature_enveloping (sha1 , hmacSha384 , null ,
658
- getSecretKey ("secret" .getBytes ("ASCII" )), sks , false );
658
+ getSecretKey ("secret" .getBytes ("ASCII" )), sks , false , true );
659
659
System .out .println ();
660
660
}
661
661
662
662
static void test_create_signature_enveloping_hmac_sha512 ()
663
663
throws Exception {
664
664
System .out .println ("* Generating signature-enveloping-hmac-sha512.xml" );
665
665
test_create_signature_enveloping (sha1 , hmacSha512 , null ,
666
- getSecretKey ("secret" .getBytes ("ASCII" )), sks , false );
666
+ getSecretKey ("secret" .getBytes ("ASCII" )), sks , false , true );
667
667
System .out .println ();
668
668
}
669
669
670
670
static void test_create_signature_enveloping_rsa () throws Exception {
671
671
System .out .println ("* Generating signature-enveloping-rsa.xml" );
672
672
test_create_signature_enveloping (sha1 , rsaSha1 , rsa ,
673
- getPrivateKey ("RSA" , 512 ), kvks , false );
673
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
674
674
System .out .println ();
675
675
}
676
676
677
677
static void test_create_signature_enveloping_sha384_rsa_sha256 ()
678
678
throws Exception {
679
679
System .out .println ("* Generating signature-enveloping-sha384-rsa_sha256.xml" );
680
680
test_create_signature_enveloping (sha384 , rsaSha256 , rsa ,
681
- getPrivateKey ("RSA" , 512 ), kvks , false );
681
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
682
682
System .out .println ();
683
683
}
684
684
685
685
static void test_create_signature_enveloping_sha224_rsa_sha256 ()
686
686
throws Exception {
687
687
System .out .println ("* Generating signature-enveloping-sha224-rsa_sha256.xml" );
688
688
test_create_signature_enveloping (sha224 , rsaSha256 , rsa ,
689
- getPrivateKey ("RSA" , 512 ), kvks , false );
689
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
690
690
System .out .println ();
691
691
}
692
692
693
693
static void test_create_signature_enveloping_sha3_224_rsa_sha256 ()
694
694
throws Exception {
695
695
System .out .println ("* Generating signature-enveloping-sha3_224-rsa_sha256.xml" );
696
696
test_create_signature_enveloping (sha3_224 , rsaSha256 , rsa ,
697
- getPrivateKey ("RSA" , 512 ), kvks , false );
697
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
698
698
System .out .println ();
699
699
}
700
700
701
701
static void test_create_signature_enveloping_sha3_256_rsa_sha256 ()
702
702
throws Exception {
703
703
System .out .println ("* Generating signature-enveloping-sha3_256-rsa_sha256.xml" );
704
704
test_create_signature_enveloping (sha3_256 , rsaSha256 , rsa ,
705
- getPrivateKey ("RSA" , 512 ), kvks , false );
705
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
706
706
System .out .println ();
707
707
}
708
708
709
709
static void test_create_signature_enveloping_sha3_384_rsa_sha256 ()
710
710
throws Exception {
711
711
System .out .println ("* Generating signature-enveloping-sha3_384-rsa_sha256.xml" );
712
712
test_create_signature_enveloping (sha3_384 , rsaSha256 , rsa ,
713
- getPrivateKey ("RSA" , 512 ), kvks , false );
713
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
714
714
System .out .println ();
715
715
}
716
716
717
717
static void test_create_signature_enveloping_sha3_512_rsa_sha256 ()
718
718
throws Exception {
719
719
System .out .println ("* Generating signature-enveloping-sha3_512-rsa_sha256.xml" );
720
720
test_create_signature_enveloping (sha3_512 , rsaSha256 , rsa ,
721
- getPrivateKey ("RSA" , 512 ), kvks , false );
721
+ getPrivateKey ("RSA" , 512 ), kvks , false , false );
722
722
System .out .println ();
723
723
}
724
724
725
725
static void test_create_signature_enveloping_sha512_rsa_sha384 ()
726
726
throws Exception {
727
727
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha384.xml" );
728
728
test_create_signature_enveloping (sha512 , rsaSha384 , rsa1024 ,
729
- getPrivateKey ("RSA" , 1024 ), kvks , false );
729
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
730
730
System .out .println ();
731
731
}
732
732
733
733
static void test_create_signature_enveloping_sha512_rsa_sha224 ()
734
734
throws Exception {
735
735
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha224.xml" );
736
736
test_create_signature_enveloping (sha512 , rsaSha224 , rsa1024 ,
737
- getPrivateKey ("RSA" , 1024 ), kvks , false );
737
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
738
738
System .out .println ();
739
739
}
740
740
741
741
static void test_create_signature_enveloping_sha512_rsa_sha512 ()
742
742
throws Exception {
743
743
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha512.xml" );
744
744
test_create_signature_enveloping (sha512 , rsaSha512 , rsa1024 ,
745
- getPrivateKey ("RSA" , 1024 ), kvks , false );
745
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
746
746
System .out .println ();
747
747
}
748
748
749
749
static void test_create_signature_enveloping_sha512_rsa_sha1_mgf1 ()
750
750
throws Exception {
751
751
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha1_mgf1.xml" );
752
752
test_create_signature_enveloping (sha512 , rsaSha1mgf1 , rsa1024 ,
753
- getPrivateKey ("RSA" , 1024 ), kvks , false );
753
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
754
754
System .out .println ();
755
755
}
756
756
757
757
static void test_create_signature_enveloping_sha512_rsa_sha224_mgf1 ()
758
758
throws Exception {
759
759
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha224_mgf1.xml" );
760
760
test_create_signature_enveloping (sha512 , rsaSha224mgf1 , rsa1024 ,
761
- getPrivateKey ("RSA" , 1024 ), kvks , false );
761
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
762
762
System .out .println ();
763
763
}
764
764
765
765
static void test_create_signature_enveloping_sha512_rsa_sha256_mgf1 ()
766
766
throws Exception {
767
767
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha256_mgf1.xml" );
768
768
test_create_signature_enveloping (sha512 , rsaSha256mgf1 , rsa1024 ,
769
- getPrivateKey ("RSA" , 1024 ), kvks , false );
769
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
770
770
System .out .println ();
771
771
}
772
772
773
773
static void test_create_signature_enveloping_sha512_rsa_sha384_mgf1 ()
774
774
throws Exception {
775
775
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha384_mgf1.xml" );
776
776
test_create_signature_enveloping (sha512 , rsaSha384mgf1 , rsa1024 ,
777
- getPrivateKey ("RSA" , 1024 ), kvks , false );
777
+ getPrivateKey ("RSA" , 1024 ), kvks , false , true );
778
778
System .out .println ();
779
779
}
780
780
781
781
static void test_create_signature_enveloping_sha512_rsa_sha512_mgf1 ()
782
782
throws Exception {
783
783
System .out .println ("* Generating signature-enveloping-sha512-rsa_sha512_mgf1.xml" );
784
784
test_create_signature_enveloping (sha512 , rsaSha512mgf1 , rsa2048 ,
785
- getPrivateKey ("RSA" , 2048 ), kvks , false );
785
+ getPrivateKey ("RSA" , 2048 ), kvks , false , true );
786
786
System .out .println ();
787
787
}
788
788
789
789
static void test_create_signature_enveloping_p256_sha1 () throws Exception {
790
790
System .out .println ("* Generating signature-enveloping-p256-sha1.xml" );
791
791
test_create_signature_enveloping (sha1 , ecdsaSha1 , p256ki ,
792
- getECPrivateKey ("P256" ), kvks , false );
792
+ getECPrivateKey ("P256" ), kvks , false , true );
793
793
System .out .println ();
794
794
}
795
795
796
796
static void test_create_signature_enveloping_p256_sha224 () throws Exception {
797
797
System .out .println ("* Generating signature-enveloping-p256-sha224.xml" );
798
798
test_create_signature_enveloping (sha1 , ecdsaSha224 , p256ki ,
799
- getECPrivateKey ("P256" ), kvks , false );
799
+ getECPrivateKey ("P256" ), kvks , false , true );
800
800
System .out .println ();
801
801
}
802
802
803
803
static void test_create_signature_enveloping_p256_sha256 () throws Exception {
804
804
System .out .println ("* Generating signature-enveloping-p256-sha256.xml" );
805
805
test_create_signature_enveloping (sha1 , ecdsaSha256 , p256ki ,
806
- getECPrivateKey ("P256" ), kvks , false );
806
+ getECPrivateKey ("P256" ), kvks , false , true );
807
807
System .out .println ();
808
808
}
809
809
810
810
static void test_create_signature_enveloping_p256_sha384 () throws Exception {
811
811
System .out .println ("* Generating signature-enveloping-p256-sha384.xml" );
812
812
test_create_signature_enveloping (sha1 , ecdsaSha384 , p256ki ,
813
- getECPrivateKey ("P256" ), kvks , false );
813
+ getECPrivateKey ("P256" ), kvks , false , true );
814
814
System .out .println ();
815
815
}
816
816
817
817
static void test_create_signature_enveloping_p256_sha512 () throws Exception {
818
818
System .out .println ("* Generating signature-enveloping-p256-sha512.xml" );
819
819
test_create_signature_enveloping (sha1 , ecdsaSha512 , p256ki ,
820
- getECPrivateKey ("P256" ), kvks , false );
820
+ getECPrivateKey ("P256" ), kvks , false , true );
821
821
System .out .println ();
822
822
}
823
823
824
824
static void test_create_signature_enveloping_p384_sha1 () throws Exception {
825
825
System .out .println ("* Generating signature-enveloping-p384-sha1.xml" );
826
826
test_create_signature_enveloping (sha1 , ecdsaSha1 , p384ki ,
827
- getECPrivateKey ("P384" ), kvks , false );
827
+ getECPrivateKey ("P384" ), kvks , false , true );
828
828
System .out .println ();
829
829
}
830
830
831
831
static void test_create_signature_enveloping_p521_sha1 () throws Exception {
832
832
System .out .println ("* Generating signature-enveloping-p521-sha1.xml" );
833
833
test_create_signature_enveloping (sha1 , ecdsaSha1 , p521ki ,
834
- getECPrivateKey ("P521" ), kvks , false );
834
+ getECPrivateKey ("P521" ), kvks , false , true );
835
835
System .out .println ();
836
836
}
837
837
@@ -963,6 +963,7 @@ static void test_create_signature_reference_dependency() throws Exception {
963
963
964
964
DOMValidateContext dvc = new DOMValidateContext
965
965
(kvks , doc .getDocumentElement ());
966
+ dvc .setProperty ("org.jcp.xml.dsig.secureValidation" , false );
966
967
XMLSignature sig2 = fac .unmarshalXMLSignature (dvc );
967
968
968
969
if (sig .equals (sig2 ) == false ) {
@@ -1010,6 +1011,7 @@ static void test_create_signature_with_attr_in_no_namespace()
1010
1011
1011
1012
DOMValidateContext dvc = new DOMValidateContext
1012
1013
(kvks , doc .getDocumentElement ());
1014
+ dvc .setProperty ("org.jcp.xml.dsig.secureValidation" , false );
1013
1015
dvc .setIdAttributeNS (nc , null , "Id" );
1014
1016
XMLSignature sig2 = fac .unmarshalXMLSignature (dvc );
1015
1017
@@ -1451,7 +1453,7 @@ private static void dumpDocument(Document doc, Writer w) throws Exception {
1451
1453
1452
1454
private static void test_create_signature_enveloping
1453
1455
(DigestMethod dm , SignatureMethod sm , KeyInfo ki , Key signingKey ,
1454
- KeySelector ks , boolean b64 ) throws Exception {
1456
+ KeySelector ks , boolean b64 , boolean secVal ) throws Exception {
1455
1457
1456
1458
// create reference
1457
1459
Reference ref ;
@@ -1486,6 +1488,7 @@ private static void dumpDocument(Document doc, Writer w) throws Exception {
1486
1488
1487
1489
DOMValidateContext dvc = new DOMValidateContext
1488
1490
(ks , doc .getDocumentElement ());
1491
+ dvc .setProperty ("org.jcp.xml.dsig.secureValidation" , secVal );
1489
1492
XMLSignature sig2 = fac .unmarshalXMLSignature (dvc );
1490
1493
1491
1494
if (sig .equals (sig2 ) == false ) {
0 commit comments