@@ -20,6 +20,16 @@ const (
2020 SignatureHeader = "Signature"
2121)
2222
23+ // RFC 9421 Algorithm Names (Section 6.2.2 Initial Contents)
24+ const (
25+ AlgorithmRSAPSSSHA512 = "rsa-pss-sha512" // Section 3.3.1
26+ AlgorithmRSAV15SHA256 = "rsa-v1_5-sha256" // Section 3.3.2
27+ AlgorithmHMACSHA256 = "hmac-sha256" // Section 3.3.3
28+ AlgorithmECDSAP256SHA256 = "ecdsa-p256-sha256" // Section 3.3.4
29+ AlgorithmECDSAP384SHA384 = "ecdsa-p384-sha384" // Section 3.3.5
30+ AlgorithmEd25519 = "ed25519" // Section 3.3.6
31+ )
32+
2333// KeyResolver interface allows resolving cryptographic keys by their ID
2434type KeyResolver interface {
2535 ResolveKey (keyID string ) (any , error )
@@ -233,17 +243,17 @@ func determineAlgorithm(def *input.Definition, key any) (string, error) {
233243func convertRFC9421ToDSIG (rfc9421Alg string ) (string , error ) {
234244 switch rfc9421Alg {
235245 // Official RFC 9421 algorithms from Section 6.2.2 Initial Contents
236- case "rsa-pss-sha512" : // Section 3.3.1
246+ case AlgorithmRSAPSSSHA512 : // Section 3.3.1
237247 return dsig .RSAPSSWithSHA512 , nil
238- case "rsa-v1_5-sha256" : // Section 3.3.2
248+ case AlgorithmRSAV15SHA256 : // Section 3.3.2
239249 return dsig .RSAPKCS1v15WithSHA256 , nil
240- case "hmac-sha256" : // Section 3.3.3
250+ case AlgorithmHMACSHA256 : // Section 3.3.3
241251 return dsig .HMACWithSHA256 , nil
242- case "ecdsa-p256-sha256" : // Section 3.3.4
252+ case AlgorithmECDSAP256SHA256 : // Section 3.3.4
243253 return dsig .ECDSAWithP256AndSHA256 , nil
244- case "ecdsa-p384-sha384" : // Section 3.3.5
254+ case AlgorithmECDSAP384SHA384 : // Section 3.3.5
245255 return dsig .ECDSAWithP384AndSHA384 , nil
246- case "ed25519" : // Section 3.3.6
256+ case AlgorithmEd25519 : // Section 3.3.6
247257 return dsig .EdDSA , nil
248258 default :
249259 return "" , fmt .Errorf ("unsupported RFC 9421 algorithm: %s" , rfc9421Alg )
0 commit comments