-/* $OpenBSD: wycheproof.go,v 1.144 2023/04/17 15:11:00 tb Exp $ */
+/* $OpenBSD: wycheproof.go,v 1.145 2023/04/25 15:56:56 tb Exp $ */
/*
* Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org>
"SHA-256": C.NID_sha256,
"SHA-384": C.NID_sha384,
"SHA-512": C.NID_sha512,
+ "SHA-512/224": C.NID_sha512_224,
+ "SHA-512/256": C.NID_sha512_256,
+ "SHA3-224": C.NID_sha3_224,
+ "SHA3-256": C.NID_sha3_256,
+ "SHA3-384": C.NID_sha3_384,
+ "SHA3-512": C.NID_sha3_512,
}
func nidFromString(ns string) (int, error) {
return C.EVP_sha384(), nil
case "SHA-512":
return C.EVP_sha512(), nil
+ case "SHA-512/224":
+ return C.EVP_sha512_224(), nil
+ case "SHA-512/256":
+ return C.EVP_sha512_256(), nil
+ case "SHA3-224":
+ return C.EVP_sha3_224(), nil
+ case "SHA3-256":
+ return C.EVP_sha3_256(), nil
+ case "SHA3-384":
+ return C.EVP_sha3_384(), nil
+ case "SHA3-512":
+ return C.EVP_sha3_512(), nil
default:
return nil, fmt.Errorf("unknown hash %q", hs)
}
func runHmacTestGroup(algorithm string, wtg *wycheproofTestGroupHmac) bool {
fmt.Printf("Running %v test group %v with key size %d and tag size %d...\n", algorithm, wtg.Type, wtg.KeySize, wtg.TagSize)
- md, err := hashEvpMdFromString("SHA-" + strings.TrimPrefix(algorithm, "HMACSHA"))
+ prefix := "SHA-"
+ if strings.HasPrefix(algorithm, "HMACSHA3-") {
+ prefix = "SHA"
+ }
+ md, err := hashEvpMdFromString(prefix + strings.TrimPrefix(algorithm, "HMACSHA"))
if err != nil {
log.Fatalf("Failed to get hash: %v", err)
}
wtg = &wycheproofTestGroupEdDSA{}
case "HKDF-SHA-1", "HKDF-SHA-256", "HKDF-SHA-384", "HKDF-SHA-512":
wtg = &wycheproofTestGroupHkdf{}
- case "HMACSHA1", "HMACSHA224", "HMACSHA256", "HMACSHA384", "HMACSHA512":
+ case "HMACSHA1", "HMACSHA224", "HMACSHA256", "HMACSHA384", "HMACSHA512", "HMACSHA3-224", "HMACSHA3-256", "HMACSHA3-384", "HMACSHA3-512":
wtg = &wycheproofTestGroupHmac{}
case "KW":
wtg = &wycheproofTestGroupKW{}
return runEdDSATestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupEdDSA))
case "HKDF-SHA-1", "HKDF-SHA-256", "HKDF-SHA-384", "HKDF-SHA-512":
return runHkdfTestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupHkdf))
- case "HMACSHA1", "HMACSHA224", "HMACSHA256", "HMACSHA384", "HMACSHA512":
+ case "HMACSHA1", "HMACSHA224", "HMACSHA256", "HMACSHA384", "HMACSHA512", "HMACSHA3-224", "HMACSHA3-256", "HMACSHA3-384", "HMACSHA3-512":
return runHmacTestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupHmac))
case "KW":
return runKWTestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupKW))
testc = newTestCoordinator()
- skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sha3|sha512_(224|256)|sect\d{3}[rk]1)_`)
+ skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sect\d{3}[rk]1)_`)
for _, test := range tests {
tvs, err := filepath.Glob(filepath.Join(testVectorPath, test.pattern))