1919import java .security .spec .MGF1ParameterSpec ;
2020import java .security .spec .PSSParameterSpec ;
2121import java .util .HashMap ;
22+ import java .util .LinkedHashMap ;
2223import java .util .List ;
2324import java .util .Map ;
2425
4142import org .bouncycastle .jcajce .util .SpecUtil ;
4243import org .bouncycastle .util .Arrays ;
4344import org .bouncycastle .util .Exceptions ;
44- import org .bouncycastle .util .Strings ;
4545import org .bouncycastle .util .encoders .Hex ;
4646
4747/**
@@ -53,7 +53,7 @@ public class SignatureSpi
5353 //the byte encoding of the ASCII string "CompositeAlgorithmSignatures2025"
5454 private static final byte [] prefix = Hex .decode ("436f6d706f73697465416c676f726974686d5369676e61747572657332303235" );
5555 private static final Map <String , String > canonicalNames = new HashMap <String , String >();
56- private static final HashMap <ASN1ObjectIdentifier , byte []> domainSeparators = new HashMap <ASN1ObjectIdentifier , byte []>();
56+ private static final HashMap <ASN1ObjectIdentifier , byte []> domainSeparators = new LinkedHashMap <ASN1ObjectIdentifier , byte []>();
5757 private static final HashMap <ASN1ObjectIdentifier , AlgorithmParameterSpec > algorithmsParameterSpecs = new HashMap <ASN1ObjectIdentifier , AlgorithmParameterSpec >();
5858 private static final String ML_DSA_44 = "ML-DSA-44" ;
5959 private static final String ML_DSA_65 = "ML-DSA-65" ;
@@ -69,25 +69,25 @@ public class SignatureSpi
6969 canonicalNames .put (NISTObjectIdentifiers .id_ml_dsa_44 .getId (), ML_DSA_44 );
7070 canonicalNames .put (NISTObjectIdentifiers .id_ml_dsa_65 .getId (), ML_DSA_65 );
7171 canonicalNames .put (NISTObjectIdentifiers .id_ml_dsa_87 .getId (), ML_DSA_87 );
72-
73- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_RSA2048_PSS_SHA256 , Strings . toByteArray ( " COMPSIG-MLDSA44-RSA2048-PSS-SHA256" ));
74- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_RSA2048_PKCS15_SHA256 , Strings . toByteArray ( " COMPSIG-MLDSA44-RSA2048-PKCS15-SHA256" ));
75- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_Ed25519_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA44-Ed25519-SHA512" ));
76- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_ECDSA_P256_SHA256 , Strings . toByteArray ( " COMPSIG-MLDSA44-ECDSA-P256-SHA256" ));
77- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA3072_PSS_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-RSA3072-PSS-SHA512" ));
78- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA3072_PKCS15_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-RSA3072-PKCS15-SHA512" ));
79- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA4096_PSS_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-RSA4096-PSS-SHA512" ));
80- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA4096_PKCS15_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-RSA4096-PKCS15-SHA512" ));
81- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_P256_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-ECDSA-P256-SHA512" ));
82- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_P384_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-ECDSA-P384-SHA512" ));
83- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_brainpoolP256r1_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-ECDSA-BP256-SHA512" ));
84- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_Ed25519_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA65-Ed25519-SHA512" ));
85- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_brainpoolP384r1_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA87-ECDSA-BP384-SHA512" ));
86- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_Ed448_SHAKE256 , Strings . toByteArray ( " COMPSIG-MLDSA87-Ed448-SHAKE256" ));
87- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_RSA3072_PSS_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA87-RSA3072-PSS-SHA512" ));
88- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_RSA4096_PSS_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA87-RSA4096-PSS-SHA512" ));
89- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_P384_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA87-ECDSA-P384-SHA512" ));
90- domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_P521_SHA512 , Strings . toByteArray ( " COMPSIG-MLDSA87-ECDSA-P521-SHA512" ));
72+
73+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_RSA2048_PSS_SHA256 , Hex . decode ( "434f4d505349472d4d4c44534134342d525341323034382d5053532d534841323536" )); // COMPSIG-MLDSA44-RSA2048-PSS-SHA256
74+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_RSA2048_PKCS15_SHA256 , Hex . decode ( "434f4d505349472d4d4c44534134342d525341323034382d504b435331352d534841323536" )); // COMPSIG-MLDSA44-RSA2048-PKCS15-SHA256
75+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_Ed25519_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534134342d456432353531392d534841353132" )); // COMPSIG-MLDSA44-Ed25519-SHA512
76+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA44_ECDSA_P256_SHA256 , Hex . decode ( "434f4d505349472d4d4c44534134342d45434453412d503235362d534841323536" )); // COMPSIG-MLDSA44-ECDSA-P256-SHA256
77+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA3072_PSS_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d525341333037322d5053532d534841353132" )); // COMPSIG-MLDSA65-RSA3072-PSS-SHA512
78+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA3072_PKCS15_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d525341333037322d504b435331352d534841353132" )); // COMPSIG-MLDSA65-RSA3072-PKCS15-SHA512
79+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA4096_PSS_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d525341343039362d5053532d534841353132" )); // COMPSIG-MLDSA65-RSA4096-PSS-SHA512
80+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_RSA4096_PKCS15_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d525341343039362d504b435331352d534841353132" )); // COMPSIG-MLDSA65-RSA4096-PKCS15-SHA512
81+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_P256_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d45434453412d503235362d534841353132" )); // COMPSIG-MLDSA65-ECDSA-P256-SHA512
82+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_P384_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d45434453412d503338342d534841353132" )); // COMPSIG-MLDSA65-ECDSA-P384-SHA512
83+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_ECDSA_brainpoolP256r1_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d45434453412d42503235362d534841353132" )); // COMPSIG-MLDSA65-ECDSA-BP256-SHA512
84+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA65_Ed25519_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534136352d456432353531392d534841353132" )); // COMPSIG-MLDSA65-Ed25519-SHA512
85+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_brainpoolP384r1_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534138372d45434453412d42503338342d534841353132" )); // COMPSIG-MLDSA87-ECDSA-BP384-SHA512
86+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_Ed448_SHAKE256 , Hex . decode ( "434f4d505349472d4d4c44534138372d45643434382d5348414b45323536" )); // COMPSIG-MLDSA87-Ed448-SHAKE256
87+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_RSA3072_PSS_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534138372d525341333037322d5053532d534841353132" )); // COMPSIG-MLDSA87-RSA3072-PSS-SHA512
88+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_RSA4096_PSS_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534138372d525341343039362d5053532d534841353132" )); // COMPSIG-MLDSA87-RSA4096-PSS-SHA512
89+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_P384_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534138372d45434453412d503338342d534841353132" )); // COMPSIG-MLDSA87-ECDSA-P384-SHA512
90+ domainSeparators .put (IANAObjectIdentifiers .id_MLDSA87_ECDSA_P521_SHA512 , Hex . decode ( "434f4d505349472d4d4c44534138372d45434453412d503532312d534841353132" )); // COMPSIG-MLDSA87-ECDSA-P521-SHA512
9191
9292 algorithmsParameterSpecs .put (IANAObjectIdentifiers .id_MLDSA44_RSA2048_PSS_SHA256 ,
9393 new PSSParameterSpec ("SHA-256" , "MGF1" , new MGF1ParameterSpec ("SHA-256" ), 32 , 1 ));
0 commit comments