aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-openpgp.c
diff options
context:
space:
mode:
Diffstat (limited to 'scd/app-openpgp.c')
-rw-r--r--scd/app-openpgp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 5ca526c5f..81b4923d4 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -2848,7 +2848,7 @@ change_keyattr (app_t app, int keyno, const unsigned char *buf, size_t buflen,
/* Helper to process an setattr command for name KEY-ATTR.
In (VALUE,VALUELEN), it expects following string:
- RSA: "--force <keyno> <algo> <nbits>"
+ RSA: "--force <keyno> <algo> rsa<nbits>"
ECC: "--force <keyno> <algo> <curvename>"
*/
static gpg_error_t
@@ -2887,7 +2887,7 @@ change_keyattr_from_string (app_t app,
unsigned int nbits;
errno = 0;
- nbits = strtoul (string+n, NULL, 10);
+ nbits = strtoul (string+n+3, NULL, 10);
if (errno)
err = gpg_error (GPG_ERR_INV_DATA);
else if (nbits < 1024)
@@ -2985,6 +2985,13 @@ rsa_writekey (app_t app, gpg_error_t (*pincb)(void*, const char *, char **),
unsigned char fprbuf[20];
u32 created_at = 0;
+ if (app->app_local->keyattr[keyno].key_type != KEY_TYPE_RSA)
+ {
+ log_error (_("unsupported algorithm: %s"), "RSA");
+ err = gpg_error (GPG_ERR_INV_VALUE);
+ goto leave;
+ }
+
last_depth1 = depth;
while (!(err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen))
&& depth && depth >= last_depth1)
@@ -3519,10 +3526,7 @@ do_writekey (app_t app, ctrl_t ctrl,
goto leave;
if (tok && toklen == 3 && memcmp ("rsa", tok, toklen) == 0)
err = rsa_writekey (app, pincb, pincb_arg, keyno, buf, buflen, depth);
- else if (tok
- && ((toklen == 3 && memcmp ("ecc", tok, toklen) == 0)
- || (toklen == 4 && memcmp ("ecdh", tok, toklen) == 0)
- || (toklen == 5 && memcmp ("ecdsa", tok, toklen) == 0)))
+ else if (tok && toklen == 3 && memcmp ("ecc", tok, toklen) == 0)
err = ecc_writekey (app, pincb, pincb_arg, keyno, buf, buflen, depth);
else
{