summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2018-08-24 17:34:46 +0000
committertb <>2018-08-24 17:34:46 +0000
commitfd8d3971664e8269572431ef3d5399e1b7646d04 (patch)
treef59c19ca05a9534f3a2c1e79958a4c118908384e /src
parent4ca92876cd1aa45f9ac5ea123afc11e1ef4574cb (diff)
downloadopenbsd-fd8d3971664e8269572431ef3d5399e1b7646d04.tar.gz
openbsd-fd8d3971664e8269572431ef3d5399e1b7646d04.tar.bz2
openbsd-fd8d3971664e8269572431ef3d5399e1b7646d04.zip
Also test DSA with the DER encoded key. Lots of help from jsing, thanks!
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index a9db5f530a..5bbfb7c2af 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.16 2018/08/23 19:46:59 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.17 2018/08/24 17:34:46 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -21,6 +21,8 @@ package main
21/* 21/*
22#cgo LDFLAGS: -lcrypto 22#cgo LDFLAGS: -lcrypto
23 23
24#include <string.h>
25
24#include <openssl/bn.h> 26#include <openssl/bn.h>
25#include <openssl/curve25519.h> 27#include <openssl/curve25519.h>
26#include <openssl/dsa.h> 28#include <openssl/dsa.h>
@@ -450,12 +452,36 @@ func runDSATestGroup(wtg *wycheproofTestGroupDSA) bool {
450 log.Fatalf("Failed to get hash: %v", err) 452 log.Fatalf("Failed to get hash: %v", err)
451 } 453 }
452 454
455 der, err := hex.DecodeString(wtg.KeyDER)
456 if err != nil {
457 log.Fatalf("Failed to decode DER encoded key: %v", err)
458 }
459
460 derLen := len(der)
461 if derLen == 0 {
462 der = append(der, 0)
463 }
464
465 Cder := (*C.uchar)(C.malloc((C.ulong)(derLen)))
466 if Cder == nil {
467 log.Fatal("malloc failed")
468 }
469 C.memcpy(unsafe.Pointer(Cder), unsafe.Pointer(&der[0]), C.ulong(derLen))
470
471 p := (*C.uchar)(Cder)
472 dsaDER := C.d2i_DSA_PUBKEY(nil, (**C.uchar)(&p), C.long(derLen))
473 defer C.DSA_free(dsaDER)
474 C.free(unsafe.Pointer(Cder))
475
453 /// XXX audit acceptable cases 476 /// XXX audit acceptable cases
454 success := true 477 success := true
455 for _, wt := range wtg.Tests { 478 for _, wt := range wtg.Tests {
456 if !runDSATest(dsa, h, wt) { 479 if !runDSATest(dsa, h, wt) {
457 success = false 480 success = false
458 } 481 }
482 if !runDSATest(dsaDER, h, wt) {
483 success = false
484 }
459 } 485 }
460 return success 486 return success
461} 487}