summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_oct.c
diff options
context:
space:
mode:
authorjsing <>2023-03-08 04:50:27 +0000
committerjsing <>2023-03-08 04:50:27 +0000
commite1c888106b8acbf84cec67a2b091f2e917d2d79d (patch)
tree3c4980fe37e68835a8cfd79b0b18e7d38f9c023b /src/lib/libcrypto/ec/ec_oct.c
parentd0aa55ca89f010e114806ccd82c50fc6dd7f3bf0 (diff)
downloadopenbsd-e1c888106b8acbf84cec67a2b091f2e917d2d79d.tar.gz
openbsd-e1c888106b8acbf84cec67a2b091f2e917d2d79d.tar.bz2
openbsd-e1c888106b8acbf84cec67a2b091f2e917d2d79d.zip
Remove EC_FLAGS_DEFAULT_OCT.
The EC code has an amazing array of function pointer hooks, such that a method can hook into almost any operation... and then there is the EC_FLAGS_DEFAULT_OCT flag, which adds a bunch of complex code and #ifdef so you can avoid setting three of those function pointers! Remove EC_FLAGS_DEFAULT_OCT, the now unused flags field from EC_METHOD, along with the various code that was wrapped in EC_FLAGS_DEFAULT_OCT, setting the three function pointers that need to be set in each of the EC_METHODs. ok beck@ tb@
Diffstat (limited to 'src/lib/libcrypto/ec/ec_oct.c')
-rw-r--r--src/lib/libcrypto/ec/ec_oct.c66
1 files changed, 6 insertions, 60 deletions
diff --git a/src/lib/libcrypto/ec/ec_oct.c b/src/lib/libcrypto/ec/ec_oct.c
index 0e651991fd..ef17ec59a5 100644
--- a/src/lib/libcrypto/ec/ec_oct.c
+++ b/src/lib/libcrypto/ec/ec_oct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_oct.c,v 1.9 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: ec_oct.c,v 1.10 2023/03/08 04:50:27 jsing 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 */
@@ -74,8 +74,7 @@ int
74EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, 74EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
75 const BIGNUM *x, int y_bit, BN_CTX *ctx) 75 const BIGNUM *x, int y_bit, BN_CTX *ctx)
76{ 76{
77 if (group->meth->point_set_compressed_coordinates == NULL && 77 if (group->meth->point_set_compressed_coordinates == NULL) {
78 !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
79 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 78 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
80 return 0; 79 return 0;
81 } 80 }
@@ -83,29 +82,8 @@ EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
83 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 82 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
84 return 0; 83 return 0;
85 } 84 }
86 if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { 85 return group->meth->point_set_compressed_coordinates(group, point,
87 if (group->meth->field_type == NID_X9_62_prime_field) 86 x, y_bit, ctx);
88 return ec_GFp_simple_set_compressed_coordinates(
89 group, point, x, y_bit, ctx);
90 else
91#ifdef OPENSSL_NO_EC2M
92 {
93 ECerror(EC_R_GF2M_NOT_SUPPORTED);
94 return 0;
95 }
96#else
97 return ec_GF2m_simple_set_compressed_coordinates(
98 group, point, x, y_bit, ctx);
99#endif
100 }
101 if (!group->meth->point_set_compressed_coordinates(group, point, x,
102 y_bit, ctx))
103 return 0;
104 if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
105 ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
106 return 0;
107 }
108 return 1;
109} 87}
110 88
111int 89int
@@ -129,8 +107,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
129 point_conversion_form_t form, 107 point_conversion_form_t form,
130 unsigned char *buf, size_t len, BN_CTX *ctx) 108 unsigned char *buf, size_t len, BN_CTX *ctx)
131{ 109{
132 if (group->meth->point2oct == 0 110 if (group->meth->point2oct == NULL) {
133 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
134 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 111 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
135 return 0; 112 return 0;
136 } 113 }
@@ -138,21 +115,6 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
138 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 115 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
139 return 0; 116 return 0;
140 } 117 }
141 if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
142 if (group->meth->field_type == NID_X9_62_prime_field)
143 return ec_GFp_simple_point2oct(group, point,
144 form, buf, len, ctx);
145 else
146#ifdef OPENSSL_NO_EC2M
147 {
148 ECerror(EC_R_GF2M_NOT_SUPPORTED);
149 return 0;
150 }
151#else
152 return ec_GF2m_simple_point2oct(group, point,
153 form, buf, len, ctx);
154#endif
155 }
156 return group->meth->point2oct(group, point, form, buf, len, ctx); 118 return group->meth->point2oct(group, point, form, buf, len, ctx);
157} 119}
158 120
@@ -160,8 +122,7 @@ int
160EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, 122EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
161 const unsigned char *buf, size_t len, BN_CTX *ctx) 123 const unsigned char *buf, size_t len, BN_CTX *ctx)
162{ 124{
163 if (group->meth->oct2point == 0 && 125 if (group->meth->oct2point == NULL) {
164 !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
165 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 126 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
166 return 0; 127 return 0;
167 } 128 }
@@ -169,20 +130,5 @@ EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
169 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 130 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
170 return 0; 131 return 0;
171 } 132 }
172 if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
173 if (group->meth->field_type == NID_X9_62_prime_field)
174 return ec_GFp_simple_oct2point(group, point,
175 buf, len, ctx);
176 else
177#ifdef OPENSSL_NO_EC2M
178 {
179 ECerror(EC_R_GF2M_NOT_SUPPORTED);
180 return 0;
181 }
182#else
183 return ec_GF2m_simple_oct2point(group, point,
184 buf, len, ctx);
185#endif
186 }
187 return group->meth->oct2point(group, point, buf, len, ctx); 133 return group->meth->oct2point(group, point, buf, len, ctx);
188} 134}