1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 04:22:47 -05:00

Tidy up the API for RSA key exchange.

ssh_rsakex_encrypt took an input (pointer, length) pair, which I've
replaced with a ptrlen; it also took an _output_ (pointer, length)
pair, and then re-computed the right length internally and enforced by
assertion that the one passed in matched it. Now it just returns a
strbuf of whatever length it computed, which saves the caller having
to compute the length at all.

Also, both ssh_rsakex_encrypt and ssh_rsakex_decrypt took their
arguments in a weird order; I think it looks more sensible to put the
RSA key first rather than last, so now they both have the common order
(key, hash, input data).
This commit is contained in:
Simon Tatham
2019-01-02 08:39:16 +00:00
parent a2d1c211a7
commit 2bd76ed88c
4 changed files with 21 additions and 25 deletions

9
ssh.h
View File

@ -535,11 +535,10 @@ struct ssh_rsa_kex_extra {
struct RSAKey *ssh_rsakex_newkey(ptrlen data);
void ssh_rsakex_freekey(struct RSAKey *key);
int ssh_rsakex_klen(struct RSAKey *key);
void ssh_rsakex_encrypt(const struct ssh_hashalg *h,
unsigned char *in, int inlen,
unsigned char *out, int outlen, struct RSAKey *key);
mp_int *ssh_rsakex_decrypt(const struct ssh_hashalg *h, ptrlen ciphertext,
struct RSAKey *rsa);
strbuf *ssh_rsakex_encrypt(
struct RSAKey *key, const struct ssh_hashalg *h, ptrlen plaintext);
mp_int *ssh_rsakex_decrypt(
struct RSAKey *key, const struct ssh_hashalg *h, ptrlen ciphertext);
/*
* SSH2 ECDH key exchange functions