summaryrefslogtreecommitdiff
path: root/regress/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-11-21 11:41:19 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-11-21 11:41:19 +0000
commited2558b8520a5837e9e311bf1f3dd6bfdc779292 (patch)
tree8dac0b52e1398520796292c9537eade2ae69c452 /regress/lib
parentc4cd57af51368fd90d85c4536cf4d1b14eec2360 (diff)
wycheproof.go: modify some DSA and ECDSA code to work with opaque structs
Diffstat (limited to 'regress/lib')
-rw-r--r--regress/lib/libcrypto/wycheproof/wycheproof.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/regress/lib/libcrypto/wycheproof/wycheproof.go b/regress/lib/libcrypto/wycheproof/wycheproof.go
index 9b22f1411ec..b10792ab6f4 100644
--- a/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
-/* $OpenBSD: wycheproof.go,v 1.122 2021/09/24 20:48:23 tb Exp $ */
+/* $OpenBSD: wycheproof.go,v 1.123 2021/11/21 11:41:18 tb Exp $ */
/*
* Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2018, 2019 Theo Buehler <tb@openbsd.org>
@@ -1270,12 +1270,21 @@ func encodeDSAP1363Sig(wtSig string) (*C.uchar, C.int) {
s := C.CString(wtSig[sigLen/2:])
defer C.free(unsafe.Pointer(r))
defer C.free(unsafe.Pointer(s))
- if C.BN_hex2bn(&cSig.r, r) == 0 {
+ var sigR *C.BIGNUM
+ var sigS *C.BIGNUM
+ defer C.BN_free(sigR)
+ defer C.BN_free(sigS)
+ if C.BN_hex2bn(&sigR, r) == 0 {
return nil, 0
}
- if C.BN_hex2bn(&cSig.s, s) == 0 {
+ if C.BN_hex2bn(&sigS, s) == 0 {
return nil, 0
}
+ if C.DSA_SIG_set0(cSig, sigR, sigS) == 0 {
+ return nil, 0
+ }
+ sigR = nil
+ sigS = nil
derLen := C.i2d_DSA_SIG(cSig, nil)
if derLen == 0 {
@@ -1805,12 +1814,21 @@ func encodeECDSAWebCryptoSig(wtSig string) (*C.uchar, C.int) {
s := C.CString(wtSig[sigLen/2:])
defer C.free(unsafe.Pointer(r))
defer C.free(unsafe.Pointer(s))
- if C.BN_hex2bn(&cSig.r, r) == 0 {
+ var sigR *C.BIGNUM
+ var sigS *C.BIGNUM
+ defer C.BN_free(sigR)
+ defer C.BN_free(sigS)
+ if C.BN_hex2bn(&sigR, r) == 0 {
+ return nil, 0
+ }
+ if C.BN_hex2bn(&sigS, s) == 0 {
return nil, 0
}
- if C.BN_hex2bn(&cSig.s, s) == 0 {
+ if C.ECDSA_SIG_set0(cSig, sigR, sigS) == 0 {
return nil, 0
}
+ sigR = nil
+ sigS = nil
derLen := C.i2d_ECDSA_SIG(cSig, nil)
if derLen == 0 {