diff options
author | tb <> | 2021-05-03 14:42:45 +0000 |
---|---|---|
committer | tb <> | 2021-05-03 14:42:45 +0000 |
commit | e41e07ada75c7e9fa51b95c405887a56a5a62f03 (patch) | |
tree | c05cb593b6e5349e258bbd2973aeafb09bb61957 /src/lib | |
parent | 78065e450b71ce970f3662afff62eb22cb0a8da8 (diff) | |
download | openbsd-e41e07ada75c7e9fa51b95c405887a56a5a62f03.tar.gz openbsd-e41e07ada75c7e9fa51b95c405887a56a5a62f03.tar.bz2 openbsd-e41e07ada75c7e9fa51b95c405887a56a5a62f03.zip |
Fix corner case for compressed points on binary curves
Per X9.62 4.4.1.b., the compressed representation of a point with
zero x coordinate on a binary curve must have y_bit unset. Error
out in that case of ec_GF2m_set_compressed_coordinates() instead
of ignoring y_bit.
ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/ec/ec2_oct.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/ec/ec2_oct.c b/src/lib/libcrypto/ec/ec2_oct.c index ad38991471..832083c628 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.15 2021/04/20 17:32:57 tb Exp $ */ | 1 | /* $OpenBSD: ec2_oct.c,v 1.16 2021/05/03 14:42:45 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -121,6 +121,10 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point | |||
121 | if (!BN_GF2m_mod_arr(x, x_, group->poly)) | 121 | if (!BN_GF2m_mod_arr(x, x_, group->poly)) |
122 | goto err; | 122 | goto err; |
123 | if (BN_is_zero(x)) { | 123 | if (BN_is_zero(x)) { |
124 | if (y_bit != 0) { | ||
125 | ECerror(EC_R_INVALID_COMPRESSED_POINT); | ||
126 | goto err; | ||
127 | } | ||
124 | if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) | 128 | if (!BN_GF2m_mod_sqrt_arr(y, &group->b, group->poly, ctx)) |
125 | goto err; | 129 | goto err; |
126 | } else { | 130 | } else { |