summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2018-08-29 19:20:22 +0000
committertb <>2018-08-29 19:20:22 +0000
commit317d759d718aac9098f28c0717c932bef2e65de1 (patch)
tree42778157cc6e5215a20923d6240a356b13070a13 /src
parent261d8fa7686e3eb82020d3c6d5d7aacdb78e6eb7 (diff)
downloadopenbsd-317d759d718aac9098f28c0717c932bef2e65de1.tar.gz
openbsd-317d759d718aac9098f28c0717c932bef2e65de1.tar.bz2
openbsd-317d759d718aac9098f28c0717c932bef2e65de1.zip
Pass algorithm as a string to all *TestGroup functions for consistency.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index 55f6858e89..3aeea18e3f 100644
--- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
1/* $OpenBSD: wycheproof.go,v 1.35 2018/08/29 19:18:20 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.36 2018/08/29 19:20:22 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -377,8 +377,8 @@ func runAesCbcPkcs5Test(ctx *C.EVP_CIPHER_CTX, wt *wycheproofTestAesCbcPkcs5) bo
377 return openSuccess && sealSuccess 377 return openSuccess && sealSuccess
378} 378}
379 379
380func runAesCbcPkcs5TestGroup(wtg *wycheproofTestGroupAesCbcPkcs5) bool { 380func runAesCbcPkcs5TestGroup(algorithm string, wtg *wycheproofTestGroupAesCbcPkcs5) bool {
381 fmt.Printf("Running AES-CBC-PKCS5 test group %v with IV size %d and key size %d...\n", wtg.Type, wtg.IVSize, wtg.KeySize) 381 fmt.Printf("Running %v test group %v with IV size %d and key size %d...\n", algorithm, wtg.Type, wtg.IVSize, wtg.KeySize)
382 382
383 var cipher *C.EVP_CIPHER 383 var cipher *C.EVP_CIPHER
384 switch wtg.KeySize { 384 switch wtg.KeySize {
@@ -708,8 +708,8 @@ func runAesCmacTest(cipher *C.EVP_CIPHER, wt *wycheproofTestAesCmac) bool {
708 return success 708 return success
709} 709}
710 710
711func runAesCmacTestGroup(wtg *wycheproofTestGroupAesCmac) bool { 711func runAesCmacTestGroup(algorithm string, wtg *wycheproofTestGroupAesCmac) bool {
712 fmt.Printf("Running AES-CMAC test group %v with key size %d and tag size %d...\n", wtg.Type, wtg.KeySize, wtg.TagSize) 712 fmt.Printf("Running %v test group %v with key size %d and tag size %d...\n", algorithm, wtg.Type, wtg.KeySize, wtg.TagSize)
713 var cipher *C.EVP_CIPHER 713 var cipher *C.EVP_CIPHER
714 714
715 switch wtg.KeySize { 715 switch wtg.KeySize {
@@ -864,13 +864,13 @@ func runChaCha20Poly1305Test(iv_len int, key_len int, tag_len int, wt *wycheproo
864 return openSuccess && sealSuccess 864 return openSuccess && sealSuccess
865} 865}
866 866
867func runChaCha20Poly1305TestGroup(wtg *wycheproofTestGroupChaCha20Poly1305) bool { 867func runChaCha20Poly1305TestGroup(algorithm string, wtg *wycheproofTestGroupChaCha20Poly1305) bool {
868 // We currently only support nonces of length 12 (96 bits) 868 // We currently only support nonces of length 12 (96 bits)
869 if wtg.IVSize != 96 { 869 if wtg.IVSize != 96 {
870 return true 870 return true
871 } 871 }
872 872
873 fmt.Printf("Running ChaCha20-Poly1305 test group %v with IV size %d, key size %d, tag size %d...\n", wtg.Type, wtg.IVSize, wtg.KeySize, wtg.TagSize) 873 fmt.Printf("Running %v test group %v with IV size %d, key size %d, tag size %d...\n", algorithm, wtg.Type, wtg.IVSize, wtg.KeySize, wtg.TagSize)
874 874
875 success := true 875 success := true
876 for _, wt := range wtg.Tests { 876 for _, wt := range wtg.Tests {
@@ -915,8 +915,8 @@ func runDSATest(dsa *C.DSA, h hash.Hash, wt *wycheproofTestDSA) bool {
915 return success 915 return success
916} 916}
917 917
918func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { 918func runDSATestGroup(algorithm string, wtg *wycheproofTestGroupDSA) bool {
919 fmt.Printf("Running DSA test group %v, key size %d and %v...\n", wtg.Type, wtg.Key.KeySize, wtg.SHA) 919 fmt.Printf("Running %v test group %v, key size %d and %v...\n", algorithm, wtg.Type, wtg.Key.KeySize, wtg.SHA)
920 920
921 dsa := C.DSA_new() 921 dsa := C.DSA_new()
922 if dsa == nil { 922 if dsa == nil {
@@ -1049,13 +1049,13 @@ func runECDSATest(ecKey *C.EC_KEY, nid int, h hash.Hash, wt *wycheproofTestECDSA
1049 return success 1049 return success
1050} 1050}
1051 1051
1052func runECDSATestGroup(wtg *wycheproofTestGroupECDSA) bool { 1052func runECDSATestGroup(algorithm string, wtg *wycheproofTestGroupECDSA) bool {
1053 // No secp256r1 support. 1053 // No secp256r1 support.
1054 if wtg.Key.Curve == "secp256r1" { 1054 if wtg.Key.Curve == "secp256r1" {
1055 return true 1055 return true
1056 } 1056 }
1057 1057
1058 fmt.Printf("Running ECDSA test group %v with curve %v, key size %d and %v...\n", wtg.Type, wtg.Key.Curve, wtg.Key.KeySize, wtg.SHA) 1058 fmt.Printf("Running %v test group %v with curve %v, key size %d and %v...\n", algorithm, wtg.Type, wtg.Key.Curve, wtg.Key.KeySize, wtg.SHA)
1059 1059
1060 nid, err := nidFromString(wtg.Key.Curve) 1060 nid, err := nidFromString(wtg.Key.Curve)
1061 if err != nil { 1061 if err != nil {
@@ -1140,8 +1140,8 @@ func runRSATest(rsa *C.RSA, nid int, h hash.Hash, wt *wycheproofTestRSA) bool {
1140 return success 1140 return success
1141} 1141}
1142 1142
1143func runRSATestGroup(wtg *wycheproofTestGroupRSA) bool { 1143func runRSATestGroup(algorithm string, wtg *wycheproofTestGroupRSA) bool {
1144 fmt.Printf("Running RSA test group %v with key size %d and %v...\n", wtg.Type, wtg.KeySize, wtg.SHA) 1144 fmt.Printf("Running %v test group %v with key size %d and %v...\n", algorithm, wtg.Type, wtg.KeySize, wtg.SHA)
1145 1145
1146 rsa := C.RSA_new() 1146 rsa := C.RSA_new()
1147 if rsa == nil { 1147 if rsa == nil {
@@ -1211,8 +1211,8 @@ func runX25519Test(wt *wycheproofTestX25519) bool {
1211 return success 1211 return success
1212} 1212}
1213 1213
1214func runX25519TestGroup(wtg *wycheproofTestGroupX25519) bool { 1214func runX25519TestGroup(algorithm string, wtg *wycheproofTestGroupX25519) bool {
1215 fmt.Printf("Running X25519 test group with curve %v...\n", wtg.Curve) 1215 fmt.Printf("Running %v test group with curve %v...\n", algorithm, wtg.Curve)
1216 1216
1217 success := true 1217 success := true
1218 for _, wt := range wtg.Tests { 1218 for _, wt := range wtg.Tests {
@@ -1265,7 +1265,7 @@ func runTestVectors(path string) bool {
1265 } 1265 }
1266 switch wtv.Algorithm { 1266 switch wtv.Algorithm {
1267 case "AES-CBC-PKCS5": 1267 case "AES-CBC-PKCS5":
1268 if !runAesCbcPkcs5TestGroup(wtg.(*wycheproofTestGroupAesCbcPkcs5)) { 1268 if !runAesCbcPkcs5TestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupAesCbcPkcs5)) {
1269 success = false 1269 success = false
1270 } 1270 }
1271 case "AES-CCM": 1271 case "AES-CCM":
@@ -1273,7 +1273,7 @@ func runTestVectors(path string) bool {
1273 success = false 1273 success = false
1274 } 1274 }
1275 case "AES-CMAC": 1275 case "AES-CMAC":
1276 if !runAesCmacTestGroup(wtg.(*wycheproofTestGroupAesCmac)) { 1276 if !runAesCmacTestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupAesCmac)) {
1277 success = false 1277 success = false
1278 } 1278 }
1279 case "AES-GCM": 1279 case "AES-GCM":
@@ -1281,23 +1281,23 @@ func runTestVectors(path string) bool {
1281 success = false 1281 success = false
1282 } 1282 }
1283 case "CHACHA20-POLY1305": 1283 case "CHACHA20-POLY1305":
1284 if !runChaCha20Poly1305TestGroup(wtg.(*wycheproofTestGroupChaCha20Poly1305)) { 1284 if !runChaCha20Poly1305TestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupChaCha20Poly1305)) {
1285 success = false 1285 success = false
1286 } 1286 }
1287 case "DSA": 1287 case "DSA":
1288 if !runDSATestGroup(wtg.(*wycheproofTestGroupDSA)) { 1288 if !runDSATestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupDSA)) {
1289 success = false 1289 success = false
1290 } 1290 }
1291 case "ECDSA": 1291 case "ECDSA":
1292 if !runECDSATestGroup(wtg.(*wycheproofTestGroupECDSA)) { 1292 if !runECDSATestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupECDSA)) {
1293 success = false 1293 success = false
1294 } 1294 }
1295 case "RSASig": 1295 case "RSASig":
1296 if !runRSATestGroup(wtg.(*wycheproofTestGroupRSA)) { 1296 if !runRSATestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupRSA)) {
1297 success = false 1297 success = false
1298 } 1298 }
1299 case "X25519": 1299 case "X25519":
1300 if !runX25519TestGroup(wtg.(*wycheproofTestGroupX25519)) { 1300 if !runX25519TestGroup(wtv.Algorithm, wtg.(*wycheproofTestGroupX25519)) {
1301 success = false 1301 success = false
1302 } 1302 }
1303 default: 1303 default: