diff options
| author | tb <> | 2021-05-03 14:42:45 +0000 |
|---|---|---|
| committer | tb <> | 2021-05-03 14:42:45 +0000 |
| commit | 82b0d687e18b8ea78530ec447ec145e545f4c0a7 (patch) | |
| tree | c05cb593b6e5349e258bbd2973aeafb09bb61957 /src/lib/libc | |
| parent | 5d87329128299a026964aacdf65838e004de6844 (diff) | |
| download | openbsd-82b0d687e18b8ea78530ec447ec145e545f4c0a7.tar.gz openbsd-82b0d687e18b8ea78530ec447ec145e545f4c0a7.tar.bz2 openbsd-82b0d687e18b8ea78530ec447ec145e545f4c0a7.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 '')
| -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 { |
