version 1.7, 2000/05/08 17:42:24 |
version 1.7.2.1, 2000/09/01 18:23:19 |
|
|
*/ |
*/ |
|
|
#include "includes.h" |
#include "includes.h" |
RCSID("$Id$"); |
RCSID("$OpenBSD$"); |
|
|
#include "ssh.h" |
#include "ssh.h" |
#include "xmalloc.h" |
#include "xmalloc.h" |
|
|
#define SIGBLOB_LEN (2*INTBLOB_LEN) |
#define SIGBLOB_LEN (2*INTBLOB_LEN) |
|
|
Key * |
Key * |
dsa_key_from_blob( |
dsa_key_from_blob(char *blob, int blen) |
char *blob, int blen) |
|
{ |
{ |
Buffer b; |
Buffer b; |
char *ktype; |
char *ktype; |
|
|
dump_base64(stderr, blob, blen); |
dump_base64(stderr, blob, blen); |
#endif |
#endif |
/* fetch & parse DSA/DSS pubkey */ |
/* fetch & parse DSA/DSS pubkey */ |
key = key_new(KEY_DSA); |
|
dsa = key->dsa; |
|
buffer_init(&b); |
buffer_init(&b); |
buffer_append(&b, blob, blen); |
buffer_append(&b, blob, blen); |
ktype = buffer_get_string(&b, NULL); |
ktype = buffer_get_string(&b, NULL); |
if (strcmp(KEX_DSS, ktype) != 0) { |
if (strcmp(KEX_DSS, ktype) != 0) { |
error("dsa_key_from_blob: cannot handle type %s", ktype); |
error("dsa_key_from_blob: cannot handle type %s", ktype); |
key_free(key); |
buffer_free(&b); |
|
xfree(ktype); |
return NULL; |
return NULL; |
} |
} |
|
key = key_new(KEY_DSA); |
|
dsa = key->dsa; |
buffer_get_bignum2(&b, dsa->p); |
buffer_get_bignum2(&b, dsa->p); |
buffer_get_bignum2(&b, dsa->q); |
buffer_get_bignum2(&b, dsa->q); |
buffer_get_bignum2(&b, dsa->g); |
buffer_get_bignum2(&b, dsa->g); |
|
|
if(rlen != 0) |
if(rlen != 0) |
error("dsa_key_from_blob: remaining bytes in key blob %d", rlen); |
error("dsa_key_from_blob: remaining bytes in key blob %d", rlen); |
buffer_free(&b); |
buffer_free(&b); |
|
xfree(ktype); |
|
|
debug("keytype %s", ktype); |
|
#ifdef DEBUG_DSS |
#ifdef DEBUG_DSS |
DSA_print_fp(stderr, dsa, 8); |
DSA_print_fp(stderr, dsa, 8); |
#endif |
#endif |
|
|
DSA_SIG *sig; |
DSA_SIG *sig; |
EVP_MD *evp_md = EVP_sha1(); |
EVP_MD *evp_md = EVP_sha1(); |
EVP_MD_CTX md; |
EVP_MD_CTX md; |
char *ktype; |
|
unsigned char *sigblob; |
unsigned char *sigblob; |
char *txt; |
char *txt; |
unsigned int len; |
unsigned int len; |
|
|
len = signaturelen; |
len = signaturelen; |
} else { |
} else { |
/* ietf-drafts */ |
/* ietf-drafts */ |
|
char *ktype; |
buffer_init(&b); |
buffer_init(&b); |
buffer_append(&b, (char *) signature, signaturelen); |
buffer_append(&b, (char *) signature, signaturelen); |
ktype = buffer_get_string(&b, NULL); |
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); |
sigblob = (unsigned char *)buffer_get_string(&b, &len); |
rlen = buffer_len(&b); |
rlen = buffer_len(&b); |
if(rlen != 0) |
if(rlen != 0) { |
error("remaining bytes in signature %d", rlen); |
error("remaining bytes in signature %d", rlen); |
|
buffer_free(&b); |
|
return -1; |
|
} |
buffer_free(&b); |
buffer_free(&b); |
|
xfree(ktype); |
} |
} |
|
|
if (len != SIGBLOB_LEN) { |
if (len != SIGBLOB_LEN) { |