aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2012-11-08 14:59:47 +0000
committerWerner Koch <[email protected]>2012-11-08 14:59:47 +0000
commit64e7c237db1eb5f463f4b810b09eda232da83676 (patch)
treefc44d8ea51f30f52321c4e24c7fceb77c4e0afef
parentSupport the not anymore patented IDEA cipher algorithm. (diff)
downloadgnupg-64e7c237db1eb5f463f4b810b09eda232da83676.tar.gz
gnupg-64e7c237db1eb5f463f4b810b09eda232da83676.zip
Create off-line card encryption key with the right size.
* g10/keygen.c (gen_card_key_with_backup): Get the size of the key from the card. -- Formerly the off-line encryption key was created with a fixed length of 1024 bit. With this change the key is created as expected. GnuPG-bug-id: 1230
-rw-r--r--g10/keygen.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index 7c473cbaf..30ec370c6 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -3711,10 +3711,25 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
PKT_public_key *pk;
size_t n;
int i;
+ unsigned int nbits;
sk_unprotected = NULL;
sk_protected = NULL;
- rc = generate_raw_key (algo, 1024, timestamp,
+
+ /* Get the size of the key directly from the card. */
+ {
+ struct agent_card_info_s info;
+
+ memset (&info, 0, sizeof info);
+ if (!agent_scd_getattr ("KEY-ATTR", &info)
+ && info.key_attr[1].algo)
+ nbits = info.key_attr[1].nbits;
+ else
+ nbits = 1024; /* All pre-v2.0 cards. */
+ agent_release_card_info (&info);
+ }
+
+ rc = generate_raw_key (algo, nbits, timestamp,
&sk_unprotected, &sk_protected);
if (rc)
return rc;