X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=sshrsa.c;h=e565a64ac791ff7be104a17f27814f4962f32fc7;hb=145ecf611238c4f1e39d89d3eee40319a2c54fe8;hp=9042c43a0c9282a03eff72855e3fd2a0b2b39621;hpb=8682246d33f21e369a3e5b38fa2fdec58b1e4425;p=PuTTY.git diff --git a/sshrsa.c b/sshrsa.c index 9042c43a..e565a64a 100644 --- a/sshrsa.c +++ b/sshrsa.c @@ -565,7 +565,8 @@ static Bignum getmp(const char **data, int *datalen) static void rsa2_freekey(void *key); /* forward reference */ -static void *rsa2_newkey(const char *data, int len) +static void *rsa2_newkey(const struct ssh_signkey *self, + const char *data, int len) { const char *p; int slen; @@ -685,13 +686,14 @@ static unsigned char *rsa2_private_blob(void *key, int *len) return blob; } -static void *rsa2_createkey(const unsigned char *pub_blob, int pub_len, +static void *rsa2_createkey(const struct ssh_signkey *self, + const unsigned char *pub_blob, int pub_len, const unsigned char *priv_blob, int priv_len) { struct RSAKey *rsa; const char *pb = (const char *) priv_blob; - rsa = rsa2_newkey((char *) pub_blob, pub_len); + rsa = rsa2_newkey(self, (char *) pub_blob, pub_len); rsa->private_exponent = getmp(&pb, &priv_len); rsa->p = getmp(&pb, &priv_len); rsa->q = getmp(&pb, &priv_len); @@ -705,7 +707,8 @@ static void *rsa2_createkey(const unsigned char *pub_blob, int pub_len, return rsa; } -static void *rsa2_openssh_createkey(const unsigned char **blob, int *len) +static void *rsa2_openssh_createkey(const struct ssh_signkey *self, + const unsigned char **blob, int *len) { const char **b = (const char **) blob; struct RSAKey *rsa; @@ -763,12 +766,15 @@ static int rsa2_openssh_fmtkey(void *key, unsigned char *blob, int len) return bloblen; } -static int rsa2_pubkey_bits(const void *blob, int len) +static int rsa2_pubkey_bits(const struct ssh_signkey *self, + const void *blob, int len) { struct RSAKey *rsa; int ret; - rsa = rsa2_newkey((const char *) blob, len); + rsa = rsa2_newkey(self, (const char *) blob, len); + if (!rsa) + return -1; ret = bignum_bitcount(rsa->modulus); rsa2_freekey(rsa); @@ -913,12 +919,13 @@ const struct ssh_signkey ssh_rsa = { rsa2_verifysig, rsa2_sign, "ssh-rsa", - "rsa2" + "rsa2", + NULL, }; void *ssh_rsakex_newkey(char *data, int len) { - return rsa2_newkey(data, len); + return rsa2_newkey(&ssh_rsa, data, len); } void ssh_rsakex_freekey(void *key) @@ -1053,11 +1060,11 @@ void ssh_rsakex_encrypt(const struct ssh_hash *h, unsigned char *in, int inlen, } static const struct ssh_kex ssh_rsa_kex_sha1 = { - "rsa1024-sha1", NULL, KEXTYPE_RSA, NULL, NULL, 0, 0, &ssh_sha1 + "rsa1024-sha1", NULL, KEXTYPE_RSA, &ssh_sha1, NULL, }; static const struct ssh_kex ssh_rsa_kex_sha256 = { - "rsa2048-sha256", NULL, KEXTYPE_RSA, NULL, NULL, 0, 0, &ssh_sha256 + "rsa2048-sha256", NULL, KEXTYPE_RSA, &ssh_sha256, NULL, }; static const struct ssh_kex *const rsa_kex_list[] = {