[svn] GnuPG - r4946 - trunk/scd

svn author wk cvs at cvs.gnupg.org
Tue Mar 10 17:10:36 CET 2009


Author: wk
Date: 2009-03-10 17:10:35 +0100 (Tue, 10 Mar 2009)
New Revision: 4946

Modified:
   trunk/scd/ChangeLog
   trunk/scd/app-openpgp.c
   trunk/scd/command.c
   trunk/scd/scdaemon.h
Log:
Add new attribute KEY-ATTR.


Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2009-03-06 17:31:27 UTC (rev 4945)
+++ trunk/scd/ChangeLog	2009-03-10 16:10:35 UTC (rev 4946)
@@ -1,3 +1,9 @@
+2009-03-10  Werner Koch  <wk at g10code.com>
+
+	* app-openpgp.c (send_key_attr): New.
+	(do_getattr): New attribute KEY_ATTR.
+	* command.c (send_status_direct): New.
+
 2009-03-06  Werner Koch  <wk at g10code.com>
 
 	* app-nks.c (do_learn_status): Factor code out to..

Modified: trunk/scd/app-openpgp.c
===================================================================
--- trunk/scd/app-openpgp.c	2009-03-06 17:31:27 UTC (rev 4945)
+++ trunk/scd/app-openpgp.c	2009-03-10 16:10:35 UTC (rev 4946)
@@ -151,7 +151,7 @@
                            key. Might be NULL if key is not
                            available.  */
     size_t keylen;      /* The length of the above S-expression.  This
-                           is usullay only required for cross checks
+                           is usually only required for cross checks
                            because the length of an S-expression is
                            implicitly available.  */
   } pk[3];
@@ -746,6 +746,24 @@
   xfree (buf);
 }
 
+
+static void
+send_key_attr (ctrl_t ctrl, app_t app, const char *keyword, int number)
+{                      
+  char buffer[200];
+
+  assert (number >=0 && number < DIM(app->app_local->keyattr));
+
+  /* We only support RSA thus the algo identifier is fixed to 1.  */
+  snprintf (buffer, sizeof buffer, "%d 1 %u %u %d",
+            number+1,
+            app->app_local->keyattr[number].n_bits,
+            app->app_local->keyattr[number].e_bits,
+            app->app_local->keyattr[number].format);
+  send_status_direct (ctrl, keyword, buffer);
+}
+
+
 /* Implement the GETATTR command.  This is similar to the LEARN
    command but returns just one value via the status interface. */
 static gpg_error_t 
@@ -763,6 +781,7 @@
     { "PUBKEY-URL",   0x5F50 },
     { "KEY-FPR",      0x00C5, 3 },
     { "KEY-TIME",     0x00CD, 4 },
+    { "KEY-ATTR",     0x0000, -5 },
     { "CA-FPR",       0x00C6, 3 },
     { "CHV-STATUS",   0x00C4, 1 }, 
     { "SIG-COUNTER",  0x0093, 2 },
@@ -811,14 +830,16 @@
     }
   if (table[idx].special == -2)
     {
-      char tmp[50];
+      char tmp[100];
 
-      sprintf (tmp, "gc=%d ki=%d fc=%d pd=%d mcl3=%u", 
-               app->app_local->extcap.get_challenge,
-               app->app_local->extcap.key_import,
-               app->app_local->extcap.change_force_chv,
-               app->app_local->extcap.private_dos,
-               app->app_local->extcap.max_certlen_3);
+      snprintf (tmp, sizeof tmp,
+                "gc=%d ki=%d fc=%d pd=%d mcl3=%u aac=%d", 
+                app->app_local->extcap.get_challenge,
+                app->app_local->extcap.key_import,
+                app->app_local->extcap.change_force_chv,
+                app->app_local->extcap.private_dos,
+                app->app_local->extcap.max_certlen_3,
+                app->app_local->extcap.algo_attr_change);
       send_status_info (ctrl, table[idx].name, tmp, strlen (tmp), NULL, 0);
       return 0;
     }
@@ -845,6 +866,12 @@
         }
       return gpg_error (GPG_ERR_INV_NAME); 
     }
+  if (table[idx].special == -5)
+    {
+      for (i=0; i < 3; i++)
+        send_key_attr (ctrl, app, table[idx].name, i);
+      return 0;
+    }
 
   relptr = get_one_do (app, table[idx].tag, &value, &valuelen, &rc);
   if (relptr)

Modified: trunk/scd/command.c
===================================================================
--- trunk/scd/command.c	2009-03-06 17:31:27 UTC (rev 4945)
+++ trunk/scd/command.c	2009-03-10 16:10:35 UTC (rev 4946)
@@ -2018,7 +2018,19 @@
 }
 
 
+/* Send a ready formatted status line via assuan.  */
+void
+send_status_direct (ctrl_t ctrl, const char *keyword, const char *args)
+{
+  assuan_context_t ctx = ctrl->server_local->assuan_ctx;
 
+  if (strchr (args, '\n'))
+    log_error ("error: LF detected in status line - not sending\n");
+  else
+    assuan_write_status (ctx, keyword, args);
+}
+
+
 /* Helper to send the clients a status change notification.  */
 static void
 send_client_notifications (void)

Modified: trunk/scd/scdaemon.h
===================================================================
--- trunk/scd/scdaemon.h	2009-03-06 17:31:27 UTC (rev 4945)
+++ trunk/scd/scdaemon.h	2009-03-10 16:10:35 UTC (rev 4946)
@@ -125,6 +125,7 @@
 int  scd_command_handler (ctrl_t, int);
 void send_status_info (ctrl_t ctrl, const char *keyword, ...)
      GNUPG_GCC_A_SENTINEL(1);
+void send_status_direct (ctrl_t ctrl, const char *keyword, const char *args);
 void scd_update_reader_status_file (void);
 
 




More information about the Gnupg-commits mailing list