|
|
@ -64,10 +64,15 @@ PUBLIC_KEY *publickey_make_dss(BUFFER *buffer){
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key->dsa_pub=DSA_new();
|
|
|
|
key->dsa_pub=DSA_new();
|
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
|
key->dsa_pub->p=make_string_bn(p);
|
|
|
|
key->dsa_pub->p=make_string_bn(p);
|
|
|
|
key->dsa_pub->q=make_string_bn(q);
|
|
|
|
key->dsa_pub->q=make_string_bn(q);
|
|
|
|
key->dsa_pub->g=make_string_bn(g);
|
|
|
|
key->dsa_pub->g=make_string_bn(g);
|
|
|
|
key->dsa_pub->pub_key=make_string_bn(pubkey);
|
|
|
|
key->dsa_pub->pub_key=make_string_bn(pubkey);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
DSA_set0_pqg(key->dsa_pub, make_string_bn(p), make_string_bn(q), make_string_bn(g));
|
|
|
|
|
|
|
|
DSA_set0_key(key->dsa_pub, make_string_bn(pubkey), NULL);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
free(p);
|
|
|
|
free(p);
|
|
|
|
free(q);
|
|
|
|
free(q);
|
|
|
|
free(g);
|
|
|
|
free(g);
|
|
|
@ -93,11 +98,17 @@ PUBLIC_KEY *publickey_make_rsa(BUFFER *buffer){
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
key->rsa_pub=RSA_new();
|
|
|
|
key->rsa_pub=RSA_new();
|
|
|
|
key->rsa_pub->e=make_string_bn(e);
|
|
|
|
BIGNUM *bn_e = make_string_bn(e);
|
|
|
|
key->rsa_pub->n=make_string_bn(n);
|
|
|
|
BIGNUM *bn_n = make_string_bn(n);
|
|
|
|
|
|
|
|
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
|
|
|
|
|
|
|
key->rsa_pub->e = bn_e;
|
|
|
|
|
|
|
|
key->rsa_pub->n = bn_n;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
RSA_set0_key(key->rsa_pub, bn_n, bn_e, NULL);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_CRYPTO
|
|
|
|
#ifdef DEBUG_CRYPTO
|
|
|
|
ssh_print_bignum("e",key->rsa_pub->e);
|
|
|
|
ssh_print_bignum("e", bn_e);
|
|
|
|
ssh_print_bignum("n",key->rsa_pub->n);
|
|
|
|
ssh_print_bignum("n", bn_n);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
free(e);
|
|
|
|
free(e);
|
|
|
|
free(n);
|
|
|
|
free(n);
|
|
|
@ -161,9 +172,17 @@ STRING *signature_to_string(SIGNATURE *sign){
|
|
|
|
buffer_add_ssh_string(tmpbuf,tmp);
|
|
|
|
buffer_add_ssh_string(tmpbuf,tmp);
|
|
|
|
free(tmp);
|
|
|
|
free(tmp);
|
|
|
|
switch(sign->type){
|
|
|
|
switch(sign->type){
|
|
|
|
case TYPE_DSS:
|
|
|
|
case TYPE_DSS: {
|
|
|
|
r=make_bignum_string(sign->dsa_sign->r);
|
|
|
|
BIGNUM *bn_r = 0L;
|
|
|
|
s=make_bignum_string(sign->dsa_sign->s);
|
|
|
|
BIGNUM *bn_s = 0L;
|
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
|
|
|
|
|
bn_r = sign->dsa_sign->r;
|
|
|
|
|
|
|
|
bn_s = sign->dsa_sign->s;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
DSA_SIG_get0(sign->dsa_sign, &bn_r, &bn_s);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
r = make_bignum_string(bn_r);
|
|
|
|
|
|
|
|
s = make_bignum_string(bn_s);
|
|
|
|
rs=string_new(40);
|
|
|
|
rs=string_new(40);
|
|
|
|
memset(buffer,0,40);
|
|
|
|
memset(buffer,0,40);
|
|
|
|
memcpy(buffer,r->string+string_len(r)-20,20);
|
|
|
|
memcpy(buffer,r->string+string_len(r)-20,20);
|
|
|
@ -174,6 +193,7 @@ STRING *signature_to_string(SIGNATURE *sign){
|
|
|
|
buffer_add_ssh_string(tmpbuf,rs);
|
|
|
|
buffer_add_ssh_string(tmpbuf,rs);
|
|
|
|
free(rs);
|
|
|
|
free(rs);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
case TYPE_RSA:
|
|
|
|
case TYPE_RSA:
|
|
|
|
case TYPE_RSA1:
|
|
|
|
case TYPE_RSA1:
|
|
|
|
buffer_add_ssh_string(tmpbuf,sign->rsa_sign);
|
|
|
|
buffer_add_ssh_string(tmpbuf,sign->rsa_sign);
|
|
|
@ -243,11 +263,17 @@ SIGNATURE *signature_from_string(STRING *signature,PUBLIC_KEY *pubkey,int needed
|
|
|
|
string_fill(s,rs->string+20,20);
|
|
|
|
string_fill(s,rs->string+20,20);
|
|
|
|
free(rs);
|
|
|
|
free(rs);
|
|
|
|
sig=DSA_SIG_new();
|
|
|
|
sig=DSA_SIG_new();
|
|
|
|
sig->r=make_string_bn(r); /* is that really portable ? Openssh's hack isn't better */
|
|
|
|
BIGNUM *bn_r = make_string_bn(r);
|
|
|
|
sig->s=make_string_bn(s);
|
|
|
|
BIGNUM *bn_s = make_string_bn(s);
|
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
|
|
|
|
|
|
sig->r = bn_r; /* is that really portable ? Openssh's hack isn't better */
|
|
|
|
|
|
|
|
sig->s = bn_s;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
DSA_SIG_set0(sig, bn_r, bn_s);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_CRYPTO
|
|
|
|
#ifdef DEBUG_CRYPTO
|
|
|
|
ssh_print_bignum("r",sig->r);
|
|
|
|
ssh_print_bignum("r", bn_r);
|
|
|
|
ssh_print_bignum("s",sig->s);
|
|
|
|
ssh_print_bignum("s", bn_s);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
free(r);
|
|
|
|
free(r);
|
|
|
|
free(s);
|
|
|
|
free(s);
|
|
|
|