projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove some redundant null-pointer checks from code that must have
[u/mdw/putty]
/
sshrsa.c
diff --git
a/sshrsa.c
b/sshrsa.c
index
6403343
..
3bd971f
100644
(file)
--- a/
sshrsa.c
+++ b/
sshrsa.c
@@
-413,16
+413,18
@@
int rsa_verify(struct RSAKey *key)
pm1 = copybn(key->p);
decbn(pm1);
ed = modmul(key->exponent, key->private_exponent, pm1);
pm1 = copybn(key->p);
decbn(pm1);
ed = modmul(key->exponent, key->private_exponent, pm1);
+ freebn(pm1);
cmp = bignum_cmp(ed, One);
cmp = bignum_cmp(ed, One);
-
sfree
(ed);
+
freebn
(ed);
if (cmp != 0)
return 0;
qm1 = copybn(key->q);
decbn(qm1);
ed = modmul(key->exponent, key->private_exponent, qm1);
if (cmp != 0)
return 0;
qm1 = copybn(key->q);
decbn(qm1);
ed = modmul(key->exponent, key->private_exponent, qm1);
+ freebn(qm1);
cmp = bignum_cmp(ed, One);
cmp = bignum_cmp(ed, One);
-
sfree
(ed);
+
freebn
(ed);
if (cmp != 0)
return 0;
if (cmp != 0)
return 0;
@@
-448,7
+450,7
@@
int rsa_verify(struct RSAKey *key)
*/
n = modmul(key->iqmp, key->q, key->p);
cmp = bignum_cmp(n, One);
*/
n = modmul(key->iqmp, key->q, key->p);
cmp = bignum_cmp(n, One);
-
sfree
(n);
+
freebn
(n);
if (cmp != 0)
return 0;
if (cmp != 0)
return 0;
@@
-556,8
+558,6
@@
static void *rsa2_newkey(char *data, int len)
struct RSAKey *rsa;
rsa = snew(struct RSAKey);
struct RSAKey *rsa;
rsa = snew(struct RSAKey);
- if (!rsa)
- return NULL;
getstring(&data, &len, &p, &slen);
if (!p || slen != 7 || memcmp(p, "ssh-rsa", 7)) {
getstring(&data, &len, &p, &slen);
if (!p || slen != 7 || memcmp(p, "ssh-rsa", 7)) {
@@
-692,8
+692,6
@@
static void *rsa2_openssh_createkey(unsigned char **blob, int *len)
struct RSAKey *rsa;
rsa = snew(struct RSAKey);
struct RSAKey *rsa;
rsa = snew(struct RSAKey);
- if (!rsa)
- return NULL;
rsa->comment = NULL;
rsa->modulus = getmp(b, len);
rsa->comment = NULL;
rsa->modulus = getmp(b, len);
@@
-705,13
+703,12
@@
static void *rsa2_openssh_createkey(unsigned char **blob, int *len)
if (!rsa->modulus || !rsa->exponent || !rsa->private_exponent ||
!rsa->iqmp || !rsa->p || !rsa->q) {
if (!rsa->modulus || !rsa->exponent || !rsa->private_exponent ||
!rsa->iqmp || !rsa->p || !rsa->q) {
- sfree(rsa->modulus);
- sfree(rsa->exponent);
- sfree(rsa->private_exponent);
- sfree(rsa->iqmp);
- sfree(rsa->p);
- sfree(rsa->q);
- sfree(rsa);
+ rsa2_freekey(rsa);
+ return NULL;
+ }
+
+ if (!rsa_verify(rsa)) {
+ rsa2_freekey(rsa);
return NULL;
}
return NULL;
}
@@
-840,6
+837,8
@@
static int rsa2_verifysig(void *key, char *sig, int siglen,
return 0;
}
in = getmp(&sig, &siglen);
return 0;
}
in = getmp(&sig, &siglen);
+ if (!in)
+ return 0;
out = modpow(in, rsa->exponent, rsa->modulus);
freebn(in);
out = modpow(in, rsa->exponent, rsa->modulus);
freebn(in);