mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
core_ed25519_is_valid_point: check Y==Z in addition to X==0
This commit is contained in:
@@ -1044,10 +1044,13 @@ int
|
||||
ge25519_is_on_main_subgroup(const ge25519_p3 *p)
|
||||
{
|
||||
ge25519_p3 pl;
|
||||
fe25519 t;
|
||||
|
||||
ge25519_mul_l(&pl, p);
|
||||
|
||||
return fe25519_iszero(pl.X);
|
||||
fe25519_sub(t, pl.Y, pl.Z);
|
||||
|
||||
return fe25519_iszero(pl.X) & fe25519_iszero(t);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -13,6 +13,10 @@ static const unsigned char max_canonical_p[32] = {
|
||||
0xe4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
|
||||
};
|
||||
static const unsigned char not_main_subgroup_p[32] = {
|
||||
0x95, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99,
|
||||
0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99
|
||||
};
|
||||
static const unsigned char L_p1[32] = {
|
||||
0xee, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10
|
||||
@@ -142,11 +146,12 @@ main(void)
|
||||
assert(crypto_core_ed25519_is_valid_point(p) == 0);
|
||||
|
||||
p[0] = 9;
|
||||
assert(crypto_core_ed25519_is_valid_point(p) == 1);
|
||||
assert(crypto_core_ed25519_is_valid_point(p) == 0);
|
||||
|
||||
assert(crypto_core_ed25519_is_valid_point(max_canonical_p) == 1);
|
||||
assert(crypto_core_ed25519_is_valid_point(non_canonical_invalid_p) == 0);
|
||||
assert(crypto_core_ed25519_is_valid_point(non_canonical_p) == 0);
|
||||
assert(crypto_core_ed25519_is_valid_point(not_main_subgroup_p) == 0);
|
||||
|
||||
memcpy(p2, p, crypto_core_ed25519_BYTES);
|
||||
add_P(p2);
|
||||
|
||||
Reference in New Issue
Block a user