diff options
author | 2018-10-18 21:34:06 +0000 | |
---|---|---|
committer | 2018-10-18 21:34:06 +0000 | |
commit | 4980fa5071e0c36acff168df3eb679b0e2e155fc (patch) | |
tree | a5b5990a116e1a47e0f9bfefd1da34c9356caf3f | |
parent | Avoid a bad out of bounds access that caused intermittent crashes. (diff) | |
download | wireguard-openbsd-4980fa5071e0c36acff168df3eb679b0e2e155fc.tar.xz wireguard-openbsd-4980fa5071e0c36acff168df3eb679b0e2e155fc.zip |
simplify BN_bin2bn() calls; no need to pre-declare the variable.
-rw-r--r-- | regress/lib/libcrypto/wycheproof/wycheproof.go | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/regress/lib/libcrypto/wycheproof/wycheproof.go b/regress/lib/libcrypto/wycheproof/wycheproof.go index a4360d2904d..318abf98061 100644 --- a/regress/lib/libcrypto/wycheproof/wycheproof.go +++ b/regress/lib/libcrypto/wycheproof/wycheproof.go @@ -1,4 +1,4 @@ -/* $OpenBSD: wycheproof.go,v 1.82 2018/10/18 21:30:05 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.83 2018/10/18 21:34:06 tb Exp $ */ /* * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> @@ -1362,12 +1362,11 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool { } defer C.EC_KEY_free(privKey) - var bnD *C.BIGNUM d, err := base64.RawURLEncoding.DecodeString(wt.Private.D) if err != nil { log.Fatalf("Failed to base64 decode d: %v", err) } - bnD = C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&d[0])), C.int(len(d)), nil) + bnD := C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&d[0])), C.int(len(d)), nil) if bnD == nil { log.Fatal("Failed to decode D") } @@ -1380,23 +1379,21 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool { return false } - var bnX *C.BIGNUM x, err := base64.RawURLEncoding.DecodeString(wt.Public.X) if err != nil { log.Fatalf("Failed to base64 decode x: %v", err) } - bnX = C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&x[0])), C.int(len(x)), nil) + bnX := C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&x[0])), C.int(len(x)), nil) if bnX == nil { log.Fatal("Failed to decode X") } defer C.BN_free(bnX) - var bnY *C.BIGNUM y, err := base64.RawURLEncoding.DecodeString(wt.Public.Y) if err != nil { log.Fatalf("Failed to base64 decode y: %v", err) } - bnY = C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&y[0])), C.int(len(y)), nil) + bnY := C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&y[0])), C.int(len(y)), nil) if bnY == nil { log.Fatal("Failed to decode Y") } @@ -1635,8 +1632,7 @@ func runECDSAWebCryptoTestGroup(algorithm string, wtg *wycheproofTestGroupECDSAW if err != nil { log.Fatalf("Failed to base64 decode X: %v", err) } - var bnX *C.BIGNUM - bnX = C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&x[0])), C.int(len(x)), nil) + bnX := C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&x[0])), C.int(len(x)), nil) if bnX == nil { log.Fatal("Failed to decode X") } @@ -1646,8 +1642,7 @@ func runECDSAWebCryptoTestGroup(algorithm string, wtg *wycheproofTestGroupECDSAW if err != nil { log.Fatalf("Failed to base64 decode Y: %v", err) } - var bnY *C.BIGNUM - bnY = C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&y[0])), C.int(len(y)), nil) + bnY := C.BN_bin2bn((*C.uchar)(unsafe.Pointer(&y[0])), C.int(len(y)), nil) if bnY == nil { log.Fatal("Failed to decode Y") } |