mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Use a strbuf in ssh_ecdhkex_m_setup.
This removes the one remaining failure at -Wvla. (Of course, that array isn't for a _hash_ function, so it wouldn't have been quite appropriate to make it a static array of size MAX_HASH_LEN.)
This commit is contained in:
parent
53f0ce3d0c
commit
8d6d7a3615
16
sshecc.c
16
sshecc.c
@ -1269,15 +1269,15 @@ static void ssh_ecdhkex_w_setup(ecdh_key *dh)
|
|||||||
|
|
||||||
static void ssh_ecdhkex_m_setup(ecdh_key *dh)
|
static void ssh_ecdhkex_m_setup(ecdh_key *dh)
|
||||||
{
|
{
|
||||||
unsigned char bytes[dh->curve->fieldBytes];
|
strbuf *bytes;
|
||||||
for (size_t i = 0; i < sizeof(bytes); ++i)
|
for (size_t i = 0; i < dh->curve->fieldBytes; ++i)
|
||||||
bytes[i] = random_byte();
|
put_byte(bytes, random_byte());
|
||||||
|
|
||||||
bytes[0] &= 0xF8;
|
bytes->u[0] &= 0xF8;
|
||||||
bytes[dh->curve->fieldBytes-1] &= 0x7F;
|
bytes->u[bytes->len-1] &= 0x7F;
|
||||||
bytes[dh->curve->fieldBytes-1] |= 0x40;
|
bytes->u[bytes->len-1] |= 0x40;
|
||||||
dh->private = mp_from_bytes_le(make_ptrlen(bytes, dh->curve->fieldBytes));
|
dh->private = mp_from_bytes_le(ptrlen_from_strbuf(bytes));
|
||||||
smemclr(bytes, sizeof(bytes));
|
strbuf_free(bytes);
|
||||||
|
|
||||||
dh->m_public = ecc_montgomery_multiply(dh->curve->m.G, dh->private);
|
dh->m_public = ecc_montgomery_multiply(dh->curve->m.G, dh->private);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user