From 6e8e365c996f2ba23205d1dad7efdb9ca526ece5 Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 6 Oct 2018 10:43:47 +0000 Subject: It's slightly simpler to get the ECDH public key as an EC_POINT by using EC_KEY_set_public_key_affine_coordinates() and EC_KEY_get0_public_key() than using EC_POINT_set_affine_coordinates_GFp() directly. --- src/regress/lib/libcrypto/wycheproof/wycheproof.go | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go index f1a2fe9730..6f2fc42f8e 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.75 2018/10/06 10:21:56 tb Exp $ */ +/* $OpenBSD: wycheproof.go,v 1.76 2018/10/06 10:43:47 tb Exp $ */ /* * Copyright (c) 2018 Joel Sing * Copyright (c) 2018 Theo Buehler @@ -1315,22 +1315,10 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool { ret := C.EC_KEY_set_private_key(privKey, bnD) if ret != 1 { - fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_private_key() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) + fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_private_key() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) return false } - group := C.EC_GROUP_new_by_curve_name(C.int(nid)) - if group == nil { - log.Fatal("Failed to get EC_GROUP") - } - defer C.EC_GROUP_free(group) - - pubPoint := C.EC_POINT_new(group) - if pubPoint == nil { - log.Fatal("Failed to create EC_POINT") - } - defer C.EC_POINT_free(pubPoint) - var bnX *C.BIGNUM x, err := base64.RawURLEncoding.DecodeString(wt.Public.X) if err != nil { @@ -1353,10 +1341,21 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool { } defer C.BN_free(bnY) - ret = C.EC_POINT_set_affine_coordinates_GFp(group, pubPoint, bnX, bnY, nil) + pubKey := C.EC_KEY_new_by_curve_name(C.int(nid)) + if pubKey == nil { + log.Fatal("Failed to create EC_KEY") + } + defer C.EC_KEY_free(pubKey) + + ret = C.EC_KEY_set_public_key_affine_coordinates(pubKey, bnX, bnY) if ret != 1 { - log.Fatal("Failed to set public key") + if wt.Result == "invalid" { + return true + } + fmt.Printf("FAIL: Test case %d (%q) %v - EC_KEY_set_public_key_affine_coordinates() = %d, want %v\n", wt.TCID, wt.Comment, wt.Flags, ret, wt.Result) + return false } + pubPoint := C.EC_KEY_get0_public_key(pubKey) privGroup := C.EC_KEY_get0_group(privKey) -- cgit v1.2.3-55-g6feb