From 9f692b0ee8ba05d706060427c4a23ccf83d0a3e6 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 25 Aug 2018 10:07:16 +0000 Subject: Also run DSA tests with the PEM encoded public key. --- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index 5caee01181..ae9108407b 100644 --- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go @@ -1,4 +1,4 @@ -/* $OpenBSD: wycheproof.go,v 1.19 2018/08/24 17:37:25 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.20 2018/08/25 10:07:16 tb Exp $ */ /* * Copyright (c) 2018 Joel Sing * Copyright (c) 2018 Theo Buehler @@ -24,6 +24,7 @@ package main #include +#include #include #include #include @@ -31,6 +32,7 @@ package main #include #include #include +#include #include #include */ @@ -453,6 +455,7 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { log.Fatalf("Failed to get hash: %v", err) } + der, err := hex.DecodeString(wtg.KeyDER) if err != nil { log.Fatalf("Failed to decode DER encoded key: %v", err) @@ -474,7 +477,21 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { defer C.DSA_free(dsaDER) C.free(unsafe.Pointer(Cder)) - /// XXX audit acceptable cases + + keyPEM := C.CString(wtg.KeyPEM); + bio := C.BIO_new_mem_buf(unsafe.Pointer(keyPEM), C.int(len(wtg.KeyPEM))) + if bio == nil { + log.Fatal("BIO_new_mem_buf failed") + } + defer C.BIO_free(bio) + + dsaPEM := C.PEM_read_bio_DSA_PUBKEY(bio, nil, nil, nil) + if dsaPEM == nil { + log.Fatal("PEM_read_bio_DSA_PUBKEY failed") + } + defer C.DSA_free(dsaPEM) + + success := true for _, wt := range wtg.Tests { if !runDSATest(dsa, h, wt) { @@ -483,6 +500,9 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool { if !runDSATest(dsaDER, h, wt) { success = false } + if !runDSATest(dsaPEM, h, wt) { + success = false + } } return success } -- cgit v1.2.3-55-g6feb