summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2004-08-14 17:33:39 +0000
committerSimon Josefsson <simon@josefsson.org>2004-08-14 17:33:39 +0000
commit5cc8b74f42510a7cee90459291e4e915eb1ca3f7 (patch)
tree3b55d46ac3b9b3fc8471dd342a5b40ab30fb9409
parent6d149884dacf5c3694f8eb1d12d706323e6b1404 (diff)
downloadgnutls-5cc8b74f42510a7cee90459291e4e915eb1ca3f7.tar.gz
Add --smime-to-p7.
-rw-r--r--NEWS2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/certtool.c49
-rw-r--r--src/certtool.gaa2
4 files changed, 55 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index c30441ea48..8e9ed92378 100644
--- 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.
diff --git a/src/Makefile.am b/src/Makefile.am
index 5794eeb2b5..20e55b361b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/certtool.c b/src/certtool.c
index c8f81edad8..5a22264619 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2004 Simon Josefsson
* Copyright (C) 2003 Nikos Mavroyanopoulos
* Copyright (C) 2004 Free Software Foundation
*
@@ -35,9 +36,15 @@
#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>
diff --git a/src/certtool.gaa b/src/certtool.gaa
index 082f9626db..309f6510cb 100644
--- a/src/certtool.gaa
+++ b/src/certtool.gaa
@@ -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."