634
keygen_upd_std_prefs( PKT_signature *sig, void *opaque )
637
keygen_upd_std_prefs (PKT_signature *sig, void *opaque)
636
if (!prefs_initialized)
637
keygen_set_std_prefs (NULL, 0);
640
build_sig_subpkt (sig, SIGSUBPKT_PREF_SYM, sym_prefs, nsym_prefs);
643
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_SYM);
644
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_SYM);
648
build_sig_subpkt (sig, SIGSUBPKT_PREF_HASH, hash_prefs, nhash_prefs);
651
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_HASH);
652
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_HASH);
656
build_sig_subpkt (sig, SIGSUBPKT_PREF_COMPR, zip_prefs, nzip_prefs);
659
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_COMPR);
660
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_COMPR);
663
/* Make sure that the MDC feature flag is set if needed */
664
add_feature_mdc (sig,mdc_available);
665
add_keyserver_modify (sig,ks_modify);
666
keygen_add_keyserver_url(sig,NULL);
641
if (!prefs_initialized)
642
keygen_set_std_prefs (NULL, 0);
645
build_sig_subpkt (sig, SIGSUBPKT_PREF_SYM, sym_prefs, nsym_prefs);
648
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_SYM);
649
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_SYM);
653
build_sig_subpkt (sig, SIGSUBPKT_PREF_HASH, hash_prefs, nhash_prefs);
656
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_HASH);
657
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_HASH);
661
build_sig_subpkt (sig, SIGSUBPKT_PREF_COMPR, zip_prefs, nzip_prefs);
664
delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_COMPR);
665
delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_COMPR);
668
/* Make sure that the MDC feature flag is set if needed. */
669
add_feature_mdc (sig,mdc_available);
670
add_keyserver_modify (sig,ks_modify);
671
keygen_add_keyserver_url(sig,NULL);
1789
1796
parse_expire_string( const char *string )
1792
u32 seconds,abs_date=0,curtime = make_timestamp();
1796
else if ( !strncmp (string, "seconds=", 8) )
1797
seconds = atoi (string+8);
1798
else if( (abs_date = scan_isodatestr(string)) && abs_date > curtime )
1799
seconds = abs_date - curtime;
1800
else if( (mult=check_valid_days(string)) )
1801
seconds = atoi(string) * 86400L * mult;
1801
u32 curtime = make_timestamp ();
1805
else if (!strncmp (string, "seconds=", 8))
1806
seconds = atoi (string+8);
1807
else if ((abs_date = scan_isodatestr(string)) && abs_date > curtime)
1808
seconds = abs_date - curtime;
1809
else if ((mult = check_valid_days (string)))
1810
seconds = atoi (string) * 86400L * mult;
1812
seconds = (u32)(-1);
1808
1817
/* Parsean Creation-Date string which is either "1986-04-26" or
1942
1957
char *aname, *acomment, *amail, *uid;
1961
/* TRANSLATORS: This is the new string telling the user what
1962
gpg is now going to do (i.e. ask for the parts of the user
1963
ID). Note that if you do not tyranslated this string, a
1964
different string will be used used, which might still have
1965
a correct transaltion. */
1968
"GnuPG needs to construct a user ID to identify your key.\n"
1970
const char *s2 = _(s1);
1972
if (!strcmp (s1, s2))
1974
/* There is no translation for the string thus we to use
1975
the old info text. gettext has no way to tell whether
1976
a translation is actually available, thus we need to
1977
to compare again. */
1978
/* TRANSLATORS: This string is in general not anymore used
1979
but you should keep your existing translation. In case
1980
the new string is not translated this old string will
1982
const char *s3 = N_("\n"
1946
1983
"You need a user ID to identify your key; "
1947
1984
"the software constructs the user ID\n"
1948
1985
"from the Real Name, Comment and Email Address in this form:\n"
1949
" \"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>\"\n\n") );
1986
" \"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>\"\n\n");
1987
const char *s4 = _(s3);
1988
if (strcmp (s3, s4))
1989
s2 = s3; /* A translation exists - use it. */
1991
tty_printf ("%s", s2) ;
1950
1993
uid = aname = acomment = amail = NULL;
2402
2446
algo=get_parameter_algo(para,pKEYTYPE);
2403
2447
if (openpgp_pk_test_algo2 (algo, PUBKEY_USAGE_SIG))
2405
log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
2449
log_error ("%s:%d: invalid algorithm\n", fname, r->lnr );
2411
log_error("%s: no Key-Type specified\n",fname);
2455
log_error ("%s: no Key-Type specified\n",fname);
2415
err=parse_parameter_usage (fname, para, pKEYUSAGE);
2459
err = parse_parameter_usage (fname, para, pKEYUSAGE);
2418
2462
/* Default to algo capabilities if key-usage is not provided */
2419
r=xmalloc_clear(sizeof(*r));
2421
r->u.usage=openpgp_pk_algo_usage(algo);
2463
r = xmalloc_clear(sizeof(*r));
2465
r->u.usage = openpgp_pk_algo_usage(algo);
2473
r = get_parameter (para, pKEYUSAGE);
2474
if (r && (r->u.usage & ~openpgp_pk_algo_usage (algo)))
2476
log_error ("%s:%d: specified Key-Usage not allowed for algo %d\n",
2477
fname, r->lnr, algo);
2428
2482
r = get_parameter( para, pSUBKEYTYPE );
2431
algo=get_parameter_algo( para, pSUBKEYTYPE);
2485
algo = get_parameter_algo (para, pSUBKEYTYPE);
2432
2486
if (openpgp_pk_test_algo (algo))
2434
log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
2488
log_error ("%s:%d: invalid algorithm\n", fname, r->lnr );
2438
err=parse_parameter_usage (fname, para, pSUBKEYUSAGE);
2492
err = parse_parameter_usage (fname, para, pSUBKEYUSAGE);
2441
2495
/* Default to algo capabilities if subkey-usage is not
2443
r=xmalloc_clear(sizeof(*r));
2444
r->key=pSUBKEYUSAGE;
2445
r->u.usage=openpgp_pk_algo_usage(algo);
2497
r = xmalloc_clear (sizeof(*r));
2498
r->key = pSUBKEYUSAGE;
2499
r->u.usage = openpgp_pk_algo_usage (algo);
2507
r = get_parameter (para, pSUBKEYUSAGE);
2508
if (r && (r->u.usage & ~openpgp_pk_algo_usage (algo)))
2510
log_error ("%s:%d: specified Subkey-Usage not allowed"
2511
" for algo %d\n", fname, r->lnr, algo);
2453
2518
if( get_parameter_value( para, pUSERID ) )
2454
2519
have_user_id=1;
2508
2573
if (parse_revocation_key (fname, para, pREVOKER))
2511
/* make DEK and S2K from the Passphrase */
2512
r = get_parameter( para, pPASSPHRASE );
2513
if( r && *r->u.value ) {
2514
/* We have a plain text passphrase - create a DEK from it.
2515
* It is a little bit ridiculous to keep it ih secure memory
2516
* but because we do this always, why not here */
2520
s2k = xmalloc_secure( sizeof *s2k );
2521
s2k->mode = opt.s2k_mode;
2522
s2k->hash_algo = S2K_DIGEST_ALGO;
2523
set_next_passphrase( r->u.value );
2524
dek = passphrase_to_dek( NULL, 0, opt.s2k_cipher_algo, s2k, 2,
2526
set_next_passphrase( NULL );
2528
memset( r->u.value, 0, strlen(r->u.value) );
2530
r = xmalloc_clear( sizeof *r );
2531
r->key = pPASSPHRASE_S2K;
2535
r = xmalloc_clear( sizeof *r );
2536
r->key = pPASSPHRASE_DEK;
2576
/* Make DEK and S2K from the Passphrase. */
2577
if (outctrl->ask_passphrase)
2579
/* %ask-passphrase is active - ignore pPASSPRASE and ask. This
2580
feature is required so that GUIs are able to do a key
2581
creation but have gpg-agent ask for the passphrase. */
2586
dek = do_ask_passphrase ( &s2k, &canceled );
2589
r = xmalloc_clear( sizeof *r );
2590
r->key = pPASSPHRASE_DEK;
2594
r = xmalloc_clear( sizeof *r );
2595
r->key = pPASSPHRASE_S2K;
2603
log_error ("%s:%d: key generation canceled\n", fname, r->lnr );
2609
r = get_parameter( para, pPASSPHRASE );
2610
if ( r && *r->u.value )
2612
/* We have a plain text passphrase - create a DEK from it.
2613
* It is a little bit ridiculous to keep it in secure memory
2614
* but because we do this always, why not here. */
2618
s2k = xmalloc_secure ( sizeof *s2k );
2619
s2k->mode = opt.s2k_mode;
2620
s2k->hash_algo = S2K_DIGEST_ALGO;
2621
set_next_passphrase ( r->u.value );
2622
dek = passphrase_to_dek (NULL, 0, opt.s2k_cipher_algo, s2k, 2,
2624
set_next_passphrase (NULL );
2626
memset (r->u.value, 0, strlen(r->u.value));
2628
r = xmalloc_clear (sizeof *r);
2629
r->key = pPASSPHRASE_S2K;
2633
r = xmalloc_clear (sizeof *r);
2634
r->key = pPASSPHRASE_DEK;
2542
2641
/* Make KEYCREATIONDATE from Creation-Date. */
2543
2642
r = get_parameter (para, pCREATIONDATE);
2677
2776
log_info("%s\n", value );
2678
2777
else if( !ascii_strcasecmp( keyword, "%dry-run" ) )
2679
2778
outctrl.dryrun = 1;
2779
else if( !ascii_strcasecmp( keyword, "%ask-passphrase" ) )
2780
outctrl.ask_passphrase = 1;
2781
else if( !ascii_strcasecmp( keyword, "%no-ask-passphrase" ) )
2782
outctrl.ask_passphrase = 0;
2680
2783
else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
2681
2784
outctrl.lnr = lnr;
2682
2785
if (proc_parameter_file( para, fname, &outctrl, 0 ))