diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec2_oct.c')
-rw-r--r-- | src/lib/libcrypto/ec/ec2_oct.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/libcrypto/ec/ec2_oct.c b/src/lib/libcrypto/ec/ec2_oct.c index 72690b1bc7..f434d726d2 100644 --- a/src/lib/libcrypto/ec/ec2_oct.c +++ b/src/lib/libcrypto/ec/ec2_oct.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec2_oct.c,v 1.7 2015/02/09 15:49:22 jsing Exp $ */ | 1 | /* $OpenBSD: ec2_oct.c,v 1.8 2017/01/29 17:49:23 beck Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -138,9 +138,9 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point | |||
138 | if (ERR_GET_LIB(err) == ERR_LIB_BN && | 138 | if (ERR_GET_LIB(err) == ERR_LIB_BN && |
139 | ERR_GET_REASON(err) == BN_R_NO_SOLUTION) { | 139 | ERR_GET_REASON(err) == BN_R_NO_SOLUTION) { |
140 | ERR_clear_error(); | 140 | ERR_clear_error(); |
141 | ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, EC_R_INVALID_COMPRESSED_POINT); | 141 | ECerror(EC_R_INVALID_COMPRESSED_POINT); |
142 | } else | 142 | } else |
143 | ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_BN_LIB); | 143 | ECerror(ERR_R_BN_LIB); |
144 | goto err; | 144 | goto err; |
145 | } | 145 | } |
146 | z0 = (BN_is_odd(z)) ? 1 : 0; | 146 | z0 = (BN_is_odd(z)) ? 1 : 0; |
@@ -182,14 +182,14 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
182 | if ((form != POINT_CONVERSION_COMPRESSED) | 182 | if ((form != POINT_CONVERSION_COMPRESSED) |
183 | && (form != POINT_CONVERSION_UNCOMPRESSED) | 183 | && (form != POINT_CONVERSION_UNCOMPRESSED) |
184 | && (form != POINT_CONVERSION_HYBRID)) { | 184 | && (form != POINT_CONVERSION_HYBRID)) { |
185 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); | 185 | ECerror(EC_R_INVALID_FORM); |
186 | goto err; | 186 | goto err; |
187 | } | 187 | } |
188 | if (EC_POINT_is_at_infinity(group, point) > 0) { | 188 | if (EC_POINT_is_at_infinity(group, point) > 0) { |
189 | /* encodes to a single 0 octet */ | 189 | /* encodes to a single 0 octet */ |
190 | if (buf != NULL) { | 190 | if (buf != NULL) { |
191 | if (len < 1) { | 191 | if (len < 1) { |
192 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); | 192 | ECerror(EC_R_BUFFER_TOO_SMALL); |
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | buf[0] = 0; | 195 | buf[0] = 0; |
@@ -204,7 +204,7 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
204 | /* if 'buf' is NULL, just return required length */ | 204 | /* if 'buf' is NULL, just return required length */ |
205 | if (buf != NULL) { | 205 | if (buf != NULL) { |
206 | if (len < ret) { | 206 | if (len < ret) { |
207 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_BUFFER_TOO_SMALL); | 207 | ECerror(EC_R_BUFFER_TOO_SMALL); |
208 | goto err; | 208 | goto err; |
209 | } | 209 | } |
210 | if (ctx == NULL) { | 210 | if (ctx == NULL) { |
@@ -235,7 +235,7 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
235 | 235 | ||
236 | skip = field_len - BN_num_bytes(x); | 236 | skip = field_len - BN_num_bytes(x); |
237 | if (skip > field_len) { | 237 | if (skip > field_len) { |
238 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); | 238 | ECerror(ERR_R_INTERNAL_ERROR); |
239 | goto err; | 239 | goto err; |
240 | } | 240 | } |
241 | while (skip > 0) { | 241 | while (skip > 0) { |
@@ -245,14 +245,14 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
245 | skip = BN_bn2bin(x, buf + i); | 245 | skip = BN_bn2bin(x, buf + i); |
246 | i += skip; | 246 | i += skip; |
247 | if (i != 1 + field_len) { | 247 | if (i != 1 + field_len) { |
248 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); | 248 | ECerror(ERR_R_INTERNAL_ERROR); |
249 | goto err; | 249 | goto err; |
250 | } | 250 | } |
251 | if (form == POINT_CONVERSION_UNCOMPRESSED || | 251 | if (form == POINT_CONVERSION_UNCOMPRESSED || |
252 | form == POINT_CONVERSION_HYBRID) { | 252 | form == POINT_CONVERSION_HYBRID) { |
253 | skip = field_len - BN_num_bytes(y); | 253 | skip = field_len - BN_num_bytes(y); |
254 | if (skip > field_len) { | 254 | if (skip > field_len) { |
255 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); | 255 | ECerror(ERR_R_INTERNAL_ERROR); |
256 | goto err; | 256 | goto err; |
257 | } | 257 | } |
258 | while (skip > 0) { | 258 | while (skip > 0) { |
@@ -263,7 +263,7 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | |||
263 | i += skip; | 263 | i += skip; |
264 | } | 264 | } |
265 | if (i != ret) { | 265 | if (i != ret) { |
266 | ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, ERR_R_INTERNAL_ERROR); | 266 | ECerror(ERR_R_INTERNAL_ERROR); |
267 | goto err; | 267 | goto err; |
268 | } | 268 | } |
269 | } | 269 | } |
@@ -295,7 +295,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
295 | int ret = 0; | 295 | int ret = 0; |
296 | 296 | ||
297 | if (len == 0) { | 297 | if (len == 0) { |
298 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_BUFFER_TOO_SMALL); | 298 | ECerror(EC_R_BUFFER_TOO_SMALL); |
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | form = buf[0]; | 301 | form = buf[0]; |
@@ -304,16 +304,16 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
304 | if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) && | 304 | if ((form != 0) && (form != POINT_CONVERSION_COMPRESSED) && |
305 | (form != POINT_CONVERSION_UNCOMPRESSED) && | 305 | (form != POINT_CONVERSION_UNCOMPRESSED) && |
306 | (form != POINT_CONVERSION_HYBRID)) { | 306 | (form != POINT_CONVERSION_HYBRID)) { |
307 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 307 | ECerror(EC_R_INVALID_ENCODING); |
308 | return 0; | 308 | return 0; |
309 | } | 309 | } |
310 | if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) { | 310 | if ((form == 0 || form == POINT_CONVERSION_UNCOMPRESSED) && y_bit) { |
311 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 311 | ECerror(EC_R_INVALID_ENCODING); |
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | if (form == 0) { | 314 | if (form == 0) { |
315 | if (len != 1) { | 315 | if (len != 1) { |
316 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 316 | ECerror(EC_R_INVALID_ENCODING); |
317 | return 0; | 317 | return 0; |
318 | } | 318 | } |
319 | return EC_POINT_set_to_infinity(group, point); | 319 | return EC_POINT_set_to_infinity(group, point); |
@@ -323,7 +323,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
323 | 1 + 2 * field_len; | 323 | 1 + 2 * field_len; |
324 | 324 | ||
325 | if (len != enc_len) { | 325 | if (len != enc_len) { |
326 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 326 | ECerror(EC_R_INVALID_ENCODING); |
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | if (ctx == NULL) { | 329 | if (ctx == NULL) { |
@@ -342,7 +342,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
342 | if (!BN_bin2bn(buf + 1, field_len, x)) | 342 | if (!BN_bin2bn(buf + 1, field_len, x)) |
343 | goto err; | 343 | goto err; |
344 | if (BN_ucmp(x, &group->field) >= 0) { | 344 | if (BN_ucmp(x, &group->field) >= 0) { |
345 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 345 | ECerror(EC_R_INVALID_ENCODING); |
346 | goto err; | 346 | goto err; |
347 | } | 347 | } |
348 | if (form == POINT_CONVERSION_COMPRESSED) { | 348 | if (form == POINT_CONVERSION_COMPRESSED) { |
@@ -352,14 +352,14 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
352 | if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) | 352 | if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) |
353 | goto err; | 353 | goto err; |
354 | if (BN_ucmp(y, &group->field) >= 0) { | 354 | if (BN_ucmp(y, &group->field) >= 0) { |
355 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 355 | ECerror(EC_R_INVALID_ENCODING); |
356 | goto err; | 356 | goto err; |
357 | } | 357 | } |
358 | if (form == POINT_CONVERSION_HYBRID) { | 358 | if (form == POINT_CONVERSION_HYBRID) { |
359 | if (!group->meth->field_div(group, yxi, y, x, ctx)) | 359 | if (!group->meth->field_div(group, yxi, y, x, ctx)) |
360 | goto err; | 360 | goto err; |
361 | if (y_bit != BN_is_odd(yxi)) { | 361 | if (y_bit != BN_is_odd(yxi)) { |
362 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_INVALID_ENCODING); | 362 | ECerror(EC_R_INVALID_ENCODING); |
363 | goto err; | 363 | goto err; |
364 | } | 364 | } |
365 | } | 365 | } |
@@ -369,7 +369,7 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, | |||
369 | 369 | ||
370 | /* test required by X9.62 */ | 370 | /* test required by X9.62 */ |
371 | if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { | 371 | if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { |
372 | ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); | 372 | ECerror(EC_R_POINT_IS_NOT_ON_CURVE); |
373 | goto err; | 373 | goto err; |
374 | } | 374 | } |
375 | ret = 1; | 375 | ret = 1; |