]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add --smime-to-p7.
authorSimon Josefsson <simon@josefsson.org>
Sat, 14 Aug 2004 17:33:39 +0000 (17:33 +0000)
committerSimon Josefsson <simon@josefsson.org>
Sat, 14 Aug 2004 17:33:39 +0000 (17:33 +0000)
NEWS
src/Makefile.am
src/certtool.c
src/certtool.gaa

diff --git a/NEWS b/NEWS
index c30441ea483d6971559dc90c4f135e812a76ce76..8e9ed923785cef53e07986e4aa456bdab344f281 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 Version 1.1.15
 - Ported to Mac OS X / Darwin.
 - Ported to FreeBSD.
+- Certtool has simplistic --smime-to-p7 to translate RFC 2633 messages into
+  PKCS #7 format.
 
 Version 1.1.14 (09/08/2004)
 - Documentation converted to Texinfo format.
index 5794eeb2b5616dd7a2814ed52718f6c7e3ecc870..20e55b361b70d2d48679bba4e10d4d830e148ab7 100644 (file)
@@ -5,7 +5,8 @@ EXTRA_DIST = common.h crypt.gaa crypt-gaa.h README.srptool \
 
 SUBDIRS = srp x509 openpgp cfg
 
-INCLUDES = -I../lib -I../libtasn1/lib -I../includes $(LIBOPENCDK_CFLAGS) -Icfg/
+INCLUDES = -I../lib -I../libtasn1/lib -I../includes $(LIBOPENCDK_CFLAGS) \
+       -I../gl -Icfg/
 
 bin_PROGRAMS = gnutls-serv gnutls-cli srptool gnutls-cli-debug certtool
 gnutls_serv_SOURCES = serv-gaa.c serv.c common.c
index c8f81edad81391d410a0310b121260286919595a..5a22264619af8d577e147f93cbd3053bdfde2912 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2004 Simon Josefsson
  * Copyright (C) 2003 Nikos Mavroyanopoulos
  * Copyright (C) 2004 Free Software Foundation
  *
 #include <getpass.h>
 #include <certtool-cfg.h>
 
+/* Gnulib portability files. */
+#include <getline.h>
+#include <error.h>
+#include <exit.h>
+
 static void print_crl_info(gnutls_x509_crl crl, FILE * out, int all);
 int generate_prime(int bits);
 void pkcs7_info(void);
+void smime_to_pkcs7(void);
 void pkcs12_info(void);
 void generate_pkcs12(void);
 void verify_chain(void);
@@ -859,6 +866,9 @@ void gaa_parser(int argc, char **argv)
     case 14:
        verify_crl();
        break;
+    case 15:
+      smime_to_pkcs7();
+      break;
     default:
        fprintf(stderr, "GnuTLS' certtool utility.\n");
        fprintf(stderr,
@@ -2658,6 +2668,45 @@ void pkcs7_info(void)
 
 }
 
+void smime_to_pkcs7(void)
+{
+  size_t linesize = 0;
+  char *lineptr = NULL;
+  ssize_t len;
+
+  /* Find body.  FIXME: Handle non-b64 Content-Transfer-Encoding.
+     Reject non-S/MIME tagged Content-Type's? */
+  do
+    {
+      len = getline (&lineptr, &linesize, infile);
+      if (len == -1)
+       error (EXIT_FAILURE, 0, "Cannot find RFC 2822 header/body separator");
+    }
+  while (strcmp (lineptr, "\r\n") != 0);
+
+  do
+    {
+      len = getline (&lineptr, &linesize, infile);
+      if (len == -1)
+       error (EXIT_FAILURE, 0, "Message has RFC 2822 header but no body");
+    }
+  while (strcmp (lineptr, "\r\n") == 0);
+
+  printf ("-----BEGIN PKCS7-----\n");
+
+  do
+    {
+      if (strcmp (lineptr, "\r\n") != 0)
+       printf("%s", lineptr);
+      len = getline (&lineptr, &linesize, infile);
+    }
+  while (len != -1);
+
+  printf ("-----END PKCS7-----\n");
+
+  free (lineptr);
+}
+
 #else                          /* ENABLE_PKI */
 
 #include <stdio.h>
index 082f9626db60d55a030b60add6eff13532fe8d9a..309f6510cb835cb1414bf7c08de5bd0842c3218e 100644 (file)
@@ -59,6 +59,8 @@ option (p12-info) { $action = 9; } "Print information on a PKCS #12 structure."
 
 option (p7-info) { $action = 12; } "Print information on a PKCS #7 structure."
 
+option (smime-to-p7) { $action = 15; } "Convert S/MIME to PKCS #7 structure."
+
 option (k, key-info) { $action = 6; } "Print information on a private key."
 
 option (to-p12) { $action = 8; } "Generate a PKCS #12 structure."