diff options
author | tb <> | 2024-10-18 18:03:45 +0000 |
---|---|---|
committer | tb <> | 2024-10-18 18:03:45 +0000 |
commit | 2b5b0449a68f53d499f44a405400ebd9de632ff5 (patch) | |
tree | 23979bed173de2674f63daa86bd4cba8ba277301 /src | |
parent | 9f898f3c2396c52080e2bf9000f513e152deb708 (diff) | |
download | openbsd-2b5b0449a68f53d499f44a405400ebd9de632ff5.tar.gz openbsd-2b5b0449a68f53d499f44a405400ebd9de632ff5.tar.bz2 openbsd-2b5b0449a68f53d499f44a405400ebd9de632ff5.zip |
Simplify EC_get_builtin_curves().
When determining the minimum of nitems and EC_CURVE_LIST_LENGTH
we need neither an extra variable nor a ternary operator.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_curve.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c index 4c1611f1af..6d7eea81cf 100644 --- a/src/lib/libcrypto/ec/ec_curve.c +++ b/src/lib/libcrypto/ec/ec_curve.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_curve.c,v 1.45 2024/10/18 17:56:45 tb Exp $ */ | 1 | /* $OpenBSD: ec_curve.c,v 1.46 2024/10/18 18:03:45 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -2680,14 +2680,15 @@ ec_group_is_builtin_curve(const EC_GROUP *group) | |||
2680 | size_t | 2680 | size_t |
2681 | EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems) | 2681 | EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems) |
2682 | { | 2682 | { |
2683 | size_t i, min; | 2683 | size_t i; |
2684 | 2684 | ||
2685 | if (r == NULL || nitems == 0) | 2685 | if (r == NULL || nitems == 0) |
2686 | return EC_CURVE_LIST_LENGTH; | 2686 | return EC_CURVE_LIST_LENGTH; |
2687 | 2687 | ||
2688 | min = nitems < EC_CURVE_LIST_LENGTH ? nitems : EC_CURVE_LIST_LENGTH; | 2688 | if (nitems > EC_CURVE_LIST_LENGTH) |
2689 | nitems = EC_CURVE_LIST_LENGTH; | ||
2689 | 2690 | ||
2690 | for (i = 0; i < min; i++) { | 2691 | for (i = 0; i < nitems; i++) { |
2691 | r[i].nid = ec_curve_list[i].nid; | 2692 | r[i].nid = ec_curve_list[i].nid; |
2692 | r[i].comment = ec_curve_list[i].comment; | 2693 | r[i].comment = ec_curve_list[i].comment; |
2693 | } | 2694 | } |