Crypto: Add CompatibleAlgorithms function
@@ -261,3 +261,19 @@ func NewSHA3_256() Hasher {
func NewSHA3_384() Hasher {
return hash.NewSHA3_384()
}
+
+// CompatibleAlgorithms returns true if the signature and hash algorithms are compatible.
+func CompatibleAlgorithms(sigAlgo SignatureAlgorithm, hashAlgo HashAlgorithm) bool {
+ switch sigAlgo {
+ case ECDSA_P256:
+ fallthrough
+ case ECDSA_secp256k1:
+ switch hashAlgo {
+ case SHA2_256:
+ fallthrough
+ case SHA3_256:
+ return true
+ }
+ }
+ return false
+}
