GNUPG-1-9-BRANCH gnupg/agent (ChangeLog Makefile.am command-ssh.c minip12.c t-protect.c)

cvs user wk cvs at cvs.gnupg.org
Wed Jun 29 15:48:30 CEST 2005


    Date: Wednesday, June 29, 2005 @ 16:12:18
  Author: wk
    Path: /cvs/gnupg/gnupg/agent
     Tag: GNUPG-1-9-BRANCH

   Added: t-protect.c
Modified: ChangeLog Makefile.am command-ssh.c minip12.c

(data_sign): Removed empty statement.


---------------+
 ChangeLog     |    9 +++
 Makefile.am   |   15 +++++
 command-ssh.c |    2 
 minip12.c     |   12 +++-
 t-protect.c   |  142 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 175 insertions(+), 5 deletions(-)


Index: gnupg/agent/ChangeLog
diff -u gnupg/agent/ChangeLog:1.59.2.86 gnupg/agent/ChangeLog:1.59.2.87
--- gnupg/agent/ChangeLog:1.59.2.86	Thu Jun 16 10:12:03 2005
+++ gnupg/agent/ChangeLog	Wed Jun 29 16:12:18 2005
@@ -1,3 +1,12 @@
+2005-06-29  Werner Koch  <wk at g10code.com>
+
+	* command-ssh.c (data_sign): Removed empty statement.
+
+2005-06-21  Werner Koch  <wk at g10code.com>
+
+	* minip12.c (create_final): Cast size_t to ulong for printf. 
+	(build_key_bag, build_cert_bag, build_cert_sequence): Ditto.
+
 2005-06-16  Werner Koch  <wk at g10code.com>
 
 	* protect-tool.c (make_advanced): Makde RESULT a plain char.
Index: gnupg/agent/Makefile.am
diff -u gnupg/agent/Makefile.am:1.22.2.7 gnupg/agent/Makefile.am:1.22.2.8
--- gnupg/agent/Makefile.am:1.22.2.7	Wed Jun  1 17:46:01 2005
+++ gnupg/agent/Makefile.am	Wed Jun 29 16:12:18 2005
@@ -20,6 +20,7 @@
 
 bin_PROGRAMS = gpg-agent
 libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase
+noinst_PROGRAMS = $(TESTS)
 
 AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
 
@@ -70,3 +71,17 @@
 gpg_preset_passphrase_LDADD += -lwsock32
 endif
 
+#
+# Module tests
+#
+TESTS = t-protect
+
+t_common_ldadd = ../jnlib/libjnlib.a ../common/libcommon.a  \
+                 $(LIBGCRYPT_LIBS) -lgpg-error @LIBINTL@
+
+t_protect_SOURCES = t-protect.c protect.c 
+t_protect_LDADD = $(t_common_ldadd)
+
+
+
+
Index: gnupg/agent/command-ssh.c
diff -u gnupg/agent/command-ssh.c:1.1.4.23 gnupg/agent/command-ssh.c:1.1.4.24
--- gnupg/agent/command-ssh.c:1.1.4.23	Thu Jun 16 10:12:03 2005
+++ gnupg/agent/command-ssh.c	Wed Jun 29 16:12:18 2005
@@ -1988,7 +1988,7 @@
   gcry_sexp_t valuelist = NULL;
   gcry_sexp_t sublist = NULL;
   gcry_mpi_t sig_value = NULL;
-  unsigned char *sig_blob = NULL;;
+  unsigned char *sig_blob = NULL;
   size_t sig_blob_n = 0;
   char *identifier = NULL;
   const char *identifier_raw;
Index: gnupg/agent/minip12.c
diff -u gnupg/agent/minip12.c:1.5.2.9 gnupg/agent/minip12.c:1.5.2.10
--- gnupg/agent/minip12.c:1.5.2.9	Thu Jun 16 10:12:03 2005
+++ gnupg/agent/minip12.c	Wed Jun 29 16:12:18 2005
@@ -1085,7 +1085,8 @@
   /* Ready. */
   resultlen = p - result;
   if (needed != resultlen)
-    log_debug ("length mismatch: %u, %u\n", needed, resultlen);
+    log_debug ("length mismatch: %lu, %lu\n",
+               (unsigned long)needed, (unsigned long)resultlen);
 
   *r_length = resultlen;
   return result;
@@ -1339,7 +1340,8 @@
   keybaglen = p - keybag;
   
   if (needed != keybaglen)
-    log_debug ("length mismatch: %u, %u\n", needed, keybaglen);
+    log_debug ("length mismatch: %lu, %lu\n",
+               (unsigned long)needed, (unsigned long)keybaglen);
   
   *r_length = keybaglen;
   return keybag;
@@ -1437,7 +1439,8 @@
   certbaglen = p - certbag;
   
   if (needed != certbaglen)
-    log_debug ("length mismatch: %u, %u\n", needed, certbaglen);
+    log_debug ("length mismatch: %lu, %lu\n",
+               (unsigned long)needed, (unsigned long)certbaglen);
 
   *r_length = certbaglen;
   return certbag;
@@ -1527,7 +1530,8 @@
   certseqlen = p - certseq;
   
   if (needed != certseqlen)
-    log_debug ("length mismatch: %u, %u\n", needed, certseqlen);
+    log_debug ("length mismatch: %lu, %lu\n",
+               (unsigned long)needed, (unsigned long)certseqlen);
   
   /* Append some pad characters; we already allocated extra space. */
   n = 8 - certseqlen % 8;
Index: gnupg/agent/t-protect.c
diff -u /dev/null gnupg/agent/t-protect.c:1.1.2.1
--- /dev/null	Wed Jun 29 16:12:18 2005
+++ gnupg/agent/t-protect.c	Wed Jun 29 16:12:18 2005
@@ -0,0 +1,142 @@
+/* t-protect.c - Module tests for protect.c
+ * Copyright (C) 2005 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "agent.h"
+
+
+#define pass()  do { ; } while(0)
+#define fail()  do { fprintf (stderr, "%s:%d: test failed\n",\
+                              __FILE__,__LINE__);            \
+                     exit (1);                               \
+                   } while(0)
+
+
+static void
+test_agent_protect (void)
+{
+  /* Protect the key encoded in canonical format in PLAINKEY.  We assume
+     a valid S-Exp here. */
+/*   int  agent_protect (const unsigned char *plainkey, const char *passphrase, */
+/*                       unsigned char **result, size_t *resultlen); */
+}
+
+
+static void
+test_agent_unprotect (void)
+{
+  /* Unprotect the key encoded in canonical format.  We assume a valid
+     S-Exp here. */
+/*   int  */
+/*     agent_unprotect (const unsigned char *protectedkey, const char *passphrase, */
+/*                      unsigned char **result, size_t *resultlen) */
+}
+
+
+static void
+test_agent_private_key_type (void)
+{
+/* Check the type of the private key, this is one of the constants:
+   PRIVATE_KEY_UNKNOWN if we can't figure out the type (this is the
+   value 0), PRIVATE_KEY_CLEAR for an unprotected private key.
+   PRIVATE_KEY_PROTECTED for an protected private key or
+   PRIVATE_KEY_SHADOWED for a sub key where the secret parts are stored
+   elsewhere. */
+/* int */
+/* agent_private_key_type (const unsigned char *privatekey) */
+}
+
+
+static void
+test_make_shadow_info (void)
+{
+  static struct 
+  {
+    const char *snstr; 
+    const char *idstr;
+    const char *expected;
+  } data[] = {
+    { "", "", NULL },
+    
+  };
+  int i;
+  unsigned char *result;
+
+  for (i=0; i < DIM(data); i++)
+    {
+      result =  make_shadow_info (data[i].snstr, data[i].idstr);
+      if (!result && !data[i].expected)
+        pass ();
+      else if (!result && data[i].expected)
+        fail ();
+      else if (!data[i].expected)
+        fail ();
+      /* fixme: Need to compare the result but also need to check
+         proper S-expression syntax. */
+    }
+}
+
+
+
+static void
+test_agent_shadow_key (void)
+{
+/* Create a shadow key from a public key.  We use the shadow protocol
+  "ti-v1" and insert the S-expressionn SHADOW_INFO.  The resulting
+  S-expression is returned in an allocated buffer RESULT will point
+  to. The input parameters are expected to be valid canonicalized
+  S-expressions */
+/* int  */
+/* agent_shadow_key (const unsigned char *pubkey, */
+/*                   const unsigned char *shadow_info, */
+/*                   unsigned char **result) */
+}
+
+
+static void
+test_agent_get_shadow_info (void)
+{
+/* Parse a canonical encoded shadowed key and return a pointer to the
+   inner list with the shadow_info */
+/* int  */
+/* agent_get_shadow_info (const unsigned char *shadowkey, */
+/*                        unsigned char const **shadow_info) */
+}
+
+
+
+
+int
+main (int argc, char **argv)
+{
+  test_agent_protect ();
+  test_agent_unprotect ();
+  test_agent_private_key_type ();
+  test_make_shadow_info ();
+  test_agent_shadow_key ();
+  test_agent_get_shadow_info ();
+
+  return 0;
+}




More information about the Gnupg-commits mailing list