@@ -144,6 +144,13 @@ public class NewSignedDataTest
144144 private static KeyPair _signEd448KP ;
145145 private static X509Certificate _signEd448Cert ;
146146
147+ private static KeyPair _signMLDsa44KP ;
148+ private static X509Certificate _signMLDsa44Cert ;
149+ private static KeyPair _signMLDsa65KP ;
150+ private static X509Certificate _signMLDsa65Cert ;
151+ private static KeyPair _signMLDsa87KP ;
152+ private static X509Certificate _signMLDsa87Cert ;
153+
147154 private static String _reciDN ;
148155 private static KeyPair _reciKP ;
149156 private static X509Certificate _reciCert ;
@@ -704,6 +711,9 @@ public class NewSignedDataTest
704711 noParams .add (NISTObjectIdentifiers .id_ecdsa_with_sha3_512 );
705712 noParams .add (EdECObjectIdentifiers .id_Ed25519 );
706713 noParams .add (EdECObjectIdentifiers .id_Ed448 );
714+ noParams .add (NISTObjectIdentifiers .id_ml_dsa_44 );
715+ noParams .add (NISTObjectIdentifiers .id_ml_dsa_65 );
716+ noParams .add (NISTObjectIdentifiers .id_ml_dsa_87 );
707717 }
708718
709719 public NewSignedDataTest (String name )
@@ -776,6 +786,15 @@ private static void init()
776786 _signEd448KP = CMSTestUtil .makeEd448KeyPair ();
777787 _signEd448Cert = CMSTestUtil .makeCertificate (_signEd448KP , _signDN , _origKP , _origDN );
778788
789+ _signMLDsa44KP = CMSTestUtil .makeMLDsa44KeyPair ();
790+ _signMLDsa44Cert = CMSTestUtil .makeCertificate (_signMLDsa44KP , _signDN , _origKP , _origDN );
791+
792+ _signMLDsa65KP = CMSTestUtil .makeMLDsa65KeyPair ();
793+ _signMLDsa65Cert = CMSTestUtil .makeCertificate (_signMLDsa65KP , _signDN , _origKP , _origDN );
794+
795+ _signMLDsa87KP = CMSTestUtil .makeMLDsa87KeyPair ();
796+ _signMLDsa87Cert = CMSTestUtil .makeCertificate (_signMLDsa87KP , _signDN , _origKP , _origDN );
797+
779798 _reciDN = "CN=Doug, OU=Sales, O=Bouncy Castle, C=AU" ;
780799 _reciKP = CMSTestUtil .makeKeyPair ();
781800 _reciCert = CMSTestUtil .makeCertificate (_reciKP , _reciDN , _signKP , _signDN );
@@ -1789,13 +1808,32 @@ public void testSHA512_256ithRSADigest()
17891808 public void testEd25519 ()
17901809 throws Exception
17911810 {
1792- encapsulatedTest (_signEd25519KP , _signEd25519Cert , "Ed25519" , EdECObjectIdentifiers .id_Ed25519 , new AlgorithmIdentifier (NISTObjectIdentifiers .id_sha512 ));
1811+ /*
1812+ * RFC 8419 3.1. When signing with Ed25519, the digestAlgorithm MUST be id-sha512, and the algorithm
1813+ * parameters field MUST be absent.
1814+ *
1815+ * We confirm here that our implementation defaults to SHA-512 for the digest algorithm.
1816+ */
1817+ AlgorithmIdentifier expectedDigAlgId = new AlgorithmIdentifier (NISTObjectIdentifiers .id_sha512 );
1818+
1819+ encapsulatedTest (_signEd25519KP , _signEd25519Cert , "Ed25519" , EdECObjectIdentifiers .id_Ed25519 ,
1820+ expectedDigAlgId );
17931821 }
17941822
17951823 public void testEd448 ()
17961824 throws Exception
17971825 {
1798- encapsulatedTest (_signEd448KP , _signEd448Cert , "Ed448" , EdECObjectIdentifiers .id_Ed448 , new AlgorithmIdentifier (NISTObjectIdentifiers .id_shake256_len , new ASN1Integer (512 )));
1826+ /*
1827+ * RFC 8419 3.1. When signing with Ed448, the digestAlgorithm MUST be id-shake256-len, the algorithm
1828+ * parameters field MUST be present, and the parameter MUST contain 512, encoded as a positive integer
1829+ * value.
1830+ *
1831+ * We confirm here that our implementation defaults to id-shake256-len/512 for the digest algorithm.
1832+ */
1833+ AlgorithmIdentifier expectedDigAlgId = new AlgorithmIdentifier (NISTObjectIdentifiers .id_shake256_len ,
1834+ new ASN1Integer (512 ));
1835+
1836+ encapsulatedTest (_signEd448KP , _signEd448Cert , "Ed448" , EdECObjectIdentifiers .id_Ed448 , expectedDigAlgId );
17991837 }
18001838
18011839 public void testDetachedEd25519 ()
@@ -2270,6 +2308,57 @@ public SignerInformationVerifier get(SignerId signerId)
22702308 assertTrue (digAlgs .contains (new AlgorithmIdentifier (TeleTrusTObjectIdentifiers .ripemd160 , DERNull .INSTANCE )));
22712309 }
22722310
2311+ // public void testMLDsa44()
2312+ // throws Exception
2313+ // {
2314+ // /*
2315+ // * draft-ietf-lamps-cms-ml-dsa-02 3.3. SHA-512 [FIPS180] MUST be supported for use with the variants
2316+ // * of ML-DSA in this document; however, other hash functions MAY also be supported. When SHA-512 is
2317+ // * used, the id-sha512 [RFC5754] digest algorithm identifier is used and the parameters field MUST be
2318+ // * omitted.
2319+ // *
2320+ // * We confirm here that our implementation defaults to SHA-512 for the digest algorithm.
2321+ // */
2322+ // AlgorithmIdentifier expectedDigAlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512);
2323+ //
2324+ // encapsulatedTest(_signMLDsa44KP, _signMLDsa44Cert, "ML-DSA-44", NISTObjectIdentifiers.id_ml_dsa_44,
2325+ // expectedDigAlgId);
2326+ // }
2327+ //
2328+ // public void testMLDsa65()
2329+ // throws Exception
2330+ // {
2331+ // /*
2332+ // * draft-ietf-lamps-cms-ml-dsa-02 3.3. SHA-512 [FIPS180] MUST be supported for use with the variants
2333+ // * of ML-DSA in this document; however, other hash functions MAY also be supported. When SHA-512 is
2334+ // * used, the id-sha512 [RFC5754] digest algorithm identifier is used and the parameters field MUST be
2335+ // * omitted.
2336+ // *
2337+ // * We confirm here that our implementation defaults to SHA-512 for the digest algorithm.
2338+ // */
2339+ // AlgorithmIdentifier expectedDigAlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512);
2340+ //
2341+ // encapsulatedTest(_signMLDsa65KP, _signMLDsa65Cert, "ML-DSA-65", NISTObjectIdentifiers.id_ml_dsa_65,
2342+ // expectedDigAlgId);
2343+ // }
2344+ //
2345+ // public void testMLDsa87()
2346+ // throws Exception
2347+ // {
2348+ // /*
2349+ // * draft-ietf-lamps-cms-ml-dsa-02 3.3. SHA-512 [FIPS180] MUST be supported for use with the variants
2350+ // * of ML-DSA in this document; however, other hash functions MAY also be supported. When SHA-512 is
2351+ // * used, the id-sha512 [RFC5754] digest algorithm identifier is used and the parameters field MUST be
2352+ // * omitted.
2353+ // *
2354+ // * We confirm here that our implementation defaults to SHA-512 for the digest algorithm.
2355+ // */
2356+ // AlgorithmIdentifier expectedDigAlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512);
2357+ //
2358+ // encapsulatedTest(_signMLDsa87KP, _signMLDsa87Cert, "ML-DSA-87", NISTObjectIdentifiers.id_ml_dsa_87,
2359+ // expectedDigAlgId);
2360+ // }
2361+
22732362 private void rsaPSSTest (String signatureAlgorithmName )
22742363 throws Exception
22752364 {
0 commit comments