=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/dsa.c,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- src/usr.bin/ssh/Attic/dsa.c 2000/05/08 17:42:24 1.7 +++ src/usr.bin/ssh/Attic/dsa.c 2000/09/01 18:23:19 1.7.2.1 @@ -28,7 +28,7 @@ */ #include "includes.h" -RCSID("$Id: dsa.c,v 1.7 2000/05/08 17:42:24 markus Exp $"); +RCSID("$OpenBSD: dsa.c,v 1.7.2.1 2000/09/01 18:23:19 jason Exp $"); #include "ssh.h" #include "xmalloc.h" @@ -53,8 +53,7 @@ #define SIGBLOB_LEN (2*INTBLOB_LEN) Key * -dsa_key_from_blob( - char *blob, int blen) +dsa_key_from_blob(char *blob, int blen) { Buffer b; char *ktype; @@ -66,16 +65,17 @@ dump_base64(stderr, blob, blen); #endif /* fetch & parse DSA/DSS pubkey */ - key = key_new(KEY_DSA); - dsa = key->dsa; buffer_init(&b); buffer_append(&b, blob, blen); ktype = buffer_get_string(&b, NULL); if (strcmp(KEX_DSS, ktype) != 0) { - error("dsa_key_from_blob: cannot handle type %s", ktype); - key_free(key); + error("dsa_key_from_blob: cannot handle type %s", ktype); + buffer_free(&b); + xfree(ktype); return NULL; } + key = key_new(KEY_DSA); + dsa = key->dsa; buffer_get_bignum2(&b, dsa->p); buffer_get_bignum2(&b, dsa->q); buffer_get_bignum2(&b, dsa->g); @@ -84,8 +84,8 @@ if(rlen != 0) error("dsa_key_from_blob: remaining bytes in key blob %d", rlen); buffer_free(&b); + xfree(ktype); - debug("keytype %s", ktype); #ifdef DEBUG_DSS DSA_print_fp(stderr, dsa, 8); #endif @@ -197,7 +197,6 @@ DSA_SIG *sig; EVP_MD *evp_md = EVP_sha1(); EVP_MD_CTX md; - char *ktype; unsigned char *sigblob; char *txt; unsigned int len; @@ -227,14 +226,24 @@ len = signaturelen; } else { /* ietf-drafts */ + char *ktype; buffer_init(&b); buffer_append(&b, (char *) signature, signaturelen); ktype = buffer_get_string(&b, NULL); + if (strcmp(KEX_DSS, ktype) != 0) { + error("dsa_verify: cannot handle type %s", ktype); + buffer_free(&b); + return -1; + } sigblob = (unsigned char *)buffer_get_string(&b, &len); rlen = buffer_len(&b); - if(rlen != 0) + if(rlen != 0) { error("remaining bytes in signature %d", rlen); + buffer_free(&b); + return -1; + } buffer_free(&b); + xfree(ktype); } if (len != SIGBLOB_LEN) {