22using System . IO ;
33
44using Org . BouncyCastle . Asn1 ;
5+ using Org . BouncyCastle . Crypto . Digests ;
56using Org . BouncyCastle . Crypto . Parameters ;
67using Org . BouncyCastle . Crypto . Signers . SlhDsa ;
78using Org . BouncyCastle . Security ;
@@ -23,15 +24,41 @@ public sealed class HashSlhDsaSigner
2324 private SlhDsaEngine m_engine ;
2425
2526 public HashSlhDsaSigner ( SlhDsaParameters parameters , bool deterministic )
27+ : this ( parameters , deterministic ,
28+ DigestUtilities . GetDigest ( parameters . PreHashOid ) ,
29+ parameters . PreHashOid )
30+ {
31+ if ( parameters == null )
32+ throw new ArgumentNullException ( nameof ( parameters ) ) ;
33+ if ( parameters . PreHashOid == null )
34+ throw new ArgumentException ( "cannot be used for SLH-DSA" , nameof ( parameters ) ) ;
35+ }
36+
37+ public static HashSlhDsaSigner CreateRawSigner ( SlhDsaParameters parameters , bool deterministic )
2638 {
2739 if ( parameters == null )
2840 throw new ArgumentNullException ( nameof ( parameters ) ) ;
2941 if ( parameters . PreHashOid == null )
3042 throw new ArgumentException ( "cannot be used for SLH-DSA" , nameof ( parameters ) ) ;
3143
44+ return new HashSlhDsaSigner ( parameters , deterministic , new NullDigest ( ) , parameters . PreHashOid ) ;
45+ }
46+
47+ public static HashSlhDsaSigner CreateRawSigner ( SlhDsaParameters parametersWithoutPrehash , bool deterministic , DerObjectIdentifier preHashOid )
48+ {
49+ if ( parametersWithoutPrehash == null )
50+ throw new ArgumentNullException ( nameof ( parametersWithoutPrehash ) ) ;
51+ if ( preHashOid == null )
52+ throw new ArgumentNullException ( nameof ( preHashOid ) ) ;
53+
54+ return new HashSlhDsaSigner ( parametersWithoutPrehash , deterministic , new NullDigest ( ) , preHashOid ) ;
55+ }
56+
57+ private HashSlhDsaSigner ( SlhDsaParameters parameters , bool deterministic , IDigest preHashDigest , DerObjectIdentifier preHashOid )
58+ {
3259 m_parameters = parameters ;
33- m_preHashOidEncoding = parameters . PreHashOid . GetEncoded ( Asn1Encodable . Der ) ;
34- m_preHashDigest = DigestUtilities . GetDigest ( parameters . PreHashOid ) ;
60+ m_preHashOidEncoding = preHashOid . GetEncoded ( Asn1Encodable . Der ) ;
61+ m_preHashDigest = preHashDigest ;
3562 m_deterministic = deterministic ;
3663 }
3764
0 commit comments