mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
handle case when encoded key is (p-1)/2
This commit is contained in:
parent
4d7b86ca26
commit
36eaaa748c
|
@ -100,7 +100,7 @@ namespace crypto
|
||||||
|
|
||||||
BIGNUM * r = BN_CTX_get (ctx); BN_bin2bn (encoded1, 32, r);
|
BIGNUM * r = BN_CTX_get (ctx); BN_bin2bn (encoded1, 32, r);
|
||||||
|
|
||||||
if (BN_cmp (r, p12) < 0) // r < (p-1)/2
|
if (BN_cmp (r, p12) <= 0) // r < (p-1)/2
|
||||||
{
|
{
|
||||||
// v = -A/(1+u*r^2)
|
// v = -A/(1+u*r^2)
|
||||||
BIGNUM * v = BN_CTX_get (ctx); BN_mod_sqr (v, r, p, ctx);
|
BIGNUM * v = BN_CTX_get (ctx); BN_mod_sqr (v, r, p, ctx);
|
||||||
|
|
|
@ -40,6 +40,17 @@ const uint8_t key2[32] =
|
||||||
0xe5, 0x78, 0x2b, 0xe1, 0xe1, 0x14, 0x5c, 0xe2, 0xc3, 0xc6, 0xfd, 0xe1, 0x6d, 0xed, 0x53, 0x63
|
0xe5, 0x78, 0x2b, 0xe1, 0xe1, 0x14, 0x5c, 0xe2, 0xc3, 0xc6, 0xfd, 0xe1, 0x6d, 0xed, 0x53, 0x63
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const uint8_t encoded3[32] =
|
||||||
|
{
|
||||||
|
0xf6, 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, 0x3f
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t key3[32] =
|
||||||
|
{
|
||||||
|
0x9c, 0xdb, 0x52, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||||
|
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55
|
||||||
|
};
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
|
@ -53,4 +64,6 @@ int main ()
|
||||||
assert(memcmp (buf, key1, 32) == 0);
|
assert(memcmp (buf, key1, 32) == 0);
|
||||||
el.Decode (encoded2, buf);
|
el.Decode (encoded2, buf);
|
||||||
assert(memcmp (buf, key2, 32) == 0);
|
assert(memcmp (buf, key2, 32) == 0);
|
||||||
|
el.Decode (encoded3, buf);
|
||||||
|
assert(memcmp (buf, key3, 32) == 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue