mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 13:02:47 -05:00
Refactor ecdh_kex into an organised vtable.
This is already slightly nice because it lets me separate the Weierstrass and Montgomery code more completely, without having to have a vtable tucked into dh->extra. But more to the point, it will allow completely different kex methods to fit into the same framework later. To that end, I've moved more of the descriptive message generation into the vtable, and also provided the constructor with a flag that will let it do different things in client and server. Also, following on from a previous commit, I've arranged that the new API returns arbitrary binary data for the exchange hash, rather than an mp_int. An upcoming implementation of this interface will want to return an encoded string instead of an encoded mp_int.
This commit is contained in:
@ -87,7 +87,7 @@ uint64_t prng_reseed_time_ms(void)
|
||||
X(cipher, ssh_cipher *, ssh_cipher_free(v)) \
|
||||
X(mac, ssh2_mac *, ssh2_mac_free(v)) \
|
||||
X(dh, dh_ctx *, dh_cleanup(v)) \
|
||||
X(ecdh, ecdh_key *, ssh_ecdhkex_freekey(v)) \
|
||||
X(ecdh, ecdh_key *, ecdh_key_free(v)) \
|
||||
X(rsakex, RSAKey *, ssh_rsakex_freekey(v)) \
|
||||
X(rsa, RSAKey *, rsa_free(v)) \
|
||||
X(prng, prng *, prng_free(v)) \
|
||||
@ -787,6 +787,18 @@ static RSAKey *rsa_new(void)
|
||||
return rsa;
|
||||
}
|
||||
|
||||
strbuf *ecdh_key_getkey_wrapper(ecdh_key *ek, ptrlen remoteKey)
|
||||
{
|
||||
/* Fold the boolean return value in C into the string return value
|
||||
* for this purpose, by returning NULL on failure */
|
||||
strbuf *sb = strbuf_new();
|
||||
if (!ecdh_key_getkey(ek, remoteKey, BinarySink_UPCAST(sb))) {
|
||||
strbuf_free(sb);
|
||||
return NULL;
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
strbuf *rsa_ssh1_encrypt_wrapper(ptrlen input, RSAKey *key)
|
||||
{
|
||||
/* Fold the boolean return value in C into the string return value
|
||||
|
Reference in New Issue
Block a user