diff options
| author | tb <> | 2023-12-29 18:47:47 +0000 |
|---|---|---|
| committer | tb <> | 2023-12-29 18:47:47 +0000 |
| commit | 3b9ef26e3354193b8139f526e3350d30b751d1f9 (patch) | |
| tree | 53b46e0b2d252bda1d498eb8dc4350abdc5bed89 /src/lib/libc | |
| parent | daac9ac8c298b481db05bf3ee249b871385f2a4d (diff) | |
| download | openbsd-3b9ef26e3354193b8139f526e3350d30b751d1f9.tar.gz openbsd-3b9ef26e3354193b8139f526e3350d30b751d1f9.tar.bz2 openbsd-3b9ef26e3354193b8139f526e3350d30b751d1f9.zip | |
Clean up eckey_param_decode()
This aligns eckey's parameter decoding routine with the one of other
cipher abstractions: better variable names, single exit and add missing
check for EVP_PKEY_assign_EC_KEY().
ok jsing
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c index 2b3b3db63d..e6fe8bd370 100644 --- a/src/lib/libcrypto/ec/ec_ameth.c +++ b/src/lib/libcrypto/ec/ec_ameth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_ameth.c,v 1.47 2023/12/29 18:46:24 tb Exp $ */ | 1 | /* $OpenBSD: ec_ameth.c,v 1.48 2023/12/29 18:47:47 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -551,16 +551,23 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) | |||
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | static int | 553 | static int |
| 554 | eckey_param_decode(EVP_PKEY *pkey, | 554 | eckey_param_decode(EVP_PKEY *pkey, const unsigned char **param, int param_len) |
| 555 | const unsigned char **pder, int derlen) | ||
| 556 | { | 555 | { |
| 557 | EC_KEY *eckey; | 556 | EC_KEY *eckey; |
| 558 | if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) { | 557 | int ret = 0; |
| 559 | ECerror(ERR_R_EC_LIB); | 558 | |
| 560 | return 0; | 559 | if ((eckey = d2i_ECParameters(NULL, param, param_len)) == NULL) |
| 561 | } | 560 | goto err; |
| 562 | EVP_PKEY_assign_EC_KEY(pkey, eckey); | 561 | if (!EVP_PKEY_assign_EC_KEY(pkey, eckey)) |
| 563 | return 1; | 562 | goto err; |
| 563 | eckey = NULL; | ||
| 564 | |||
| 565 | ret = 1; | ||
| 566 | |||
| 567 | err: | ||
| 568 | EC_KEY_free(eckey); | ||
| 569 | |||
| 570 | return ret; | ||
| 564 | } | 571 | } |
| 565 | 572 | ||
| 566 | static int | 573 | static int |
