diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/wycheproof/wycheproof.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index cd95f32ff1..11c99b745a 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.63 2018/09/22 11:00:25 tb Exp $ */ | 1 | /* $OpenBSD: wycheproof.go,v 1.64 2018/09/22 13:42:46 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> |
@@ -919,7 +919,7 @@ func checkAeadSeal(ctx *C.EVP_AEAD_CTX, iv []byte, ivLen int, aad []byte, aadLen | |||
919 | return success | 919 | return success |
920 | } | 920 | } |
921 | 921 | ||
922 | func runChaCha20Poly1305Test(iv_len int, key_len int, tag_len int, wt *wycheproofTestAead) bool { | 922 | func runChaCha20Poly1305Test(wt *wycheproofTestAead) bool { |
923 | aead := C.EVP_aead_chacha20_poly1305() | 923 | aead := C.EVP_aead_chacha20_poly1305() |
924 | 924 | ||
925 | key, err := hex.DecodeString(wt.Key) | 925 | key, err := hex.DecodeString(wt.Key) |
@@ -947,17 +947,7 @@ func runChaCha20Poly1305Test(iv_len int, key_len int, tag_len int, wt *wycheproo | |||
947 | log.Fatalf("Failed to decode tag %q: %v", wt.Tag, err) | 947 | log.Fatalf("Failed to decode tag %q: %v", wt.Tag, err) |
948 | } | 948 | } |
949 | 949 | ||
950 | keyLen, ivLen, aadLen, tagLen := len(key), len(iv), len(aad), len(tag) | 950 | keyLen, ivLen, aadLen, msgLen, ctLen, tagLen := len(key), len(iv), len(aad), len(msg), len(ct), len(tag) |
951 | if key_len != keyLen || iv_len != ivLen || tag_len != tagLen { | ||
952 | fmt.Printf("FAIL: Test case %d (%q) %v - length mismatch; key: got %d, want %d; IV: got %d, want %d; tag: got %d, want %d\n", wt.TCID, wt.Comment, wt.Flags, keyLen, key_len, ivLen, iv_len, tagLen, tag_len) | ||
953 | return false | ||
954 | } | ||
955 | |||
956 | msgLen, ctLen := len(msg), len(ct) | ||
957 | if msgLen != ctLen { | ||
958 | fmt.Printf("FAIL: Test case %d (%q) %v - length mismatch: msgLen = %d, ctLen = %d\n", wt.TCID, wt.Comment, wt.Flags, msgLen, ctLen) | ||
959 | return false | ||
960 | } | ||
961 | 951 | ||
962 | if ivLen == 0 { | 952 | if ivLen == 0 { |
963 | iv = append(iv, 0) | 953 | iv = append(iv, 0) |
@@ -970,7 +960,7 @@ func runChaCha20Poly1305Test(iv_len int, key_len int, tag_len int, wt *wycheproo | |||
970 | } | 960 | } |
971 | 961 | ||
972 | var ctx C.EVP_AEAD_CTX | 962 | var ctx C.EVP_AEAD_CTX |
973 | if C.EVP_AEAD_CTX_init(&ctx, aead, (*C.uchar)(unsafe.Pointer(&key[0])), C.size_t(key_len), C.size_t(tag_len), nil) != 1 { | 963 | if C.EVP_AEAD_CTX_init(&ctx, aead, (*C.uchar)(unsafe.Pointer(&key[0])), C.size_t(keyLen), C.size_t(tagLen), nil) != 1 { |
974 | log.Fatal("Failed to initialize AEAD context") | 964 | log.Fatal("Failed to initialize AEAD context") |
975 | } | 965 | } |
976 | defer C.EVP_AEAD_CTX_cleanup(&ctx) | 966 | defer C.EVP_AEAD_CTX_cleanup(&ctx) |
@@ -991,7 +981,7 @@ func runChaCha20Poly1305TestGroup(algorithm string, wtg *wycheproofTestGroupAead | |||
991 | 981 | ||
992 | success := true | 982 | success := true |
993 | for _, wt := range wtg.Tests { | 983 | for _, wt := range wtg.Tests { |
994 | if !runChaCha20Poly1305Test(wtg.IVSize / 8, wtg.KeySize / 8, wtg.TagSize / 8, wt) { | 984 | if !runChaCha20Poly1305Test(wt) { |
995 | success = false | 985 | success = false |
996 | } | 986 | } |
997 | } | 987 | } |