summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-10-06 10:43:47 +0000
committertb <>2018-10-06 10:43:47 +0000
commit6e8e365c996f2ba23205d1dad7efdb9ca526ece5 (patch)
tree284ce6511fe7addf11495d57d6952791a93dbbe2
parent29ddf5f399442d553affe73458040202148371c9 (diff)
downloadopenbsd-6e8e365c996f2ba23205d1dad7efdb9ca526ece5.tar.gz
openbsd-6e8e365c996f2ba23205d1dad7efdb9ca526ece5.tar.bz2
openbsd-6e8e365c996f2ba23205d1dad7efdb9ca526ece5.zip
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.
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go31
1 files 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 @@
1/* $OpenBSD: wycheproof.go,v 1.75 2018/10/06 10:21:56 tb Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.76 2018/10/06 10:43:47 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -1315,22 +1315,10 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1315 1315
1316 ret := C.EC_KEY_set_private_key(privKey, bnD) 1316 ret := C.EC_KEY_set_private_key(privKey, bnD)
1317 if ret != 1 { 1317 if ret != 1 {
1318 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) 1318 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)
1319 return false 1319 return false
1320 } 1320 }
1321 1321
1322 group := C.EC_GROUP_new_by_curve_name(C.int(nid))
1323 if group == nil {
1324 log.Fatal("Failed to get EC_GROUP")
1325 }
1326 defer C.EC_GROUP_free(group)
1327
1328 pubPoint := C.EC_POINT_new(group)
1329 if pubPoint == nil {
1330 log.Fatal("Failed to create EC_POINT")
1331 }
1332 defer C.EC_POINT_free(pubPoint)
1333
1334 var bnX *C.BIGNUM 1322 var bnX *C.BIGNUM
1335 x, err := base64.RawURLEncoding.DecodeString(wt.Public.X) 1323 x, err := base64.RawURLEncoding.DecodeString(wt.Public.X)
1336 if err != nil { 1324 if err != nil {
@@ -1353,10 +1341,21 @@ func runECDHWebCryptoTest(nid int, wt *wycheproofTestECDHWebCrypto) bool {
1353 } 1341 }
1354 defer C.BN_free(bnY) 1342 defer C.BN_free(bnY)
1355 1343
1356 ret = C.EC_POINT_set_affine_coordinates_GFp(group, pubPoint, bnX, bnY, nil) 1344 pubKey := C.EC_KEY_new_by_curve_name(C.int(nid))
1345 if pubKey == nil {
1346 log.Fatal("Failed to create EC_KEY")
1347 }
1348 defer C.EC_KEY_free(pubKey)
1349
1350 ret = C.EC_KEY_set_public_key_affine_coordinates(pubKey, bnX, bnY)
1357 if ret != 1 { 1351 if ret != 1 {
1358 log.Fatal("Failed to set public key") 1352 if wt.Result == "invalid" {
1353 return true
1354 }
1355 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)
1356 return false
1359 } 1357 }
1358 pubPoint := C.EC_KEY_get0_public_key(pubKey)
1360 1359
1361 privGroup := C.EC_KEY_get0_group(privKey) 1360 privGroup := C.EC_KEY_get0_group(privKey)
1362 1361