aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/DETAILS19
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/keygen.c84
-rw-r--r--g10/status.c1
-rw-r--r--g10/status.h1
5 files changed, 84 insertions, 28 deletions
diff --git a/doc/DETAILS b/doc/DETAILS
index a5b840995..e8b9efd03 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -1,4 +1,4 @@
-
+ -*- text -*-
Format of colon listings
========================
First an example:
@@ -447,13 +447,19 @@ more arguments in future versions.
epoch or an ISO 8601 string which can be detected by the
presence of the letter 'T' inside.
- KEY_CREATED <type> <fingerprint>
+ KEY_CREATED <type> <fingerprint> [<handle>]
A key has been created
type: 'B' = primary and subkey
'P' = primary
'S' = subkey
The fingerprint is one of the primary key for type B and P and
- the one of the subkey for S.
+ the one of the subkey for S. Handle is an arbitrary
+ non-whitespace string used to match key parameters from batch
+ key creation run.
+
+ KEY_NOT_CREATED [<handle>]
+ The key from batch run has not been created due to errors.
+
SESSION_KEY <algo>:<hexdigits>
The session key used to decrypt the message. This message will
@@ -744,6 +750,13 @@ The format of this file is as follows:
revoker. The optional "sensitive" flag marks the designated
revoker as sensitive information. Only v4 keys may be
designated revokers.
+ Handle: <string>
+ This is an optional parameter only used with the status lines
+ KEY_CREATED and KEY_NOT_CREATED. STRING may be up to 100
+ characters and should not contauin spaces. It is useful for
+ batch key generation to associate a key parameter block with a
+ status line.
+
Here is an example:
$ cat >foo <<EOF
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 8e0580c5d..bb4371637 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -3,6 +3,13 @@
* keygen.c (read_parameter_file): Changed to use iobuf based file
reading to allow the special file name feature to work.
+ * keygen.c (read_parameter_file): New keyword "Handle". This is
+ bug 287.
+ (print_status_key_not_created): New.
+ (print_status_key_created): Add new arg HANDLE.
+ (do_generate_keypair): Print not created status.
+ * status.c, tatus.h (STATUS_KEY_NOT_CREATED): New.
+
2004-10-11 David Shaw <[email protected]>
* pkclist.c (do_edit_ownertrust): Use the same translated string
diff --git a/g10/keygen.c b/g10/keygen.c
index 5929e2909..fe3893499 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -64,7 +64,8 @@ enum para_name {
pPASSPHRASE_DEK,
pPASSPHRASE_S2K,
pSERIALNO,
- pBACKUPENCDIR
+ pBACKUPENCDIR,
+ pHANDLE
};
struct para_data_s {
@@ -162,6 +163,49 @@ copy_mpi (MPI a, unsigned char *buffer, size_t len, size_t *ncopied)
#endif /* ENABLE_CARD_SUPPORT */
+
+static void
+print_status_key_created (int letter, PKT_public_key *pk, const char *handle)
+{
+ unsigned char array[MAX_FINGERPRINT_LEN], *s;
+ char *buf, *p;
+ size_t i, n;
+
+ if (!handle)
+ handle = "";
+
+ buf = xmalloc (MAX_FINGERPRINT_LEN*2+31 + strlen (handle) + 1);
+
+ p = buf;
+ if (letter || pk)
+ {
+ *p++ = letter;
+ *p++ = ' ';
+ fingerprint_from_pk (pk, array, &n);
+ s = array;
+ for (i=0; i < n ; i++, s++, p += 2)
+ sprintf (p, "%02X", *s);
+ }
+ if (*handle)
+ {
+ *p++ = ' ';
+ for (i=0; handle[i] && i < 100; i++)
+ *p++ = isspace ((unsigned int)handle[i])? '_':handle[i];
+ }
+ *p = 0;
+ write_status_text ((letter || pk)?STATUS_KEY_CREATED:STATUS_KEY_NOT_CREATED,
+ buf);
+ xfree (buf);
+}
+
+static void
+print_status_key_not_created (const char *handle)
+{
+ print_status_key_created (0, NULL, handle);
+}
+
+
+
static void
write_uid( KBNODE root, const char *s )
{
@@ -2019,7 +2063,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
char *p;
int i;
- /* check that we have all required parameters */
+ /* Check that we have all required parameters. */
assert( get_parameter( para, pKEYTYPE ) );
i = get_parameter_algo( para, pKEYTYPE );
if( i < 1 || check_pubkey_algo2( i, PUBKEY_USAGE_SIG ) ) {
@@ -2130,7 +2174,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
/****************
* Kludge to allow non interactive key generation controlled
- * by a parameter file (which currently is only stdin)
+ * by a parameter file.
* Note, that string parameters are expected to be in UTF-8
*/
static void
@@ -2152,6 +2196,7 @@ read_parameter_file( const char *fname )
{ "Passphrase", pPASSPHRASE },
{ "Preferences", pPREFERENCES },
{ "Revoker", pREVOKER },
+ { "Handle", pHANDLE },
{ NULL, 0 }
};
IOBUF fp;
@@ -2209,7 +2254,9 @@ read_parameter_file( const char *fname )
outctrl.dryrun = 1;
else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
outctrl.lnr = lnr;
- proc_parameter_file( para, fname, &outctrl, 0 );
+ if (proc_parameter_file( para, fname, &outctrl, 0 ))
+ print_status_key_not_created
+ (get_parameter_value (para, pHANDLE));
release_parameter_list( para );
para = NULL;
}
@@ -2269,7 +2316,9 @@ read_parameter_file( const char *fname )
if( keywords[i].key == pKEYTYPE && para ) {
outctrl.lnr = lnr;
- proc_parameter_file( para, fname, &outctrl, 0 );
+ if (proc_parameter_file( para, fname, &outctrl, 0 ))
+ print_status_key_not_created
+ (get_parameter_value (para, pHANDLE));
release_parameter_list( para );
para = NULL;
}
@@ -2297,7 +2346,8 @@ read_parameter_file( const char *fname )
}
else if( para ) {
outctrl.lnr = lnr;
- proc_parameter_file( para, fname, &outctrl, 0 );
+ if (proc_parameter_file( para, fname, &outctrl, 0 ))
+ print_status_key_not_created (get_parameter_value (para, pHANDLE));
}
if( outctrl.use_files ) { /* close open streams */
@@ -2600,24 +2650,6 @@ generate_raw_key (int algo, unsigned int nbits, u32 created_at,
static void
-print_status_key_created (int letter, PKT_public_key *pk)
-{
- byte array[MAX_FINGERPRINT_LEN], *s;
- char buf[MAX_FINGERPRINT_LEN*2+30], *p;
- size_t i, n;
-
- p = buf;
- *p++ = letter;
- *p++ = ' ';
- fingerprint_from_pk (pk, array, &n);
- s = array;
- for (i=0; i < n ; i++, s++, p += 2)
- sprintf (p, "%02X", *s);
- *p = 0;
- write_status_text (STATUS_KEY_CREATED, buf);
-}
-
-static void
do_generate_keypair( struct para_data_s *para,
struct output_control_s *outctrl, int card )
{
@@ -2889,11 +2921,13 @@ do_generate_keypair( struct para_data_s *para,
log_error("key generation failed: %s\n", g10_errstr(rc) );
else
tty_printf(_("Key generation failed: %s\n"), g10_errstr(rc) );
+ print_status_key_not_created ( get_parameter_value (para, pHANDLE) );
}
else {
PKT_public_key *pk = find_kbnode (pub_root,
PKT_PUBLIC_KEY)->pkt->pkt.public_key;
- print_status_key_created (did_sub? 'B':'P', pk);
+ print_status_key_created (did_sub? 'B':'P', pk,
+ get_parameter_value (para, pHANDLE));
}
release_kbnode( pub_root );
release_kbnode( sec_root );
diff --git a/g10/status.c b/g10/status.c
index 1ed1ca038..d0bc08d87 100644
--- a/g10/status.c
+++ b/g10/status.c
@@ -142,6 +142,7 @@ get_status_string ( int no )
case STATUS_BEGIN_STREAM : s = "BEGIN_STREAM"; break;
case STATUS_END_STREAM : s = "END_STREAM"; break;
case STATUS_KEY_CREATED : s = "KEY_CREATED"; break;
+ case STATUS_KEY_NOT_CREATED: s = "KEY_NOT_CREATED"; break;
case STATUS_USERID_HINT : s = "USERID_HINT"; break;
case STATUS_UNEXPECTED : s = "UNEXPECTED"; break;
case STATUS_INV_RECP : s = "INV_RECP"; break;
diff --git a/g10/status.h b/g10/status.h
index ee282662a..c6c730bbe 100644
--- a/g10/status.h
+++ b/g10/status.h
@@ -103,6 +103,7 @@
#define STATUS_NEWSIG 72
#define STATUS_PLAINTEXT 73
#define STATUS_PLAINTEXT_LENGTH 74
+#define STATUS_KEY_NOT_CREATED 75
/*-- status.c --*/
void set_status_fd ( int fd );