summaryrefslogtreecommitdiffstats
path: root/g10/getkey.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1997-11-24 23:24:04 +0100
committerWerner Koch <wk@gnupg.org>1997-11-24 23:24:04 +0100
commit46900fbd437a134bd16e5030182fb3a219cd370e (patch)
treef13063a7c4896b189c7a3d09791d5464241174c7 /g10/getkey.c
parentIDEA removed, signing works (diff)
downloadgnupg2-46900fbd437a134bd16e5030182fb3a219cd370e.tar.xz
gnupg2-46900fbd437a134bd16e5030182fb3a219cd370e.zip
ElGamal funktioniert und ist default
Diffstat (limited to 'g10/getkey.c')
-rw-r--r--g10/getkey.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 8ca462210..4aea8e7ca 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -85,8 +85,9 @@ cache_pubkey_cert( PKT_pubkey_cert *pkc )
pkc_cache_entry_t ce;
u32 keyid[2];
- if( pkc->pubkey_algo == PUBKEY_ALGO_RSA ) {
- mpi_get_keyid( pkc->d.rsa.rsa_n, keyid );
+ if( pkc->pubkey_algo == PUBKEY_ALGO_ELGAMAL
+ || pkc->pubkey_algo == PUBKEY_ALGO_RSA ) {
+ keyid_from_pkc( pkc, keyid );
}
else
return; /* don't know how to get the keyid */
@@ -252,13 +253,11 @@ get_pubkey_by_name( PKT_pubkey_cert *pkc, const char *name )
* Get a secret key and store it into skey
*/
int
-get_seckey( RSA_secret_key *skey, u32 *keyid )
+get_seckey( PKT_seckey_cert *skc, u32 *keyid )
{
int rc=0;
- PKT_seckey_cert skc;
- memset( &skc, 0, sizeof skc );
- if( !(rc=scan_secret_keyring( &skc, keyid, NULL, "../keys/secring.g10" ) ) )
+ if( !(rc=scan_secret_keyring( skc, keyid, NULL, "../keys/secring.g10" ) ) )
goto found;
/* fixme: look at other places */
goto leave;
@@ -267,22 +266,10 @@ get_seckey( RSA_secret_key *skey, u32 *keyid )
/* get the secret key (this may prompt for a passprase to
* unlock the secret key
*/
- if( (rc = check_secret_key( &skc )) )
- goto leave;
- if( skc.pubkey_algo != PUBKEY_ALGO_RSA ) {
- rc = G10ERR_PUBKEY_ALGO; /* unsupport algorithm */
+ if( (rc = check_secret_key( skc )) )
goto leave;
- }
- /* copy the stuff to SKEY. skey is then the owner */
- skey->e = skc.d.rsa.rsa_e;
- skey->n = skc.d.rsa.rsa_n;
- skey->p = skc.d.rsa.rsa_p;
- skey->q = skc.d.rsa.rsa_q;
- skey->d = skc.d.rsa.rsa_d;
- skey->u = skc.d.rsa.rsa_u;
leave:
- memset( &skc, 0, sizeof skc );
return rc;
}
@@ -357,8 +344,9 @@ scan_keyring( PKT_pubkey_cert *pkc, u32 *keyid,
}
else if( keyid && pkt.pkttype == PKT_PUBKEY_CERT ) {
switch( pkt.pkt.pubkey_cert->pubkey_algo ) {
+ case PUBKEY_ALGO_ELGAMAL:
case PUBKEY_ALGO_RSA:
- mpi_get_keyid( pkt.pkt.pubkey_cert->d.rsa.rsa_n , akeyid );
+ keyid_from_pkc( pkt.pkt.pubkey_cert, akeyid );
if( akeyid[0] == keyid[0] && akeyid[1] == keyid[1] ) {
copy_pubkey_cert( pkc, pkt.pkt.pubkey_cert );
found++;
@@ -406,8 +394,9 @@ scan_keyring( PKT_pubkey_cert *pkc, u32 *keyid,
log_error("Ooops: no pubkey for userid '%.*s'\n",
pkt.pkt.user_id->len, pkt.pkt.user_id->name);
else {
- if( last_pk->pubkey_algo == PUBKEY_ALGO_RSA ) {
- mpi_get_keyid( last_pk->d.rsa.rsa_n , akeyid );
+ if( last_pk->pubkey_algo == PUBKEY_ALGO_ELGAMAL
+ || last_pk->pubkey_algo == PUBKEY_ALGO_RSA ) {
+ keyid_from_pkc( last_pk, akeyid );
cache_user_id( pkt.pkt.user_id, akeyid );
}
cache_pubkey_cert( last_pk );
@@ -462,8 +451,9 @@ scan_secret_keyring( PKT_seckey_cert *skc, u32 *keyid,
}
else if( keyid && pkt.pkttype == PKT_SECKEY_CERT ) {
switch( pkt.pkt.seckey_cert->pubkey_algo ) {
+ case PUBKEY_ALGO_ELGAMAL:
case PUBKEY_ALGO_RSA:
- mpi_get_keyid( pkt.pkt.seckey_cert->d.rsa.rsa_n , akeyid );
+ keyid_from_skc( pkt.pkt.seckey_cert, akeyid );
if( akeyid[0] == keyid[0] && akeyid[1] == keyid[1] ) {
copy_seckey_cert( skc, pkt.pkt.seckey_cert );
found++;
@@ -510,9 +500,10 @@ scan_secret_keyring( PKT_seckey_cert *skc, u32 *keyid,
log_error("Ooops: no seckey for userid '%.*s'\n",
pkt.pkt.user_id->len, pkt.pkt.user_id->name);
else {
- if( last_pk->pubkey_algo == PUBKEY_ALGO_RSA ) {
- mpi_get_keyid( last_pk->d.rsa.rsa_n , akeyid );
- cache_user_id( pkt.pkt.user_id, akeyid );
+ if( last_pk->pubkey_algo == PUBKEY_ALGO_ELGAMAL
+ || last_pk->pubkey_algo == PUBKEY_ALGO_RSA ) {
+ keyid_from_skc( last_pk, akeyid );
+ cache_user_id( pkt.pkt.user_id, akeyid );
}
}
}