[git] GnuPG - branch, master, updated. gnupg-2.1.15-263-g987bbb2

by NIIBE Yutaka cvs at cvs.gnupg.org
Sat Oct 22 01:51:01 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  987bbb2276aeb6bee2793e8406e223717b605009 (commit)
      from  f7e50634be71ce3028726f23edf14454109a04a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 987bbb2276aeb6bee2793e8406e223717b605009
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Sat Oct 22 08:45:35 2016 +0900

    g10: More card key generation change.
    
    * g10/keygen.c (gen_card_key): Add back ALGO as the second argument.
    Don't get ALGO by KEY-ATTR by this function.  It's caller to provide
    ALGO.  Don't do that by both of caller and callee.
    (generate_keypair): Only put paramerters needed.  Use parameters
    for ALGO to call gen_card_key.
    (generate_card_subkeypair): Get ALGO and call gen_card_key with it.
    
    --
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/g10/keygen.c b/g10/keygen.c
index a59435d..61e070c 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -152,10 +152,11 @@ static gpg_error_t parse_algo_usage_expire (ctrl_t ctrl, int for_subkey,
                                      u32 *r_expire,
                                      unsigned int *r_nbits, char **r_curve);
 static void do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
-				 struct output_control_s *outctrl, int card );
+                                 struct output_control_s *outctrl, int card );
 static int write_keyblock (iobuf_t out, kbnode_t node);
-static gpg_error_t gen_card_key (int keyno, int is_primary, kbnode_t pub_root,
-                                 u32 *timestamp, u32 expireval);
+static gpg_error_t gen_card_key (int keyno, int algo, int is_primary,
+                                 kbnode_t pub_root, u32 *timestamp,
+                                 u32 expireval);
 
 
 static void
@@ -255,7 +256,7 @@ keygen_add_key_expire (PKT_signature *sig, void *opaque)
 
       buf[0] = (u >> 24) & 0xff;
       buf[1] = (u >> 16) & 0xff;
-      buf[2] = (u >>	8) & 0xff;
+      buf[2] = (u >>  8) & 0xff;
       buf[3] = u & 0xff;
       build_sig_subpkt (sig, SIGSUBPKT_KEY_EXPIRE, buf, 4);
     }
@@ -3783,24 +3784,6 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname,
       strcpy (r->u.value, "sign");
       r->next = para;
       para = r;
-      if (info.key_attr[0].algo == PUBKEY_ALGO_RSA)
-        {
-          r = xcalloc (1, sizeof *r + 20 );
-          r->key = pKEYLENGTH;
-          sprintf( r->u.value, "%u", info.key_attr[0].nbits);
-          r->next = para;
-          para = r;
-        }
-      else if (info.key_attr[0].algo == PUBKEY_ALGO_ECDSA
-               || info.key_attr[0].algo == PUBKEY_ALGO_EDDSA
-               || info.key_attr[0].algo == PUBKEY_ALGO_ECDH)
-        {
-          r = xcalloc (1, sizeof *r + strlen (info.key_attr[0].curve));
-          r->key = pKEYCURVE;
-          strcpy (r->u.value, info.key_attr[0].curve);
-          r->next = para;
-          para = r;
-        }
 
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pSUBKEYTYPE;
@@ -4282,7 +4265,8 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
                      get_parameter_passphrase (para),
                      &cache_nonce, NULL);
   else
-    err = gen_card_key (1, 1, pub_root, &timestamp,
+    err = gen_card_key (1, get_parameter_algo( para, pKEYTYPE, NULL ),
+                        1, pub_root, &timestamp,
                         get_parameter_u32 (para, pKEYEXPIRE));
 
   /* Get the pointer to the generated public key packet.  */
@@ -4320,7 +4304,8 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
 
   if (!err && card && get_parameter (para, pAUTHKEYTYPE))
     {
-      err = gen_card_key (3, 0, pub_root, &timestamp,
+      err = gen_card_key (3, get_parameter_algo( para, pAUTHKEYTYPE, NULL ),
+                          0, pub_root, &timestamp,
                           get_parameter_u32 (para, pKEYEXPIRE));
       if (!err)
         err = write_keybinding (pub_root, pri_psk, NULL,
@@ -4359,7 +4344,8 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
         }
       else
         {
-          err = gen_card_key (2, 0, pub_root, &timestamp,
+          err = gen_card_key (2, 0, get_parameter_algo (para, pSUBKEYTYPE, NULL),
+                              pub_root, &timestamp,
                               get_parameter_u32 (para, pKEYEXPIRE));
         }
 
@@ -4796,9 +4782,20 @@ generate_card_subkeypair (kbnode_t pub_keyblock,
   u32 cur_time;
   struct para_data_s *para = NULL;
   PKT_public_key *sub_pk = NULL;
+  int algo;
+  struct agent_card_info_s info;
 
   log_assert (keyno >= 1 && keyno <= 3);
 
+  memset (&info, 0, sizeof (info));
+  err = agent_scd_getattr ("KEY-ATTR", &info);
+  if (err)
+    {
+      log_error (_("error getting current key info: %s\n"), gpg_strerror (err));
+      return err;
+    }
+  algo = info.key_attr[keyno-1].algo;
+
   para = xtrycalloc (1, sizeof *para + strlen (serialno) );
   if (!para)
     {
@@ -4857,7 +4854,7 @@ generate_card_subkeypair (kbnode_t pub_keyblock,
 
   /* Note, that depending on the backend, the card key generation may
      update CUR_TIME.  */
-  err = gen_card_key (keyno, 0, pub_keyblock, &cur_time, expire);
+  err = gen_card_key (keyno, algo, 0, pub_keyblock, &cur_time, expire);
   /* Get the pointer to the generated public subkey packet.  */
   if (!err)
     {
@@ -4905,29 +4902,17 @@ write_keyblock( IOBUF out, KBNODE node )
 
 /* Note that timestamp is an in/out arg. */
 static gpg_error_t
-gen_card_key (int keyno, int is_primary, kbnode_t pub_root,
+gen_card_key (int keyno, int algo, int is_primary, kbnode_t pub_root,
               u32 *timestamp, u32 expireval)
 {
 #ifdef ENABLE_CARD_SUPPORT
   gpg_error_t err;
-  struct agent_card_info_s info;
-  int algo;
   PACKET *pkt;
   PKT_public_key *pk;
   char keyid[10];
   unsigned char *public;
   gcry_sexp_t s_key;
 
-  memset (&info, 0, sizeof (info));
-  err = agent_scd_getattr ("KEY-ATTR", &info);
-  if (err)
-    {
-      log_error (_("error getting current key info: %s\n"), gpg_strerror (err));
-      return err;
-    }
-
-  algo = info.key_attr[keyno-1].algo;
-
   snprintf (keyid, DIM(keyid), "OPENPGP.%d", keyno);
 
   pk = xtrycalloc (1, sizeof *pk );

-----------------------------------------------------------------------

Summary of changes:
 g10/keygen.c | 63 +++++++++++++++++++++++-------------------------------------
 1 file changed, 24 insertions(+), 39 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list