diff options
author | tb <> | 2024-10-26 13:49:08 +0000 |
---|---|---|
committer | tb <> | 2024-10-26 13:49:08 +0000 |
commit | 7ccf065af6f0457c33e36093dc03e479be111de9 (patch) | |
tree | 4901129d972eaf3aa4369a23a5d9fb12375218c9 /src | |
parent | e2a62e818bf165355adbef5a3d01db7e7c51499e (diff) | |
download | openbsd-7ccf065af6f0457c33e36093dc03e479be111de9.tar.gz openbsd-7ccf065af6f0457c33e36093dc03e479be111de9.tar.bz2 openbsd-7ccf065af6f0457c33e36093dc03e479be111de9.zip |
ec_asn1_test: play some silly games to cover a few more code paths
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/ec/ec_asn1_test.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/ec/ec_asn1_test.c b/src/regress/lib/libcrypto/ec/ec_asn1_test.c index 76dc415a93..e5813d830c 100644 --- a/src/regress/lib/libcrypto/ec/ec_asn1_test.c +++ b/src/regress/lib/libcrypto/ec/ec_asn1_test.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_asn1_test.c,v 1.16 2024/10/26 10:15:19 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1_test.c,v 1.17 2024/10/26 13:49:08 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> |
@@ -2685,6 +2685,52 @@ ec_group_check_private_key(const struct ec_private_key *key) | |||
2685 | goto err; | 2685 | goto err; |
2686 | } | 2686 | } |
2687 | 2687 | ||
2688 | /* | ||
2689 | * Invalidate the point by doubling and inverting it. Then see if | ||
2690 | * point reuse works. | ||
2691 | */ | ||
2692 | |||
2693 | if (!EC_POINT_dbl(group, point, point, NULL)) { | ||
2694 | fprintf(stderr, "FAIL: EC_POINT_dbl() failed for %s\n", | ||
2695 | key->name); | ||
2696 | goto err; | ||
2697 | } | ||
2698 | if (!EC_POINT_invert(group, point, NULL)) { | ||
2699 | fprintf(stderr, "FAIL: EC_POINT_invert() failed for %s\n", | ||
2700 | key->name); | ||
2701 | goto err; | ||
2702 | } | ||
2703 | if (!EC_POINT_is_on_curve(group, point, NULL)) { | ||
2704 | fprintf(stderr, "FAIL: EC_POINT_is_on_curve() failed for %s\n", | ||
2705 | key->name); | ||
2706 | goto err; | ||
2707 | } | ||
2708 | if (EC_POINT_is_at_infinity(group, point)) { | ||
2709 | fprintf(stderr, "FAIL: EC_POINT_is_at_infinity() is true for %s\n", | ||
2710 | key->name); | ||
2711 | goto err; | ||
2712 | } | ||
2713 | |||
2714 | /* The points are now different. */ | ||
2715 | if ((rv = EC_POINT_cmp(group, ec_public_point, point, NULL)) == 0) { | ||
2716 | fprintf(stderr, "FAIL: EC_POINT_cmp() returned %d for %s\n", | ||
2717 | rv, key->name); | ||
2718 | goto err; | ||
2719 | } | ||
2720 | |||
2721 | if (EC_POINT_hex2point(group, hex, point, NULL) == NULL) { | ||
2722 | fprintf(stderr, "FAIL: EC_POINT_hex2point() failed for %s\n", | ||
2723 | key->name); | ||
2724 | goto err; | ||
2725 | } | ||
2726 | |||
2727 | /* And after reuse they should be the same again. */ | ||
2728 | if ((rv = EC_POINT_cmp(group, ec_public_point, point, NULL)) != 0) { | ||
2729 | fprintf(stderr, "FAIL: EC_POINT_cmp() returned %d for %s\n", | ||
2730 | rv, key->name); | ||
2731 | goto err; | ||
2732 | } | ||
2733 | |||
2688 | free(hex); | 2734 | free(hex); |
2689 | hex = NULL; | 2735 | hex = NULL; |
2690 | 2736 | ||