summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_oct.c
diff options
context:
space:
mode:
authortb <>2021-04-20 17:32:57 +0000
committertb <>2021-04-20 17:32:57 +0000
commite3bdd39cc031d39a8ea071c9a8ecea5b6a958967 (patch)
treeb19c2d7871b27d3b2f6ce519613278cb8c4140a5 /src/lib/libcrypto/ec/ec_oct.c
parent5ac32b17def2bf66d2e60cc7866c946a98c4a411 (diff)
downloadopenbsd-e3bdd39cc031d39a8ea071c9a8ecea5b6a958967.tar.gz
openbsd-e3bdd39cc031d39a8ea071c9a8ecea5b6a958967.tar.bz2
openbsd-e3bdd39cc031d39a8ea071c9a8ecea5b6a958967.zip
Prepare to provide EC_POINT_set_compressed_coordinates
ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_oct.c')
-rw-r--r--src/lib/libcrypto/ec/ec_oct.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/src/lib/libcrypto/ec/ec_oct.c b/src/lib/libcrypto/ec/ec_oct.c
index a285c81459..a3a826d0f1 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.6 2020/12/04 08:55:30 tb Exp $ */ 1/* $OpenBSD: ec_oct.c,v 1.7 2021/04/20 17:32:57 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 */
@@ -70,9 +70,9 @@
70 70
71#include "ec_lcl.h" 71#include "ec_lcl.h"
72 72
73int 73int
74EC_POINT_set_compressed_coordinates_GFp(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 == 0 77 if (group->meth->point_set_compressed_coordinates == 0
78 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { 78 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
@@ -108,40 +108,23 @@ EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP * group, EC_POINT * point
108 return 1; 108 return 1;
109} 109}
110 110
111int
112EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
113 const BIGNUM *x, int y_bit, BN_CTX *ctx)
114{
115 return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx);
116}
117
111#ifndef OPENSSL_NO_EC2M 118#ifndef OPENSSL_NO_EC2M
112int 119int
113EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP * group, EC_POINT * point, 120EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
114 const BIGNUM * x, int y_bit, BN_CTX * ctx) 121 const BIGNUM *x, int y_bit, BN_CTX *ctx)
115{ 122{
116 if (group->meth->point_set_compressed_coordinates == 0 123 return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx);
117 && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
118 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
119 return 0;
120 }
121 if (group->meth != point->meth) {
122 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
123 return 0;
124 }
125 if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) {
126 if (group->meth->field_type == NID_X9_62_prime_field)
127 return ec_GFp_simple_set_compressed_coordinates(
128 group, point, x, y_bit, ctx);
129 else
130 return ec_GF2m_simple_set_compressed_coordinates(
131 group, point, x, y_bit, ctx);
132 }
133 if (!group->meth->point_set_compressed_coordinates(group, point, x,
134 y_bit, ctx))
135 return 0;
136 if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
137 ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
138 return 0;
139 }
140 return 1;
141} 124}
142#endif 125#endif
143 126
144size_t 127size_t
145EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, 128EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
146 point_conversion_form_t form, 129 point_conversion_form_t form,
147 unsigned char *buf, size_t len, BN_CTX *ctx) 130 unsigned char *buf, size_t len, BN_CTX *ctx)
@@ -173,8 +156,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
173 return group->meth->point2oct(group, point, form, buf, len, ctx); 156 return group->meth->point2oct(group, point, form, buf, len, ctx);
174} 157}
175 158
176 159int
177int
178EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, 160EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
179 const unsigned char *buf, size_t len, BN_CTX *ctx) 161 const unsigned char *buf, size_t len, BN_CTX *ctx)
180{ 162{