91 |
"Key-Length: %d\n" |
"Key-Length: %d\n" |
92 |
"Key-Usage: %s\n" |
"Key-Usage: %s\n" |
93 |
"Name-Real: %s\n" |
"Name-Real: %s\n" |
|
"Name-Email: %s\n" |
|
94 |
"Name-Comment: %s\n" |
"Name-Comment: %s\n" |
95 |
|
"Name-Email: %s\n" |
96 |
"Expire-Date: %s\n" |
"Expire-Date: %s\n" |
97 |
"Passphrase: %s\n" |
"Passphrase: %s\n" |
98 |
"</GnupgKeyParms>\n"; |
"</GnupgKeyParms>\n"; |
126 |
size += strlen (key_params); |
size += strlen (key_params); |
127 |
if (expdate) |
if (expdate) |
128 |
size += strlen (expdate) + 1; |
size += strlen (expdate) + 1; |
129 |
p = (char *)malloc (size+1); |
p = new char[size+1]; |
130 |
if (!p) |
if (!p) |
131 |
BUG (0); |
BUG (0); |
132 |
/* XXX: simply the whole switch-case code. */ |
/* XXX: simply the whole switch-case code. */ |
172 |
break; |
break; |
173 |
|
|
174 |
default: |
default: |
175 |
if (p) |
free_if_alloc (p); |
|
free (p); |
|
|
p = NULL; |
|
176 |
break; |
break; |
177 |
} |
} |
178 |
} |
} |
218 |
break; |
break; |
219 |
|
|
220 |
default: |
default: |
221 |
if (p) |
free_if_alloc (p); |
|
free (p); |
|
|
p = NULL; |
|
222 |
break; |
break; |
223 |
} |
} |
224 |
} |
} |
245 |
err = gpgme_op_genkey (ctx, params, NULL, NULL); |
err = gpgme_op_genkey (ctx, params, NULL, NULL); |
246 |
if (!err) { |
if (!err) { |
247 |
res = gpgme_op_genkey_result (ctx); |
res = gpgme_op_genkey_result (ctx); |
248 |
*fpr = res->fpr? strdup (res->fpr) : NULL; |
*fpr = res->fpr? m_strdup (res->fpr) : NULL; |
249 |
} |
} |
250 |
gpgme_release (ctx); |
gpgme_release (ctx); |
251 |
return err; |
return err; |
462 |
BUG (0); |
BUG (0); |
463 |
p = gpg_genkey_params (keytype, bits, utf8_name, NULL, |
p = gpg_genkey_params (keytype, bits, utf8_name, NULL, |
464 |
email, expire, pwd); |
email, expire, pwd); |
465 |
safe_free (utf8_name); |
free_if_alloc (utf8_name); |
466 |
} |
} |
467 |
else { |
else { |
468 |
char *utf8_name, *utf8_comment; |
char *utf8_name, *utf8_comment; |
472 |
BUG (0); |
BUG (0); |
473 |
p = gpg_genkey_params (keytype, bits, utf8_name, utf8_comment, |
p = gpg_genkey_params (keytype, bits, utf8_name, utf8_comment, |
474 |
email, expire, pwd); |
email, expire, pwd); |
475 |
safe_free (utf8_name); |
free_if_alloc (utf8_name); |
476 |
safe_free (utf8_comment); |
free_if_alloc (utf8_comment); |
477 |
} |
} |
478 |
keygen_cb_dlg_create (); |
keygen_cb_dlg_create (); |
479 |
err = gpg_genkey (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
480 |
sfree_if_alloc (pwd); |
sfree_if_alloc (pwd); |
481 |
if (p) { |
if (p) { |
482 |
wipememory (p, strlen (p)); /* burn the passphrase! */ |
wipememory (p, strlen (p)); /* burn the passphrase! */ |
483 |
free (p); |
free_if_alloc (p); |
484 |
} |
} |
485 |
keygen_cb_dlg_destroy (); |
keygen_cb_dlg_destroy (); |
486 |
keygen_cb (NULL, NULL, 0, 0, 0); /* flush */ |
keygen_cb (NULL, NULL, 0, 0, 0); /* flush */ |
487 |
if (err) { |
if (err) { |
488 |
safe_free (fpr); |
free_if_alloc (fpr); |
489 |
msg_box (dlg, gpgme_strerror (err), _("Key Generation"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Generation"), MB_ERR); |
490 |
return FALSE; |
return FALSE; |
491 |
} |
} |
493 |
|
|
494 |
keycache_update (0, fpr); |
keycache_update (0, fpr); |
495 |
keycache_update (1, fpr); |
keycache_update (1, fpr); |
496 |
safe_free (fpr); |
free_if_alloc (fpr); |
497 |
|
|
498 |
clear_dlg_fields (dlg); |
clear_dlg_fields (dlg); |
499 |
backup_keyrings (dlg); |
backup_keyrings (dlg); |
589 |
pubkey_algo = GPG_KEYGEN_DSA_RSA; |
pubkey_algo = GPG_KEYGEN_DSA_RSA; |
590 |
p = gpg_genkey_params (pubkey_algo, DFAULT_KEYSIZE, utf8_name, |
p = gpg_genkey_params (pubkey_algo, DFAULT_KEYSIZE, utf8_name, |
591 |
NULL, email, NULL, pass); |
NULL, email, NULL, pass); |
592 |
free( utf8_name ); |
free_if_alloc (utf8_name); |
593 |
keygen_cb_dlg_create(); |
keygen_cb_dlg_create(); |
594 |
err = gpg_genkey (p, keygen_cb, &fpr); |
err = gpg_genkey (p, keygen_cb, &fpr); |
595 |
keygen_cb_dlg_destroy(); |
keygen_cb_dlg_destroy(); |
596 |
keygen_cb( NULL, NULL, 0, 0, 0 ); |
keygen_cb (NULL, NULL, 0, 0, 0); |
597 |
if( p ) { |
if (p) { |
598 |
memset( p, 0, strlen( p ) ); |
wipememory (p, strlen (p)); |
599 |
free( p ); |
free_if_alloc (p); |
600 |
} |
} |
601 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
602 |
if( err ) { |
if (err) { |
603 |
msg_box( dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR ); |
msg_box (dlg, gpgme_strerror( err ), _("Key Generation Wizard"), MB_ERR); |
604 |
if (fpr) |
free_if_alloc (fpr); |
|
free (fpr); |
|
605 |
return FALSE; |
return FALSE; |
606 |
} |
} |
607 |
status_box( dlg, _("Key Generation completed"), _("GnuPG Status") ); |
status_box( dlg, _("Key Generation completed"), _("GnuPG Status") ); |
608 |
|
|
609 |
keycache_update (0, fpr); |
keycache_update (0, fpr); |
610 |
keycache_update (1, fpr); |
keycache_update (1, fpr); |
611 |
safe_free (fpr); |
free_if_alloc (fpr); |
612 |
|
|
613 |
backup_keyrings (dlg); |
backup_keyrings (dlg); |
614 |
if (ctx) |
if (ctx) |