diff options
-rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_oct.c | 66 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_mont.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_nist.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 7 |
6 files changed, 27 insertions, 79 deletions
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index c7ea0d9765..f995ff8718 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec2_smpl.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: ec2_smpl.c,v 1.32 2023/03/08 04:50:27 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -724,7 +724,6 @@ ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | |||
724 | } | 724 | } |
725 | 725 | ||
726 | static const EC_METHOD ec_GF2m_simple_method = { | 726 | static const EC_METHOD ec_GF2m_simple_method = { |
727 | .flags = EC_FLAGS_DEFAULT_OCT, | ||
728 | .field_type = NID_X9_62_characteristic_two_field, | 727 | .field_type = NID_X9_62_characteristic_two_field, |
729 | .group_init = ec_GF2m_simple_group_init, | 728 | .group_init = ec_GF2m_simple_group_init, |
730 | .group_finish = ec_GF2m_simple_group_finish, | 729 | .group_finish = ec_GF2m_simple_group_finish, |
@@ -744,6 +743,10 @@ static const EC_METHOD ec_GF2m_simple_method = { | |||
744 | ec_GF2m_simple_point_set_affine_coordinates, | 743 | ec_GF2m_simple_point_set_affine_coordinates, |
745 | .point_get_affine_coordinates = | 744 | .point_get_affine_coordinates = |
746 | ec_GF2m_simple_point_get_affine_coordinates, | 745 | ec_GF2m_simple_point_get_affine_coordinates, |
746 | .point_set_compressed_coordinates = | ||
747 | ec_GF2m_simple_set_compressed_coordinates, | ||
748 | .point2oct = ec_GF2m_simple_point2oct, | ||
749 | .oct2point = ec_GF2m_simple_oct2point, | ||
747 | .add = ec_GF2m_simple_add, | 750 | .add = ec_GF2m_simple_add, |
748 | .dbl = ec_GF2m_simple_dbl, | 751 | .dbl = ec_GF2m_simple_dbl, |
749 | .invert = ec_GF2m_simple_invert, | 752 | .invert = ec_GF2m_simple_invert, |
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index a1d7c9d3f2..d4cb777c83 100644 --- a/src/lib/libcrypto/ec/ec_local.h +++ b/src/lib/libcrypto/ec/ec_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_local.h,v 1.9 2023/03/07 05:50:59 jsing Exp $ */ | 1 | /* $OpenBSD: ec_local.h,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 | */ |
@@ -86,17 +86,7 @@ __BEGIN_HIDDEN_DECLS | |||
86 | # endif | 86 | # endif |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* Use default functions for poin2oct, oct2point and compressed coordinates */ | ||
90 | #define EC_FLAGS_DEFAULT_OCT 0x1 | ||
91 | |||
92 | struct ec_method_st { | 89 | struct ec_method_st { |
93 | |||
94 | /* | ||
95 | * Methods and members exposed directly by the public API. | ||
96 | */ | ||
97 | |||
98 | int flags; | ||
99 | |||
100 | int field_type; | 90 | int field_type; |
101 | 91 | ||
102 | int (*group_init)(EC_GROUP *); | 92 | int (*group_init)(EC_GROUP *); |
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 | |||
74 | EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, | 74 | EC_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 | ||
111 | int | 89 | int |
@@ -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 | |||
160 | EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, | 122 | EC_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 | } |
diff --git a/src/lib/libcrypto/ec/ecp_mont.c b/src/lib/libcrypto/ec/ecp_mont.c index f26107c20b..d0d497b011 100644 --- a/src/lib/libcrypto/ec/ecp_mont.c +++ b/src/lib/libcrypto/ec/ecp_mont.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_mont.c,v 1.25 2023/03/07 05:41:18 jsing Exp $ */ | 1 | /* $OpenBSD: ecp_mont.c,v 1.26 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 | */ |
@@ -233,7 +233,6 @@ ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) | |||
233 | } | 233 | } |
234 | 234 | ||
235 | static const EC_METHOD ec_GFp_mont_method = { | 235 | static const EC_METHOD ec_GFp_mont_method = { |
236 | .flags = EC_FLAGS_DEFAULT_OCT, | ||
237 | .field_type = NID_X9_62_prime_field, | 236 | .field_type = NID_X9_62_prime_field, |
238 | .group_init = ec_GFp_mont_group_init, | 237 | .group_init = ec_GFp_mont_group_init, |
239 | .group_finish = ec_GFp_mont_group_finish, | 238 | .group_finish = ec_GFp_mont_group_finish, |
@@ -257,6 +256,10 @@ static const EC_METHOD ec_GFp_mont_method = { | |||
257 | ec_GFp_simple_point_set_affine_coordinates, | 256 | ec_GFp_simple_point_set_affine_coordinates, |
258 | .point_get_affine_coordinates = | 257 | .point_get_affine_coordinates = |
259 | ec_GFp_simple_point_get_affine_coordinates, | 258 | ec_GFp_simple_point_get_affine_coordinates, |
259 | .point_set_compressed_coordinates = | ||
260 | ec_GFp_simple_set_compressed_coordinates, | ||
261 | .point2oct = ec_GFp_simple_point2oct, | ||
262 | .oct2point = ec_GFp_simple_oct2point, | ||
260 | .add = ec_GFp_simple_add, | 263 | .add = ec_GFp_simple_add, |
261 | .dbl = ec_GFp_simple_dbl, | 264 | .dbl = ec_GFp_simple_dbl, |
262 | .invert = ec_GFp_simple_invert, | 265 | .invert = ec_GFp_simple_invert, |
diff --git a/src/lib/libcrypto/ec/ecp_nist.c b/src/lib/libcrypto/ec/ecp_nist.c index 3a81a0e8d9..e3c13f7c65 100644 --- a/src/lib/libcrypto/ec/ecp_nist.c +++ b/src/lib/libcrypto/ec/ecp_nist.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_nist.c,v 1.22 2023/03/07 05:45:14 jsing Exp $ */ | 1 | /* $OpenBSD: ecp_nist.c,v 1.23 2023/03/08 04:50:27 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -168,7 +168,6 @@ ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | static const EC_METHOD ec_GFp_nist_method = { | 170 | static const EC_METHOD ec_GFp_nist_method = { |
171 | .flags = EC_FLAGS_DEFAULT_OCT, | ||
172 | .field_type = NID_X9_62_prime_field, | 171 | .field_type = NID_X9_62_prime_field, |
173 | .group_init = ec_GFp_simple_group_init, | 172 | .group_init = ec_GFp_simple_group_init, |
174 | .group_finish = ec_GFp_simple_group_finish, | 173 | .group_finish = ec_GFp_simple_group_finish, |
@@ -192,6 +191,10 @@ static const EC_METHOD ec_GFp_nist_method = { | |||
192 | ec_GFp_simple_point_set_affine_coordinates, | 191 | ec_GFp_simple_point_set_affine_coordinates, |
193 | .point_get_affine_coordinates = | 192 | .point_get_affine_coordinates = |
194 | ec_GFp_simple_point_get_affine_coordinates, | 193 | ec_GFp_simple_point_get_affine_coordinates, |
194 | .point_set_compressed_coordinates = | ||
195 | ec_GFp_simple_set_compressed_coordinates, | ||
196 | .point2oct = ec_GFp_simple_point2oct, | ||
197 | .oct2point = ec_GFp_simple_oct2point, | ||
195 | .add = ec_GFp_simple_add, | 198 | .add = ec_GFp_simple_add, |
196 | .dbl = ec_GFp_simple_dbl, | 199 | .dbl = ec_GFp_simple_dbl, |
197 | .invert = ec_GFp_simple_invert, | 200 | .invert = ec_GFp_simple_invert, |
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index df9806445c..c33347ad85 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_smpl.c,v 1.40 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.41 2023/03/08 04:50:27 jsing Exp $ */ |
2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
3 | * for the OpenSSL project. | 3 | * for the OpenSSL project. |
4 | * Includes code written by Bodo Moeller for the OpenSSL project. | 4 | * Includes code written by Bodo Moeller for the OpenSSL project. |
@@ -1654,7 +1654,6 @@ ec_GFp_simple_mul_double_nonct(const EC_GROUP *group, EC_POINT *r, | |||
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | static const EC_METHOD ec_GFp_simple_method = { | 1656 | static const EC_METHOD ec_GFp_simple_method = { |
1657 | .flags = EC_FLAGS_DEFAULT_OCT, | ||
1658 | .field_type = NID_X9_62_prime_field, | 1657 | .field_type = NID_X9_62_prime_field, |
1659 | .group_init = ec_GFp_simple_group_init, | 1658 | .group_init = ec_GFp_simple_group_init, |
1660 | .group_finish = ec_GFp_simple_group_finish, | 1659 | .group_finish = ec_GFp_simple_group_finish, |
@@ -1678,6 +1677,10 @@ static const EC_METHOD ec_GFp_simple_method = { | |||
1678 | ec_GFp_simple_point_set_affine_coordinates, | 1677 | ec_GFp_simple_point_set_affine_coordinates, |
1679 | .point_get_affine_coordinates = | 1678 | .point_get_affine_coordinates = |
1680 | ec_GFp_simple_point_get_affine_coordinates, | 1679 | ec_GFp_simple_point_get_affine_coordinates, |
1680 | .point_set_compressed_coordinates = | ||
1681 | ec_GFp_simple_set_compressed_coordinates, | ||
1682 | .point2oct = ec_GFp_simple_point2oct, | ||
1683 | .oct2point = ec_GFp_simple_oct2point, | ||
1681 | .add = ec_GFp_simple_add, | 1684 | .add = ec_GFp_simple_add, |
1682 | .dbl = ec_GFp_simple_dbl, | 1685 | .dbl = ec_GFp_simple_dbl, |
1683 | .invert = ec_GFp_simple_invert, | 1686 | .invert = ec_GFp_simple_invert, |