summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_lib.c
diff options
context:
space:
mode:
authortb <>2023-06-25 18:52:27 +0000
committertb <>2023-06-25 18:52:27 +0000
commit70d8987d04d28fe256835167778ab28f3e6bdd3c (patch)
tree0df2834b9d3887c87ec022222f74c206da81e21c /src/lib/libcrypto/ec/ec_lib.c
parent1f1e97550126828f07750399c2a4acd3af28df1b (diff)
downloadopenbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.tar.gz
openbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.tar.bz2
openbsd-70d8987d04d28fe256835167778ab28f3e6bdd3c.zip
Remove EC_EXTRA_DATA
With the ecdh_check() and ecdsa_check() abominations gone, we can finally get rid of EC_EXTRA_DATA and EC_KEY_{get,insert}_key_method_data(). The EC_EX_DATA_*() handlers, (which fortunately have always had "'package' level visibility") join the ride to the great bit bucket in the sky. Thanks to op for making this possible. ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_lib.c')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c154
1 files changed, 1 insertions, 153 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index cb581f6e1c..2e180e9661 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.60 2023/06/24 18:21:07 jsing Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.61 2023/06/25 18:52:27 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -651,158 +651,6 @@ ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx)
651 return group->meth->blind_coordinates(group, p, ctx); 651 return group->meth->blind_coordinates(group, p, ctx);
652} 652}
653 653
654/* this has 'package' visibility */
655int
656EC_EX_DATA_set_data(EC_EXTRA_DATA ** ex_data, void *data,
657 void *(*dup_func) (void *),
658 void (*free_func) (void *),
659 void (*clear_free_func) (void *))
660{
661 EC_EXTRA_DATA *d;
662
663 if (ex_data == NULL)
664 return 0;
665
666 for (d = *ex_data; d != NULL; d = d->next) {
667 if (d->dup_func == dup_func && d->free_func == free_func &&
668 d->clear_free_func == clear_free_func) {
669 ECerror(EC_R_SLOT_FULL);
670 return 0;
671 }
672 }
673
674 if (data == NULL)
675 /* no explicit entry needed */
676 return 1;
677
678 d = malloc(sizeof *d);
679 if (d == NULL)
680 return 0;
681
682 d->data = data;
683 d->dup_func = dup_func;
684 d->free_func = free_func;
685 d->clear_free_func = clear_free_func;
686
687 d->next = *ex_data;
688 *ex_data = d;
689
690 return 1;
691}
692
693/* this has 'package' visibility */
694void *
695EC_EX_DATA_get_data(const EC_EXTRA_DATA *ex_data,
696 void *(*dup_func) (void *),
697 void (*free_func) (void *),
698 void (*clear_free_func) (void *))
699{
700 const EC_EXTRA_DATA *d;
701
702 for (d = ex_data; d != NULL; d = d->next) {
703 if (d->dup_func == dup_func && d->free_func == free_func && d->clear_free_func == clear_free_func)
704 return d->data;
705 }
706
707 return NULL;
708}
709
710/* this has 'package' visibility */
711void
712EC_EX_DATA_free_data(EC_EXTRA_DATA ** ex_data,
713 void *(*dup_func) (void *),
714 void (*free_func) (void *),
715 void (*clear_free_func) (void *))
716{
717 EC_EXTRA_DATA **p;
718
719 if (ex_data == NULL)
720 return;
721
722 for (p = ex_data; *p != NULL; p = &((*p)->next)) {
723 if ((*p)->dup_func == dup_func &&
724 (*p)->free_func == free_func &&
725 (*p)->clear_free_func == clear_free_func) {
726 EC_EXTRA_DATA *next = (*p)->next;
727
728 (*p)->free_func((*p)->data);
729 free(*p);
730
731 *p = next;
732 return;
733 }
734 }
735}
736
737/* this has 'package' visibility */
738void
739EC_EX_DATA_clear_free_data(EC_EXTRA_DATA ** ex_data,
740 void *(*dup_func) (void *),
741 void (*free_func) (void *),
742 void (*clear_free_func) (void *))
743{
744 EC_EXTRA_DATA **p;
745
746 if (ex_data == NULL)
747 return;
748
749 for (p = ex_data; *p != NULL; p = &((*p)->next)) {
750 if ((*p)->dup_func == dup_func &&
751 (*p)->free_func == free_func &&
752 (*p)->clear_free_func == clear_free_func) {
753 EC_EXTRA_DATA *next = (*p)->next;
754
755 (*p)->clear_free_func((*p)->data);
756 free(*p);
757
758 *p = next;
759 return;
760 }
761 }
762}
763
764/* this has 'package' visibility */
765void
766EC_EX_DATA_free_all_data(EC_EXTRA_DATA ** ex_data)
767{
768 EC_EXTRA_DATA *d;
769
770 if (ex_data == NULL)
771 return;
772
773 d = *ex_data;
774 while (d) {
775 EC_EXTRA_DATA *next = d->next;
776
777 d->free_func(d->data);
778 free(d);
779
780 d = next;
781 }
782 *ex_data = NULL;
783}
784
785/* this has 'package' visibility */
786void
787EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA ** ex_data)
788{
789 EC_EXTRA_DATA *d;
790
791 if (ex_data == NULL)
792 return;
793
794 d = *ex_data;
795 while (d) {
796 EC_EXTRA_DATA *next = d->next;
797
798 d->clear_free_func(d->data);
799 free(d);
800
801 d = next;
802 }
803 *ex_data = NULL;
804}
805
806EC_POINT * 654EC_POINT *
807EC_POINT_new(const EC_GROUP *group) 655EC_POINT_new(const EC_GROUP *group)
808{ 656{