X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshecc.c;h=e1166827f1143a3f9d692c17d6f8913879a4b05d;hb=f2e76e07dad155a2fdc68930a2e96d6aa2682391;hp=3912c5f1bd3e82ee58a032e13ead034124a1af66;hpb=12702cb17ebe3c6a79284a3d24e95df745aac5e3;p=PuTTY.git diff --git a/sshecc.c b/sshecc.c index 3912c5f1..e1166827 100644 --- a/sshecc.c +++ b/sshecc.c @@ -2029,10 +2029,10 @@ static void *ed25519_openssh_createkey(const struct ssh_signkey *self, } getstring((const char**)blob, len, &q, &qlen); - if (!q) - return NULL; - if (qlen != 64) + if (!q || qlen != 64) { + ecdsa_freekey(ec); return NULL; + } ec->privateKey = bignum_from_bytes_le((const unsigned char *)q, 32); @@ -2760,11 +2760,8 @@ void *ssh_ecdhkex_newkey(const struct ssh_kex *kex) bytes[0] &= 248; bytes[31] &= 127; bytes[31] |= 64; - key->privateKey = bignum_from_bytes(bytes, sizeof(bytes)); - for (i = 0; i < sizeof(bytes); ++i) - { - ((volatile char*)bytes)[i] = 0; - } + key->privateKey = bignum_from_bytes_le(bytes, sizeof(bytes)); + smemclr(bytes, sizeof(bytes)); if (!key->privateKey) { sfree(key); return NULL; @@ -2940,9 +2937,12 @@ const unsigned char *ec_alg_oid(const struct ssh_signkey *alg, return extra->oid; } -const int ec_nist_alg_and_curve_by_bits(int bits, - const struct ec_curve **curve, - const struct ssh_signkey **alg) +const int ec_nist_curve_lengths[] = { 256, 384, 521 }; +const int n_ec_nist_curve_lengths = lenof(ec_nist_curve_lengths); + +int ec_nist_alg_and_curve_by_bits(int bits, + const struct ec_curve **curve, + const struct ssh_signkey **alg) { switch (bits) { case 256: *alg = &ssh_ecdsa_nistp256; break; @@ -2954,9 +2954,9 @@ const int ec_nist_alg_and_curve_by_bits(int bits, return TRUE; } -const int ec_ed_alg_and_curve_by_bits(int bits, - const struct ec_curve **curve, - const struct ssh_signkey **alg) +int ec_ed_alg_and_curve_by_bits(int bits, + const struct ec_curve **curve, + const struct ssh_signkey **alg) { switch (bits) { case 256: *alg = &ssh_ecdsa_ed25519; break;