]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
* Added CRL verification functionality to certtool.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 26 Dec 2003 17:48:57 +0000 (17:48 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 26 Dec 2003 17:48:57 +0000 (17:48 +0000)
* Added the FSF copyright notices.
* Moved all the compatibility interface to the openssl
  compatibility library.

107 files changed:
AUTHORS
NEWS
configure.in
doc/tex/cover.tex.in
includes/Makefile.am
includes/gnutls/Makefile.am
includes/gnutls/openssl.h
lib/auth_anon.c
lib/auth_cert.c
lib/auth_dh_common.c
lib/auth_dhe.c
lib/auth_rsa.c
lib/auth_rsa_export.c
lib/debug.c
lib/ext_cert_type.c
lib/ext_max_record.c
lib/ext_server_name.c
lib/gnutls_alert.c
lib/gnutls_algorithms.c
lib/gnutls_anon_cred.c
lib/gnutls_auth.c
lib/gnutls_buffers.c
lib/gnutls_cert.c
lib/gnutls_cipher.c
lib/gnutls_cipher_int.c
lib/gnutls_compress.c
lib/gnutls_compress_int.c
lib/gnutls_constate.c
lib/gnutls_datum.c
lib/gnutls_db.c
lib/gnutls_dh.c
lib/gnutls_dh_primes.c
lib/gnutls_errors.c
lib/gnutls_extensions.c
lib/gnutls_global.c
lib/gnutls_handshake.c
lib/gnutls_hash_int.c
lib/gnutls_kx.c
lib/gnutls_mem.c
lib/gnutls_mpi.c
lib/gnutls_num.c
lib/gnutls_pk.c
lib/gnutls_priority.c
lib/gnutls_random.c
lib/gnutls_record.c
lib/gnutls_rsa_export.c
lib/gnutls_session.c
lib/gnutls_session_pack.c
lib/gnutls_sig.c
lib/gnutls_state.c
lib/gnutls_str.c
lib/gnutls_ui.c
lib/gnutls_v2_compat.c
lib/gnutls_x509.c
lib/strnstr.c
lib/x509/common.c
lib/x509/compat.c
lib/x509/compat.h
lib/x509/crl.c
lib/x509/crq.c
lib/x509/dn.c
lib/x509/dsa.c
lib/x509/extensions.c
lib/x509/mpi.c
lib/x509/pkcs12.c
lib/x509/pkcs12_bag.c
lib/x509/pkcs12_encr.c
lib/x509/pkcs5.c
lib/x509/pkcs7.c
lib/x509/privkey.c
lib/x509/privkey_pkcs8.c
lib/x509/rc2.c
lib/x509/rfc2818_hostname.c
lib/x509/sign.c
lib/x509/verify.c
lib/x509/x509.c
lib/x509/x509_write.c
lib/x509/xml.c
lib/x509_b64.c
libextra/Makefile.am
libextra/auth_srp.c
libextra/auth_srp_passwd.c
libextra/auth_srp_rsa.c
libextra/auth_srp_sb64.c
libextra/ext_srp.c
libextra/gnutls_extra.c
libextra/gnutls_openpgp.c
libextra/gnutls_openssl.c
libextra/gnutls_srp.c
libextra/openpgp/compat.c
libextra/openpgp/extras.c
libextra/openpgp/openpgp.c
libextra/openpgp/privkey.c
libextra/openpgp/verify.c
libextra/openpgp/xml.c
libextra/openssl_compat.c [new file with mode: 0644]
libextra/openssl_compat.h [moved from includes/gnutls/compat8.h with 50% similarity]
src/certtool-gaa.c
src/certtool-gaa.h
src/certtool.c
src/certtool.gaa
src/cli.c
src/crypt.c
src/prime.c
src/serv.c
src/tests.c
src/tls_test.c

diff --git a/AUTHORS b/AUTHORS
index 2061454e258a90d3482e8ba62e92d6378c3469c6..8d8d9206ec5421e8d36cc8feaf1ac3327fe0b09e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,7 @@
+/*
+ * The copyright holder for Gnutls is Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
+ */
 
 N: Nikos Mavroyanopoulos 
 A: nmav
diff --git a/NEWS b/NEWS
index 5e9ba151b55475e2ea68804bf9f39aad121a631b..5141f2d907008e456927165976f9b54b1448506a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Version 1.1.2
+- Added CRL verification functionality to certtool.
+
 Version 1.1.1 (26/12/2003)
 - Added PKCS #7 support to certtool utility.
 - Added support for reading and generating CRL distribution
index dd5c286b9de8a93740fcd3141852aad432a7e43d..32dbd3fcec943482c10b2c8c688e9424db00c9e6 100644 (file)
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name])
 dnl Gnutls Version
 GNUTLS_MAJOR_VERSION=1
 GNUTLS_MINOR_VERSION=1
-GNUTLS_MICRO_VERSION=1
+GNUTLS_MICRO_VERSION=2
 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION
 
 AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION", [version of gnutls])
index 48207ae20b46070970827106718102b32ffd9a06..f82e494d02e5a44b2990c69b5300ddad9dedf9d7 100644 (file)
@@ -54,6 +54,7 @@ Applies to GnuTLS @VERSION@
 \begin{center}
 \par
 Copyright \copyright\ 2001,2002,2003 Nikos Mavroyanopoulos\\
+Copyright \copyright\ 2004 Free Software Foundation\\
 \setlength{\parskip}{4mm}
 \par
 Permission is granted to copy, distribute and/or modify this document
index 7b9ff9133db94ec2b98f5c1bccf93abdc641fa19..cb35de547158892528bf765e8e34b9673f4af21a 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 nobase_include_HEADERS = gnutls/extra.h gnutls/gnutls.h $(OPENSSL_H) \
-       gnutls/x509.h gnutls/compat8.h gnutls/pkcs12.h \
+       gnutls/x509.h gnutls/pkcs12.h \
        gnutls/openpgp.h
 
 if ENABLE_OPENSSL
index e65e63205ae7e513135fa05def3bb9c9cba8258d..484ff83428a5c295846d253b6d77804e9bc013e7 100644 (file)
@@ -1 +1 @@
-EXTRA_DIST = extra.h openssl.h gnutls.h x509.h compat8.h pkcs12.h openpgp.h
+EXTRA_DIST = extra.h openssl.h gnutls.h x509.h pkcs12.h openpgp.h
index eb4667af9c11a48a7d289b3a172a3880b7f90c45..07d2e510c38be3c21fc8d6b7c6d63f54dc6bbbe1 100644 (file)
@@ -36,6 +36,27 @@ extern "C" {
 #include <gnutls/gnutls.h>
 #include <gcrypt.h>
 
+/* Extra definitions that do not longer exist in gnutls.
+ */
+#define GNUTLS_X509_CN_SIZE 256
+#define GNUTLS_X509_C_SIZE 3
+#define GNUTLS_X509_O_SIZE 256
+#define GNUTLS_X509_OU_SIZE 256
+#define GNUTLS_X509_L_SIZE 256
+#define GNUTLS_X509_S_SIZE 256
+#define GNUTLS_X509_EMAIL_SIZE 256
+
+typedef struct {
+       char common_name[GNUTLS_X509_CN_SIZE];
+       char country[GNUTLS_X509_C_SIZE];
+       char organization[GNUTLS_X509_O_SIZE];
+       char organizational_unit_name[GNUTLS_X509_OU_SIZE];
+       char locality_name[GNUTLS_X509_L_SIZE];
+       char state_or_province_name[GNUTLS_X509_S_SIZE];
+       char email[GNUTLS_X509_EMAIL_SIZE];
+} gnutls_x509_dn;
+
+
 #define OPENSSL_VERSION_NUMBER (0x0090604F)
 #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
 #define OPENSSL_VERSION_TEXT ("GNUTLS " LIBGNUTLS_VERSION " ")
index 465dbdfb63a9d5008f273c2cee4bb746e7860948..a49df2092c5d6f0be37b5503ea531d88c7e89eb9 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *      Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index e76ece4bfcd1640e6d0b8f615692d7679e91d686..d069ac6685638b096fbcf76c0b06b53e605a0f68 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 287c5c4191284f890279cabf033f187406dbc80c..7ae1ea1703e8f255bdfbb4cfe3afd4239720f971 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 9b8be03b8e3f1458c9b704f7b1cb69e4e0338b34..79f499156f9b0c2127e5736a69a3be524fc4edf9 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index e5927e692560c98e2920a6d91480ecb032c5b9b3..59314602747ba63afc79678b90e2454da0b8cdaf 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index bd168d0a9a41143a8794c5bff3582896c54e58f6..340c7e5aa326928ad704bb4be973c1f067f1444b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index cc3c9f72abc4c79fe34f7827dfea1bb23247383f..d944fe6b3bbacfcab1c89fe732cc70f114d4b4df 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *      Copyright (C) 2000,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 73756461243c5ad5dce0416fe3b410055838f427..ba2998ff00d8584b4c455e6996cc4f7871f57244 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 59e31590f88e73a0712afe6c607432708a4a9e60..c0ccff7f583ad1e622096c95889e9889832ded14 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *      Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 2b5c4d3ddcae9722de22ff505859536ebcbcf25c..da278969eb0fae9e8cae1e61f660000db4576f82 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index d8dc35c9a4fb8d10346c4cd98b70320ae2b8ea35..462bb795b64314e7990a288582d23c29037fe5e1 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index a713060bdf6dc6763e08f75d92e31c4264ff0474..13e7e14c97602f687719de9a32e28d75264029d7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 578aef62af40e0eaeaa0495250140200fb0f8447..42b61bdf74cb5f0a461831e9f1d0beab22c1baf5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 2c5bef6f9a61150267c7d67d789230009ca95ea9..deaed91266b98a41b4a47f949d316ec8241b15a6 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 2b80b9ad5b6d3c1723666aefed8a0c8498441a67..02d22370c046255a4537d98d575b956a278a2fd4 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 8366a5c39240d6af31a43bdf33b1cc14f50ecf31..13eb2180ec2d03d007213724e8f3320fd04a9739 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index cca6a8fed4d3c23193063d9fd2e604739c2c9058..b0ca7a231101316f8ae9beb62c2027e165dd71a3 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 05267fff1b8c09254950726afaf76efe096be89d..c0b97f240870e0a5a292b373237d576cf5744d92 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 0cf65e041e3ab67f635bd4c676e244e8626d2f33..06d5ccdef95c1303536c63aa7eed37f378cdf426 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b246a72a0ac4403760b69f61df7ac453a1b31a12..3bd2b0d5d38a615f2a70a11554740995df5e2a17 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 53962844d861fbcb0cdd3d24c3adba13f150c40d..fca9088d5b58b708c81d248e5fa2c5335bfed85f 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b871ad09f1efc911386cb74719a3d2cda4ae9939..007404a8aebd561813f0ae323c8692fe84dc2775 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 4cb0b20394b8aaff09c1537bfb86be43b6c0701c..f54f1307d1cc7c4f2e01a199350e282229896988 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 65617a3e98567eba0a4fc1e4609ebd4c815b00a1..5d749066b2e047f1c914d11e49e7749848fcdc2b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *           someday was part of gsti
index d0f22310af34fe791d97aedca1957de8d678cc9e..31a786f189944fdb7f424050097f34946cf805f6 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 0ea3581416d0b7e83df05f0e4abb3d39ed4b1eaa..ca386ae7354c345999fc302734d75092f3946b16 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 179f09cdf75b9cdf6943e7f23e9aa51f053af00f..d13e89cd86e36d6580e3a993052bb9ab5dd8b99b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index df5327877ae60c1110f1d9982deecd9e4affad2d..c89fd3332e7f4acd25c9e61b459de947adee7030 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 4abb19deb9d173002cabc64f2353bee141af8bca..2a3026354f271bfdf999ba9663b2043624b875d8 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 1746f963dc542e0ec44bd5ba8fa2d0500cccded7..b7dd519c168a5e972ef40ca7252bec7810569e93 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 6d83c2ad78ea91c458b9118e6b3d2670f8c29f3d..dbb28b10d28ddb6e4f54f2a5f0655238aafedd11 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index dc21b196e17b057484240ca537aea7b9ee8bdeee..0762c6f1aebdcfae82e83e5d365b1c224bcfb9d2 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 8dede9544669a56e040f645fb4ee2c8dc24d4c5b..0f115578c66d94933213bce3a27219904babe8ce 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b0856ca7adb19851aeae04dd4bbd9b45666e8191..8d9ed1c8c41ece7ff6dbc1271150c227a4f0c047 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index c6d5db7be1866c1a828ecbbaf6522a16a5e92755..5a2d1e888d1745a4063ad1853bab670105cb781b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index ad898bc53dc16a50cebda0cedb720a7feb979010..3a6a6d99074645cd7740b4cd49d4fb9a16860e88 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 849ac3cb91ebf69566db1536cd3c62538add44e1..7500910cfac74c5ec961c8e89363161bb06b2cd2 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 832cffdbda83ef1da12e4c7a2c1b0b121b0a28b3..ccb6ae99d06617ad0e632623d899da4d9ff88490 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 113867bd32ce2434390fceaa5212b3d33123ca67..05e82535ef88438cc8e013906ac570ba51a2eccc 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 2c44748431b59dc65be67460859de003ce4f38ec..ca043c5b219ea2538ccc6910be29c752cca8bac2 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 1a108d347d57b072d5eb7ecdf459762b8e710dce..f3b387d65f8f6b862ade5601bef232773dae0fae 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 87a541d4738f1790badc1f45d2142b20c866ab2a..bdcc35d135732ebf72046bf5fb3f1631e474e089 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 711a2fdd31ec7190b48c125ba9f7e696b474ac53..aa06c0fbe44b490642ebba7811c882407a1f56c7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 9a3918cb7a5b559af27cb0d3897d0b4170a75762..50e7486e5358da19083d78552c30de4e61eca6ca 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index bf157596db50653fdea8f19ae1b90d22876c0fa4..f29eab87d820e7ec489b4989f6d78698c1cc0211 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 0676b2dc1b04c8ca6cc8090d121a50856be500d5..9db6516b2c5ee400b0ec43ca779900b5fd4cd23d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index e6f0093d16bbfdfa7e3f90a8dc8ac1f6048164b5..cf2aee981deb41927718094a21e44c4e77a77772 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 57aed55fb0457ba2b6b61a62cea46de8804b0b77..7eaa9d0dac6c368f710c007119324f958e4786cb 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 003857a71623f44949de704e9bd4b475872a5465..ebbdd11a240e1369a03db7855e910f11cc9f1882 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 77c21d4da4bc1457cd723550e7b9c94d3b5e6edc..ac9e33c901c37b80b20a6c0382a879690fe1323b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
 #include <gnutls/x509.h>
 #include <gnutls/compat8.h>
 
-/**
-  * gnutls_x509_extract_dn - This function parses an RDN sequence
-  * @idn: should contain a DER encoded RDN sequence
-  * @rdn: a pointer to a structure to hold the name
-  *
-  * This function will return the name of the given RDN sequence.
-  * The name will be returned as a gnutls_x509_dn structure.
-  * Returns a negative error code in case of an error.
-  *
-  **/
-int gnutls_x509_extract_dn(const gnutls_datum * idn, gnutls_x509_dn * rdn)
-{
-       ASN1_TYPE dn = ASN1_TYPE_EMPTY;
-       int result;
-       size_t len;
-
-       if ((result =
-            asn1_create_element(_gnutls_get_pkix(),
-                                  "PKIX1.Name", &dn
-                                  )) != ASN1_SUCCESS) {
-               return _gnutls_asn2err(result);
-       }
-
-       result = asn1_der_decoding(&dn, idn->data, idn->size, NULL);
-       if (result != ASN1_SUCCESS) {
-               /* couldn't decode DER */
-               asn1_delete_structure(&dn);
-               return _gnutls_asn2err(result);
-       }
-
-       memset( rdn, 0, sizeof(gnutls_x509_dn));
-
-       len = sizeof(rdn->country);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_COUNTRY_NAME, 0, 0, rdn->country, &len);
-
-       len = sizeof(rdn->organization);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, rdn->organization, &len);
-
-       len = sizeof(rdn->organizational_unit_name);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0, rdn->organizational_unit_name, &len);
-
-       len = sizeof(rdn->common_name);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_COMMON_NAME, 0, 0, rdn->common_name, &len);
-
-       len = sizeof(rdn->locality_name);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_LOCALITY_NAME, 0, 0, rdn->locality_name, &len);
-
-       len = sizeof(rdn->state_or_province_name);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0, rdn->state_or_province_name, &len);
-
-       len = sizeof(rdn->email);
-       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_PKCS9_EMAIL, 0, 0, rdn->email, &len);
-
-       asn1_delete_structure(&dn);
-
-       return 0;
-}
-
-/**
-  * gnutls_x509_extract_certificate_dn - This function returns the certificate's distinguished name
-  * @cert: should contain an X.509 DER encoded certificate
-  * @ret: a pointer to a structure to hold the peer's name
-  *
-  * This function will return the name of the certificate holder. The name is gnutls_x509_dn structure and 
-  * is a obtained by the peer's certificate. If the certificate send by the
-  * peer is invalid, or in any other failure this function returns error.
-  * Returns a negative error code in case of an error.
-  *
-  **/
-int gnutls_x509_extract_certificate_dn(const gnutls_datum * cert,
-                                         gnutls_x509_dn * ret)
-{
-       gnutls_x509_crt xcert;
-       int result;
-       size_t len;
-       
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-
-       len = sizeof( ret->country);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
-               ret->country, &len);
-
-       len = sizeof( ret->organization);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
-               ret->organization, &len);
-
-       len = sizeof( ret->organizational_unit_name);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
-               ret->organizational_unit_name, &len);
-
-       len = sizeof( ret->common_name);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
-               ret->common_name, &len);
-
-       len = sizeof( ret->locality_name);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
-               ret->locality_name, &len);
-
-       len = sizeof( ret->state_or_province_name);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
-               ret->state_or_province_name, &len);
-
-       len = sizeof( ret->email);
-       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
-               ret->email, &len);
-
-       gnutls_x509_crt_deinit( xcert);
-
-       return 0;
-}
-
-/**
-  * gnutls_x509_extract_certificate_issuer_dn - This function returns the certificate's issuer distinguished name
-  * @cert: should contain an X.509 DER encoded certificate
-  * @ret: a pointer to a structure to hold the issuer's name
-  *
-  * This function will return the name of the issuer stated in the certificate. The name is a gnutls_x509_dn structure and 
-  * is a obtained by the peer's certificate. If the certificate send by the
-  * peer is invalid, or in any other failure this function returns error.
-  * Returns a negative error code in case of an error.
-  *
-  **/
-int gnutls_x509_extract_certificate_issuer_dn(const gnutls_datum * cert,
-                                                gnutls_x509_dn * ret)
-{
-       gnutls_x509_crt xcert;
-       int result;
-       size_t len;
-
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-
-       len = sizeof( ret->country);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
-               ret->country, &len);
-
-       len = sizeof( ret->organization);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
-               ret->organization, &len);
-
-       len = sizeof( ret->organizational_unit_name);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
-               ret->organizational_unit_name, &len);
-
-       len = sizeof( ret->common_name);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
-               ret->common_name, &len);
-
-       len = sizeof( ret->locality_name);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
-               ret->locality_name, &len);
-
-       len = sizeof( ret->state_or_province_name);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
-               ret->state_or_province_name, &len);
-
-       len = sizeof( ret->email);
-       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
-               ret->email, &len);
-
-       gnutls_x509_crt_deinit( xcert);
-
-       return 0;
-}
-
-
-/**
-  * gnutls_x509_extract_certificate_subject_alt_name - This function returns the certificate's alternative name, if any
-  * @cert: should contain an X.509 DER encoded certificate
-  * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
-  * @ret: is the place where the alternative name will be copied to
-  * @ret_size: holds the size of ret.
-  *
-  * This function will return the alternative names, contained in the
-  * given certificate.
-  * 
-  * This is specified in X509v3 Certificate Extensions. 
-  * GNUTLS will return the Alternative name, or a negative
-  * error code.
-  * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if ret_size is not enough to hold the alternative 
-  * name, or the type of alternative name if everything was ok. The type is 
-  * one of the enumerated GNUTLS_X509_SUBJECT_ALT_NAME.
-  *
-  * If the certificate does not have an Alternative name with the specified 
-  * sequence number then returns GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
-  *
-  **/
-int gnutls_x509_extract_certificate_subject_alt_name(const gnutls_datum * cert, int seq, char *ret, int *ret_size)
-{
-       gnutls_x509_crt xcert;
-       int result;
-       size_t size = *ret_size;
-       
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-       
-       result = gnutls_x509_crt_get_subject_alt_name( xcert, seq, ret, &size, NULL);
-       *ret_size = size;
-       
-       gnutls_x509_crt_deinit( xcert);
-       
-       return result;
-}
-
-/**
-  * gnutls_x509_extract_certificate_ca_status - This function returns the certificate CA status
-  * @cert: should contain an X.509 DER encoded certificate
-  *
-  * This function will return certificates CA status, by reading the 
-  * basicConstraints X.509 extension. If the certificate is a CA a positive
-  * value will be returned, or zero if the certificate does not have
-  * CA flag set. 
-  *
-  * A negative value may be returned in case of parsing error.
-  * If the certificate does not contain the basicConstraints extension
-  * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
-  *
-  **/
-int gnutls_x509_extract_certificate_ca_status(const gnutls_datum * cert)
-{
-       gnutls_x509_crt xcert;
-       int result;
-       
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-       
-       result = gnutls_x509_crt_get_ca_status( xcert, NULL);
-       
-       gnutls_x509_crt_deinit( xcert);
-       
-       return result;
-}
-
 /**
   * gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
   * @cert: should contain an X.509 DER encoded certificate
@@ -354,442 +97,3 @@ time_t gnutls_x509_extract_certificate_expiration_time(const
        return result;
 }
 
-/**
-  * gnutls_x509_extract_certificate_version - This function returns the certificate's version
-  * @cert: is an X.509 DER encoded certificate
-  *
-  * This function will return the X.509 certificate's version (1, 2, 3). This is obtained by the X509 Certificate
-  * Version field. Returns a negative value in case of an error.
-  *
-  **/
-int gnutls_x509_extract_certificate_version(const gnutls_datum * cert)
-{
-       gnutls_x509_crt xcert;
-       int result;
-
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-       
-       result = gnutls_x509_crt_get_version( xcert);
-       
-       gnutls_x509_crt_deinit( xcert);
-       
-       return result;
-
-}
-
-/**
-  * gnutls_x509_extract_certificate_serial - This function returns the certificate's serial number
-  * @cert: is an X.509 DER encoded certificate
-  * @result: The place where the serial number will be copied
-  * @result_size: Holds the size of the result field.
-  *
-  * This function will return the X.509 certificate's serial number. 
-  * This is obtained by the X509 Certificate serialNumber
-  * field. Serial is not always a 32 or 64bit number. Some CAs use
-  * large serial numbers, thus it may be wise to handle it as something
-  * opaque. 
-  * Returns a negative value in case of an error.
-  *
-  **/
-int gnutls_x509_extract_certificate_serial(const gnutls_datum * cert, char* result, int* result_size)
-{
-       gnutls_x509_crt xcert;
-       size_t size = *result_size;
-       int ret;
-
-       ret = gnutls_x509_crt_init( &xcert);
-       if (ret < 0) return ret;
-       
-       ret = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (ret < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return ret;
-       }
-       
-       ret = gnutls_x509_crt_get_serial( xcert, result, &size);
-       *result_size = size;
-       
-       gnutls_x509_crt_deinit( xcert);
-       
-       return ret;
-}
-
-
-/**
-  * gnutls_x509_extract_certificate_pk_algorithm - This function returns the certificate's PublicKey algorithm
-  * @cert: is a DER encoded X.509 certificate
-  * @bits: if bits is non null it will hold the size of the parameters' in bits
-  *
-  * This function will return the public key algorithm of an X.509 
-  * certificate.
-  *
-  * If bits is non null, it should have enough size to hold the parameters
-  * size in bits. For RSA the bits returned is the modulus. 
-  * For DSA the bits returned are of the public
-  * exponent.
-  *
-  * Returns a member of the gnutls_pk_algorithm enumeration on success,
-  * or a negative value on error.
-  *
-  **/
-int gnutls_x509_extract_certificate_pk_algorithm( const gnutls_datum * cert, int* bits)
-{
-       gnutls_x509_crt xcert;
-       int result;
-
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-       
-       result = gnutls_x509_crt_get_pk_algorithm( xcert, bits);
-       
-       gnutls_x509_crt_deinit( xcert);
-       
-       return result;
-}
-
-
-/**
-  * gnutls_x509_extract_certificate_dn_string - This function returns the certificate's distinguished name
-  * @cert: should contain an X.509 DER encoded certificate
-  * @buf: a pointer to a structure to hold the peer's name
-  * @sizeof_buf: holds the size of 'buf'
-  * @issuer: if non zero, then extract the name of the issuer, instead of the holder
-  *
-  * This function will copy the name of the certificate holder in the provided buffer. The name 
-  * will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253.
-  *
-  * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough,
-  * and 0 on success.
-  *
-  **/
-int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf, 
-   const gnutls_datum * cert, int issuer)
-{
-       gnutls_x509_crt xcert;
-       int result;
-
-       result = gnutls_x509_crt_init( &xcert);
-       if (result < 0) return result;
-       
-       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_x509_crt_deinit( xcert);
-               return result;
-       }
-       
-       if (!issuer)
-               result = gnutls_x509_crt_get_dn( xcert, buf, &sizeof_buf);
-       else
-               result = gnutls_x509_crt_get_issuer_dn( xcert, buf, &sizeof_buf);
-
-       gnutls_x509_crt_deinit( xcert);
-       
-       return result;
-}
-
-/**
-  * gnutls_x509_verify_certificate - This function verifies given certificate list
-  * @cert_list: is the certificate list to be verified
-  * @cert_list_length: holds the number of certificate in cert_list
-  * @CA_list: is the CA list which will be used in verification
-  * @CA_list_length: holds the number of CA certificate in CA_list
-  * @CRL_list: not used
-  * @CRL_list_length: not used
-  *
-  * This function will try to verify the given certificate list and return its status (TRUSTED, EXPIRED etc.). 
-  * The return value (status) should be one or more of the gnutls_certificate_status 
-  * enumerated elements bitwise or'd. Note that expiration and activation dates are not checked 
-  * by this function, you should check them using the appropriate functions.
-  *
-  * This function understands the basicConstraints (2.5.29.19) PKIX extension.
-  * This means that only a certificate authority can sign a certificate.
-  *
-  * However you must also check the peer's name in order to check if the verified certificate belongs to the 
-  * actual peer. 
-  *
-  * The return value (status) should be one or more of the gnutls_certificate_status 
-  * enumerated elements bitwise or'd.
-  *
-  * GNUTLS_CERT_INVALID\: the peer's certificate is not valid.
-  *
-  * GNUTLS_CERT_REVOKED\: the certificate has been revoked.
-  *
-  * A negative error code is returned in case of an error.
-  * GNUTLS_E_NO_CERTIFICATE_FOUND is returned to indicate that
-  * no certificate was sent by the peer.
-  *  
-  *
-  **/
-int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list_length, 
-       const gnutls_datum * CA_list, int CA_list_length, 
-       const gnutls_datum* CRL_list, int CRL_list_length)
-{
-       unsigned int verify;
-       gnutls_x509_crt *peer_certificate_list = NULL;
-       gnutls_x509_crt *ca_certificate_list = NULL;
-       gnutls_x509_crl *crl_list = NULL;
-       int peer_certificate_list_size=0, i, x, ret;
-       int ca_certificate_list_size=0, crl_list_size=0;
-
-       if (cert_list == NULL || cert_list_length == 0)
-               return GNUTLS_E_NO_CERTIFICATE_FOUND;
-
-       /* generate a list of gnutls_certs based on the auth info
-        * raw certs.
-        */
-       peer_certificate_list_size = cert_list_length;
-       peer_certificate_list =
-           gnutls_calloc(1,
-                         peer_certificate_list_size *
-                         sizeof(gnutls_x509_crt));
-       if (peer_certificate_list == NULL) {
-               gnutls_assert();
-               ret = GNUTLS_E_MEMORY_ERROR;
-               goto cleanup;
-       }
-
-       ca_certificate_list_size = CA_list_length;
-       ca_certificate_list =
-           gnutls_calloc(1,
-                         ca_certificate_list_size *
-                         sizeof(gnutls_x509_crt));
-       if (ca_certificate_list == NULL) {
-               gnutls_assert();
-               ret = GNUTLS_E_MEMORY_ERROR;
-               goto cleanup;
-       }
-
-       /* allocate memory for CRL
-        */
-       crl_list_size = CRL_list_length;
-       crl_list =
-           gnutls_calloc(1,
-                         crl_list_size *
-                         sizeof(gnutls_x509_crl));
-       if (crl_list == NULL) {
-               gnutls_assert();
-               ret = GNUTLS_E_MEMORY_ERROR;
-               goto cleanup;
-       }
-
-       /* convert certA_list to gnutls_cert* list
-        */
-       for (i = 0; i < peer_certificate_list_size; i++) {
-               ret = gnutls_x509_crt_init( &peer_certificate_list[i]);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-                               
-               ret =
-                    gnutls_x509_crt_import(peer_certificate_list[i],
-                                            &cert_list[i], GNUTLS_X509_FMT_DER);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-       }
-
-       /* convert CA_list to gnutls_x509_cert* list
-        */
-       for (i = 0; i < ca_certificate_list_size; i++) {
-               ret = gnutls_x509_crt_init(&ca_certificate_list[i]);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-
-               ret =
-                    gnutls_x509_crt_import(ca_certificate_list[i],
-                                        &CA_list[i], GNUTLS_X509_FMT_DER);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-       }
-
-#ifdef ENABLE_PKI
-       /* convert CRL_list to gnutls_x509_crl* list
-        */
-       for (i = 0; i < crl_list_size; i++) {
-               ret = gnutls_x509_crl_init( &crl_list[i]);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-
-               ret =
-                    gnutls_x509_crl_import(crl_list[i],
-                                        &CRL_list[i], GNUTLS_X509_FMT_DER);
-               if (ret < 0) {
-                       gnutls_assert();
-                       goto cleanup;
-               }
-       }
-#endif
-
-       /* Verify certificate 
-        */
-       ret =
-           gnutls_x509_crt_list_verify(peer_certificate_list,
-                                     peer_certificate_list_size,
-                                     ca_certificate_list, ca_certificate_list_size, 
-                                     crl_list, crl_list_size, 0, &verify);
-
-       if (ret < 0) {
-               gnutls_assert();
-               goto cleanup;
-       }
-       
-       ret = verify;
-
-       cleanup:
-
-       if (peer_certificate_list != NULL)
-               for(x=0;x<peer_certificate_list_size;x++) {
-                       if (peer_certificate_list[x] != NULL)
-                               gnutls_x509_crt_deinit(peer_certificate_list[x]);
-               }
-
-       if (ca_certificate_list != NULL)
-               for(x=0;x<ca_certificate_list_size;x++) {
-                       if (ca_certificate_list[x] !=  NULL)
-                               gnutls_x509_crt_deinit(ca_certificate_list[x]);
-               }
-
-#ifdef ENABLE_PKI
-       if (crl_list != NULL)
-               for(x=0;x<crl_list_size;x++) {
-                       if (crl_list[x] != NULL)
-                               gnutls_x509_crl_deinit(crl_list[x]);
-               }
-       
-       gnutls_free( crl_list);
-#endif
-
-       gnutls_free( ca_certificate_list);
-       gnutls_free( peer_certificate_list);
-
-       return ret;
-}
-
-/**
-  * gnutls_x509_extract_key_pk_algorithm - This function returns the keys's PublicKey algorithm
-  * @cert: is a DER encoded private key
-  *
-  * This function will return the public key algorithm of a DER encoded private
-  * key.
-  *
-  * Returns a member of the gnutls_pk_algorithm enumeration on success,
-  * or GNUTLS_E_UNKNOWN_PK_ALGORITHM on error.
-  *
-  **/
-int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key)
-{
-       gnutls_x509_privkey pkey;
-       int ret, pk;
-       
-       ret = gnutls_x509_privkey_init( &pkey);
-       if (ret < 0) {
-               gnutls_assert();
-               return ret;
-       }
-       
-       ret = gnutls_x509_privkey_import( pkey, key, GNUTLS_X509_FMT_DER);
-       if (ret < 0) {
-               gnutls_assert();
-               return ret;
-       }
-
-       pk = gnutls_x509_privkey_get_pk_algorithm( pkey);
-       
-       gnutls_x509_privkey_deinit( pkey);
-       return pk;
-}
-
-#ifdef ENABLE_PKI
-
-/**
-  * gnutls_x509_pkcs7_extract_certificate - This function returns a certificate in a PKCS7 certificate set
-  * @pkcs7_struct: should contain a PKCS7 DER formatted structure
-  * @indx: contains the index of the certificate to extract
-  * @certificate: the contents of the certificate will be copied there
-  * @certificate_size: should hold the size of the certificate
-  *
-  * This function will return a certificate of the PKCS7 or RFC2630 certificate set.
-  * Returns 0 on success. If the provided buffer is not long enough,
-  * then GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
-  *
-  * After the last certificate has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
-  * will be returned.
-  *
-  **/
-int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size)
-{
-       gnutls_pkcs7 pkcs7;
-       int result;
-       size_t size = *certificate_size;
-
-       result = gnutls_pkcs7_init( &pkcs7);
-       if (result < 0) return result;
-       
-       result = gnutls_pkcs7_import( pkcs7, pkcs7_struct, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_pkcs7_deinit( pkcs7);
-               return result;
-       }
-       
-       result = gnutls_pkcs7_get_crt_raw( pkcs7, indx, certificate, &size);
-       *certificate_size = size;
-
-       gnutls_pkcs7_deinit( pkcs7);
-       
-       return result;
-}
-
-
-/**
-  * gnutls_x509_pkcs7_extract_certificate_count - This function returns the number of certificates in a PKCS7 certificate set
-  * @pkcs7_struct: should contain a PKCS7 DER formatted structure
-  *
-  * This function will return the number of certifcates in the PKCS7 or 
-  * RFC2630 certificate set.
-  *
-  * Returns a negative value on failure.
-  *
-  **/
-int gnutls_x509_pkcs7_extract_certificate_count(const gnutls_datum * pkcs7_struct)
-{
-       gnutls_pkcs7 pkcs7;
-       int result;
-
-       result = gnutls_pkcs7_init( &pkcs7);
-       if (result < 0) return result;
-       
-       result = gnutls_pkcs7_import( pkcs7, pkcs7_struct, GNUTLS_X509_FMT_DER);
-       if (result < 0) {
-               gnutls_pkcs7_deinit( pkcs7);
-               return result;
-       }
-       
-       result = gnutls_pkcs7_get_crt_count( pkcs7);
-       
-       gnutls_pkcs7_deinit( pkcs7);
-       
-       return result;
-}
-
-#endif
index 7e60f131dbba6702ae1d9ab4b909208a958e9b4f..834c41caa98130e870e2d2ca70a107f9f379b375 100644 (file)
@@ -2,9 +2,3 @@
 
 time_t gnutls_x509_extract_certificate_activation_time( const gnutls_datum*);
 time_t gnutls_x509_extract_certificate_expiration_time( const gnutls_datum*);
-
-int gnutls_x509_extract_certificate_subject_alt_name( const gnutls_datum*, int seq, char*, int*);
-int gnutls_x509_extract_certificate_dn( const gnutls_datum*, gnutls_x509_dn*);
-
-int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size);
-int gnutls_x509_pkcs7_extract_certificate_count(const gnutls_datum * pkcs7_struct);
index be4edc4a1d8a5ccb3205384d977cf5d4b6b0b653..89f2738340c4cc5159b9a50ac6320c2c516797b3 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 8ed79f331a6c4dc5657fb27da870cdcc3859c558..453c31f9662df85427cc8379c252a9136f5b87e7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 755f72ec558637b803541972c9aefdd15fbd71ed..ae3af42c0e46664df8b2a363034da558d70ee41d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 174c0b31b233c6fe094249af159b4ec5d3009dfc..6d2f25b72f6e9e2f7385120c84839ec4ace03f19 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index c4dbfe4a6d7a080155b78a4fb857ea610d49b1b2..921ea125b5ecdbc5b1b780c7e905f307e49f551e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 007e728336deac86605b0adb1626e71644df920b..53d4e5e2f9ca5fc644654759bc1f8bf2f08e9f48 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 9f61e21d0d553b98907da024b6d47fb1d8e310d2..db8245af90a6c9f2d943eb0e0783a45117f4bc67 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 6b9ab32ba1055d3094a19006bc51a4f3dc07c2d7..466f4e7970c11422649f84ed5e1f47a0ad9ce94a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index c1501e62dbbfc9b56e6bc147e99b8583db04f1fc..921bff9b86ebcec9df58fe511d38661fb9ec6577 100644 (file)
@@ -1,7 +1,4 @@
-/* This is based on minip12.
- */
-
-/*  minip12.c - A minilam pkcs-12 implementation.
+/*  minip12.c - A mini pkcs-12 implementation (modified for gnutls)
  *     Copyright (C) 2002 Free Software Foundation, Inc.
  *
  *  This file some day was part of GnuPG.
index 15ce59c05c04d96ffc7c8c8a65370b474cafe0e0..c1c745b71e25000a424ab5ada705c0b797a4e2f2 100644 (file)
@@ -1,5 +1,6 @@
 /* pkcs5.c     Implementation of Password-Based Cryptography as per PKCS#5
  * Copyright (C) 2002,2003 Simon Josefsson
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
index eb12fc12127dd82ce38a1dc1d1eb9d0c39bb0fda..4eac6054d6530b5dbc3b7a6d3852fb4cb7ad6301 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 930640d6e13cbeae093cc00678b1b5fb84b1c050..4798e221dd09a316be409115c5d22c1cfc50647d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 433436fa3bd26c773a03e5cf1affa83855feb7a2..412b855e01783d75ceade2b0db06a2ad86a6b087 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index b993d4479356b839b86939a8672b992fdb9a9c33..982d556f255fd2010464291b2ea76e371480ad0e 100644 (file)
@@ -1,5 +1,6 @@
 /* rc2.c  -  The RC2 stream cipher
  * Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 249ec82622cb843cc0108a6b437a4ea92b140d32..bd3d7c5713569d1a69ffcd44003ab7d342d86802 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2002 Andrew McDonald
  * Portions Copyright 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b32c21569b5fd478411a871331d4cd27e2677f13..73d9d56a9d3febccdac449e7d255c343fdb856f7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos <nmav@hellug.gr>
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 7055debb2e9eddd40ca96e0bb43554efba230350..9b3f658b00608f83be1ba483f242f734ffcbe9fa 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos <nmav@hellug.gr>
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index c7f546a7b1eb42366e5bd95582f5e315a6ca5d93..88051c0cc22999abd1b226368ffa0b8d23765a20 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 8de1ff010c68ac9d957b4f6ffe6835a7db868ddc..b4c155b7bb0f0dcc52fd894e3b73642b887fd9a7 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 5c3ec65f941a6565a91b5e880cf083537641d1b7..24df0702190a9808aa5ed20cc6be780eeb0041f9 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 7156bd2fb9b088ef6405c33b18f6c444fbf2b1b6..9b233af614be545eeb7b1c31f5127c6d68b00957 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2000,2001,2003 Nikos Mavroyanopoulos <nmav@hellug.gr>
+ *  Copyright (C) 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS.
  *
index 0db520f9967c916359cd9103d276f65aa544e5db..844b9f2c343f106d1cc65a5beeea4913c528680d 100644 (file)
@@ -12,7 +12,7 @@ else
 endif
 
 EXTRA_DIST = ext_srp.h gnutls_srp.h libgnutls-extra.vers \
-       auth_srp.h auth_srp_passwd.h \
+       auth_srp.h auth_srp_passwd.h openssl_compat.h \
        gnutls-extra-api.tex gnutls_extra.h libgnutls-extra-config.in \
        libgnutls-extra.m4 lzoconf.h minilzo.h
 
@@ -22,7 +22,7 @@ lib_LTLIBRARIES = libgnutls-extra.la libgnutls-openssl.la
 
 libgnutls_openssl_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
 
-libgnutls_openssl_la_SOURCES = gnutls_openssl.c
+libgnutls_openssl_la_SOURCES = gnutls_openssl.c openssl_compat.c
 
 libgnutls_openssl_la_LIBADD = \
        ../lib/libgnutls.la
index 169949b2703da7e9e2b4323bddf9b3c126b5eb67..17fe1d28b223d4201826f3a0b921c91ab2dbd973 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 67cdaf17323be25f71687beca6cdae34db9fafc6..580cc7f438155c1e74dfcf0ea16c577f60bafecd 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index bd5a26df863c067305e2954e09bd797b59f3660d..561465d71f4625857d7ade2675d074eadbf4a606 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 9011ec1843a0879ad2220104606b4c0bdd427ccc..db8edb65b7a24c28af9d4798320044f3cac8ad29 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002 Nikos Mavroyanopoulos <nmav@hellug.gr>
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index a9460a1e7d9d3c02ca8ea2c1d7e518fd3c3374db..2624b965b175651755abd81e95f9a2b05e250e77 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b4a8c78576fbfcdba5a641ffd146b8949500e84f..00c99b2c7e4b4544c23d3956afbdc91cbd8a4ac6 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 86c2daffe3af8628a6aa7ebf64ead9ad777ede60..4ba3061bcb00b17b881106935b2f99a95bdf39f5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2002,2003 Timo Schulz <twoaday@freakmail.de>
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index b7ecaebb9e50a5781ba24116a628bc4333180090..31155e18eb7011935530941146dd16776e471e0a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2002 Andrew McDonald <andrew@mcdonald.org.uk>
+ * Copyright (C) 2004 Free Software Foundation
  *
  * GNUTLS-EXTRA 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
@@ -19,7 +20,7 @@
 #include <config.h>
 
 #include <gnutls/gnutls.h>
-#include <gnutls/compat8.h>
+#include <openssl_compat.h>
 #include <gcrypt.h>
 #include <stdio.h>
 #include <stdlib.h>
index e80602b1188700c5ca15d7353404c37f9f5668a7..2befd82c123ff23cf791df84634d0f7451c74c94 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 4faef21985a82f2f7f8bd4385db4fd37c424b7d1..963efad620453be77e8130b31d7d86aba5c5f999 100644 (file)
@@ -1,6 +1,7 @@
 /*
  *  Copyright (C) 2002 Timo Schulz
  *  Portions Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS-EXTRA.
  *
index 48a36ccb7f8b75faa263e3a7c3ac52acb798f509..1de1b2eb8bdf2cd1088a5268889436971a739084 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS-EXTRA.
  *
index 22a28a9461c57298a864c1cbad871979e2f39631..5ebdab76252a835f3883be79b56a603c105c2c6c 100644 (file)
@@ -1,6 +1,7 @@
 /*
- *  Copyright (C) 2002 Timo Schulz
- *  Portions Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2002 Timo Schulz
+ * Portions Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 51a315fa82d25bea470657794294770426d726be..0331ad1bf5eba255e097379e3beff6ac84b9c128 100644 (file)
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 481c55822263ed1ed0625776c6478a2ffb994ee7..7472b4e35356f520df8a0aba97211e18702703ca 100644 (file)
@@ -1,6 +1,7 @@
 /*
  *  Copyright (C) 2002 Timo Schulz
  *  Portions Copyright (C) 2003 Nikos Mavroyanopoulos
+ *  Copyright 2004 Free Software Foundation
  *
  *  This file is part of GNUTLS-EXTRA.
  *
index aacad0830d5626294893a8b120ceeeec632ff789..d95e10e85a15a9fa678c3178dcb3c74842f5c449 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2002 Timo Schulz <twoaday@freakmail.de>
  * Portions Copyright 2003 Nikos Mavroyanopoulos <nmav@gnutls.org>
+ * Copyright 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
diff --git a/libextra/openssl_compat.c b/libextra/openssl_compat.c
new file mode 100644 (file)
index 0000000..247cad1
--- /dev/null
@@ -0,0 +1,796 @@
+/*
+ *  Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ *  Copyright (C) 2004 Free Software Foundation
+ *
+ *  This file is part of GNUTLS.
+ *
+ *  The GNUTLS library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public   
+ *  License as published by the Free Software Foundation; either 
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+/* This file includes all functions that were in the 0.5.x and 0.8.x
+ * gnutls API. They are now implemented over the new certificate parsing
+ * API.
+ */
+
+#include <gnutls_global.h>
+#include <gnutls_errors.h>
+#include <string.h> /* memset */
+#include <x509/dn.h>
+#include <libtasn1.h>
+#include <gnutls/x509.h>
+#include <openssl_compat.h>
+
+/**
+  * gnutls_x509_extract_dn - This function parses an RDN sequence
+  * @idn: should contain a DER encoded RDN sequence
+  * @rdn: a pointer to a structure to hold the name
+  *
+  * This function will return the name of the given RDN sequence.
+  * The name will be returned as a gnutls_x509_dn structure.
+  * Returns a negative error code in case of an error.
+  *
+  **/
+int gnutls_x509_extract_dn(const gnutls_datum * idn, gnutls_x509_dn * rdn)
+{
+       ASN1_TYPE dn = ASN1_TYPE_EMPTY;
+       int result;
+       size_t len;
+
+       if ((result =
+            asn1_create_element(_gnutls_get_pkix(),
+                                  "PKIX1.Name", &dn
+                                  )) != ASN1_SUCCESS) {
+               return _gnutls_asn2err(result);
+       }
+
+       result = asn1_der_decoding(&dn, idn->data, idn->size, NULL);
+       if (result != ASN1_SUCCESS) {
+               /* couldn't decode DER */
+               asn1_delete_structure(&dn);
+               return _gnutls_asn2err(result);
+       }
+
+       memset( rdn, 0, sizeof(gnutls_x509_dn));
+
+       len = sizeof(rdn->country);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_COUNTRY_NAME, 0, 0, rdn->country, &len);
+
+       len = sizeof(rdn->organization);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0, rdn->organization, &len);
+
+       len = sizeof(rdn->organizational_unit_name);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0, rdn->organizational_unit_name, &len);
+
+       len = sizeof(rdn->common_name);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_COMMON_NAME, 0, 0, rdn->common_name, &len);
+
+       len = sizeof(rdn->locality_name);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_LOCALITY_NAME, 0, 0, rdn->locality_name, &len);
+
+       len = sizeof(rdn->state_or_province_name);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0, rdn->state_or_province_name, &len);
+
+       len = sizeof(rdn->email);
+       _gnutls_x509_parse_dn_oid( dn, "", GNUTLS_OID_PKCS9_EMAIL, 0, 0, rdn->email, &len);
+
+       asn1_delete_structure(&dn);
+
+       return 0;
+}
+
+/**
+  * gnutls_x509_extract_certificate_dn - This function returns the certificate's distinguished name
+  * @cert: should contain an X.509 DER encoded certificate
+  * @ret: a pointer to a structure to hold the peer's name
+  *
+  * This function will return the name of the certificate holder. The name is gnutls_x509_dn structure and 
+  * is a obtained by the peer's certificate. If the certificate send by the
+  * peer is invalid, or in any other failure this function returns error.
+  * Returns a negative error code in case of an error.
+  *
+  **/
+int gnutls_x509_extract_certificate_dn(const gnutls_datum * cert,
+                                         gnutls_x509_dn * ret)
+{
+       gnutls_x509_crt xcert;
+       int result;
+       size_t len;
+       
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+
+       len = sizeof( ret->country);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
+               ret->country, &len);
+
+       len = sizeof( ret->organization);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
+               ret->organization, &len);
+
+       len = sizeof( ret->organizational_unit_name);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
+               ret->organizational_unit_name, &len);
+
+       len = sizeof( ret->common_name);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
+               ret->common_name, &len);
+
+       len = sizeof( ret->locality_name);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
+               ret->locality_name, &len);
+
+       len = sizeof( ret->state_or_province_name);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
+               ret->state_or_province_name, &len);
+
+       len = sizeof( ret->email);
+       gnutls_x509_crt_get_dn_by_oid( xcert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
+               ret->email, &len);
+
+       gnutls_x509_crt_deinit( xcert);
+
+       return 0;
+}
+
+/**
+  * gnutls_x509_extract_certificate_issuer_dn - This function returns the certificate's issuer distinguished name
+  * @cert: should contain an X.509 DER encoded certificate
+  * @ret: a pointer to a structure to hold the issuer's name
+  *
+  * This function will return the name of the issuer stated in the certificate. The name is a gnutls_x509_dn structure and 
+  * is a obtained by the peer's certificate. If the certificate send by the
+  * peer is invalid, or in any other failure this function returns error.
+  * Returns a negative error code in case of an error.
+  *
+  **/
+int gnutls_x509_extract_certificate_issuer_dn(const gnutls_datum * cert,
+                                                gnutls_x509_dn * ret)
+{
+       gnutls_x509_crt xcert;
+       int result;
+       size_t len;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+
+       len = sizeof( ret->country);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_COUNTRY_NAME, 0, 0,
+               ret->country, &len);
+
+       len = sizeof( ret->organization);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATION_NAME, 0, 0,
+               ret->organization, &len);
+
+       len = sizeof( ret->organizational_unit_name);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME, 0, 0,
+               ret->organizational_unit_name, &len);
+
+       len = sizeof( ret->common_name);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_COMMON_NAME, 0, 0,
+               ret->common_name, &len);
+
+       len = sizeof( ret->locality_name);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_LOCALITY_NAME, 0, 0,
+               ret->locality_name, &len);
+
+       len = sizeof( ret->state_or_province_name);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME, 0, 0,
+               ret->state_or_province_name, &len);
+
+       len = sizeof( ret->email);
+       gnutls_x509_crt_get_issuer_dn_by_oid( xcert, GNUTLS_OID_PKCS9_EMAIL, 0, 0,
+               ret->email, &len);
+
+       gnutls_x509_crt_deinit( xcert);
+
+       return 0;
+}
+
+
+/**
+  * gnutls_x509_extract_certificate_subject_alt_name - This function returns the certificate's alternative name, if any
+  * @cert: should contain an X.509 DER encoded certificate
+  * @seq: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
+  * @ret: is the place where the alternative name will be copied to
+  * @ret_size: holds the size of ret.
+  *
+  * This function will return the alternative names, contained in the
+  * given certificate.
+  * 
+  * This is specified in X509v3 Certificate Extensions. 
+  * GNUTLS will return the Alternative name, or a negative
+  * error code.
+  * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if ret_size is not enough to hold the alternative 
+  * name, or the type of alternative name if everything was ok. The type is 
+  * one of the enumerated GNUTLS_X509_SUBJECT_ALT_NAME.
+  *
+  * If the certificate does not have an Alternative name with the specified 
+  * sequence number then returns GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
+  *
+  **/
+int gnutls_x509_extract_certificate_subject_alt_name(const gnutls_datum * cert, int seq, char *ret, int *ret_size)
+{
+       gnutls_x509_crt xcert;
+       int result;
+       size_t size = *ret_size;
+       
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_subject_alt_name( xcert, seq, ret, &size, NULL);
+       *ret_size = size;
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+/**
+  * gnutls_x509_extract_certificate_ca_status - This function returns the certificate CA status
+  * @cert: should contain an X.509 DER encoded certificate
+  *
+  * This function will return certificates CA status, by reading the 
+  * basicConstraints X.509 extension. If the certificate is a CA a positive
+  * value will be returned, or zero if the certificate does not have
+  * CA flag set. 
+  *
+  * A negative value may be returned in case of parsing error.
+  * If the certificate does not contain the basicConstraints extension
+  * GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
+  *
+  **/
+int gnutls_x509_extract_certificate_ca_status(const gnutls_datum * cert)
+{
+       gnutls_x509_crt xcert;
+       int result;
+       
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_ca_status( xcert, NULL);
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+/**
+  * gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
+  * @cert: should contain an X.509 DER encoded certificate
+  *
+  * This function will return the certificate's activation time in UNIX time 
+  * (ie seconds since 00:00:00 UTC January 1, 1970).
+  * Returns a (time_t) -1 in case of an error.
+  *
+  **/
+time_t gnutls_x509_extract_certificate_activation_time(const
+                                                         gnutls_datum *
+                                                         cert)
+{
+       gnutls_x509_crt xcert;
+       time_t result;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_activation_time( xcert);
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+/**
+  * gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
+  * @cert: should contain an X.509 DER encoded certificate
+  *
+  * This function will return the certificate's expiration time in UNIX time 
+  * (ie seconds since 00:00:00 UTC January 1, 1970).
+  * Returns a (time_t) -1 in case of an error.
+  *
+  **/
+time_t gnutls_x509_extract_certificate_expiration_time(const
+                                                         gnutls_datum *
+                                                         cert)
+{
+       gnutls_x509_crt xcert;
+       time_t result;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_expiration_time( xcert);
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+/**
+  * gnutls_x509_extract_certificate_version - This function returns the certificate's version
+  * @cert: is an X.509 DER encoded certificate
+  *
+  * This function will return the X.509 certificate's version (1, 2, 3). This is obtained by the X509 Certificate
+  * Version field. Returns a negative value in case of an error.
+  *
+  **/
+int gnutls_x509_extract_certificate_version(const gnutls_datum * cert)
+{
+       gnutls_x509_crt xcert;
+       int result;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_version( xcert);
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+
+}
+
+/**
+  * gnutls_x509_extract_certificate_serial - This function returns the certificate's serial number
+  * @cert: is an X.509 DER encoded certificate
+  * @result: The place where the serial number will be copied
+  * @result_size: Holds the size of the result field.
+  *
+  * This function will return the X.509 certificate's serial number. 
+  * This is obtained by the X509 Certificate serialNumber
+  * field. Serial is not always a 32 or 64bit number. Some CAs use
+  * large serial numbers, thus it may be wise to handle it as something
+  * opaque. 
+  * Returns a negative value in case of an error.
+  *
+  **/
+int gnutls_x509_extract_certificate_serial(const gnutls_datum * cert, char* result, int* result_size)
+{
+       gnutls_x509_crt xcert;
+       size_t size = *result_size;
+       int ret;
+
+       ret = gnutls_x509_crt_init( &xcert);
+       if (ret < 0) return ret;
+       
+       ret = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (ret < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return ret;
+       }
+       
+       ret = gnutls_x509_crt_get_serial( xcert, result, &size);
+       *result_size = size;
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return ret;
+}
+
+
+/**
+  * gnutls_x509_extract_certificate_pk_algorithm - This function returns the certificate's PublicKey algorithm
+  * @cert: is a DER encoded X.509 certificate
+  * @bits: if bits is non null it will hold the size of the parameters' in bits
+  *
+  * This function will return the public key algorithm of an X.509 
+  * certificate.
+  *
+  * If bits is non null, it should have enough size to hold the parameters
+  * size in bits. For RSA the bits returned is the modulus. 
+  * For DSA the bits returned are of the public
+  * exponent.
+  *
+  * Returns a member of the gnutls_pk_algorithm enumeration on success,
+  * or a negative value on error.
+  *
+  **/
+int gnutls_x509_extract_certificate_pk_algorithm( const gnutls_datum * cert, int* bits)
+{
+       gnutls_x509_crt xcert;
+       int result;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       result = gnutls_x509_crt_get_pk_algorithm( xcert, bits);
+       
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+
+/**
+  * gnutls_x509_extract_certificate_dn_string - This function returns the certificate's distinguished name
+  * @cert: should contain an X.509 DER encoded certificate
+  * @buf: a pointer to a structure to hold the peer's name
+  * @sizeof_buf: holds the size of 'buf'
+  * @issuer: if non zero, then extract the name of the issuer, instead of the holder
+  *
+  * This function will copy the name of the certificate holder in the provided buffer. The name 
+  * will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253.
+  *
+  * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not long enough,
+  * and 0 on success.
+  *
+  **/
+int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf, 
+   const gnutls_datum * cert, int issuer)
+{
+       gnutls_x509_crt xcert;
+       int result;
+
+       result = gnutls_x509_crt_init( &xcert);
+       if (result < 0) return result;
+       
+       result = gnutls_x509_crt_import( xcert, cert, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_x509_crt_deinit( xcert);
+               return result;
+       }
+       
+       if (!issuer)
+               result = gnutls_x509_crt_get_dn( xcert, buf, &sizeof_buf);
+       else
+               result = gnutls_x509_crt_get_issuer_dn( xcert, buf, &sizeof_buf);
+
+       gnutls_x509_crt_deinit( xcert);
+       
+       return result;
+}
+
+/**
+  * gnutls_x509_verify_certificate - This function verifies given certificate list
+  * @cert_list: is the certificate list to be verified
+  * @cert_list_length: holds the number of certificate in cert_list
+  * @CA_list: is the CA list which will be used in verification
+  * @CA_list_length: holds the number of CA certificate in CA_list
+  * @CRL_list: not used
+  * @CRL_list_length: not used
+  *
+  * This function will try to verify the given certificate list and return its status (TRUSTED, EXPIRED etc.). 
+  * The return value (status) should be one or more of the gnutls_certificate_status 
+  * enumerated elements bitwise or'd. Note that expiration and activation dates are not checked 
+  * by this function, you should check them using the appropriate functions.
+  *
+  * This function understands the basicConstraints (2.5.29.19) PKIX extension.
+  * This means that only a certificate authority can sign a certificate.
+  *
+  * However you must also check the peer's name in order to check if the verified certificate belongs to the 
+  * actual peer. 
+  *
+  * The return value (status) should be one or more of the gnutls_certificate_status 
+  * enumerated elements bitwise or'd.
+  *
+  * GNUTLS_CERT_INVALID\: the peer's certificate is not valid.
+  *
+  * GNUTLS_CERT_REVOKED\: the certificate has been revoked.
+  *
+  * A negative error code is returned in case of an error.
+  * GNUTLS_E_NO_CERTIFICATE_FOUND is returned to indicate that
+  * no certificate was sent by the peer.
+  *  
+  *
+  **/
+int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list_length, 
+       const gnutls_datum * CA_list, int CA_list_length, 
+       const gnutls_datum* CRL_list, int CRL_list_length)
+{
+       unsigned int verify;
+       gnutls_x509_crt *peer_certificate_list = NULL;
+       gnutls_x509_crt *ca_certificate_list = NULL;
+       gnutls_x509_crl *crl_list = NULL;
+       int peer_certificate_list_size=0, i, x, ret;
+       int ca_certificate_list_size=0, crl_list_size=0;
+
+       if (cert_list == NULL || cert_list_length == 0)
+               return GNUTLS_E_NO_CERTIFICATE_FOUND;
+
+       /* generate a list of gnutls_certs based on the auth info
+        * raw certs.
+        */
+       peer_certificate_list_size = cert_list_length;
+       peer_certificate_list =
+           gnutls_calloc(1,
+                         peer_certificate_list_size *
+                         sizeof(gnutls_x509_crt));
+       if (peer_certificate_list == NULL) {
+               gnutls_assert();
+               ret = GNUTLS_E_MEMORY_ERROR;
+               goto cleanup;
+       }
+
+       ca_certificate_list_size = CA_list_length;
+       ca_certificate_list =
+           gnutls_calloc(1,
+                         ca_certificate_list_size *
+                         sizeof(gnutls_x509_crt));
+       if (ca_certificate_list == NULL) {
+               gnutls_assert();
+               ret = GNUTLS_E_MEMORY_ERROR;
+               goto cleanup;
+       }
+
+       /* allocate memory for CRL
+        */
+       crl_list_size = CRL_list_length;
+       crl_list =
+           gnutls_calloc(1,
+                         crl_list_size *
+                         sizeof(gnutls_x509_crl));
+       if (crl_list == NULL) {
+               gnutls_assert();
+               ret = GNUTLS_E_MEMORY_ERROR;
+               goto cleanup;
+       }
+
+       /* convert certA_list to gnutls_cert* list
+        */
+       for (i = 0; i < peer_certificate_list_size; i++) {
+               ret = gnutls_x509_crt_init( &peer_certificate_list[i]);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+                               
+               ret =
+                    gnutls_x509_crt_import(peer_certificate_list[i],
+                                            &cert_list[i], GNUTLS_X509_FMT_DER);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+       }
+
+       /* convert CA_list to gnutls_x509_cert* list
+        */
+       for (i = 0; i < ca_certificate_list_size; i++) {
+               ret = gnutls_x509_crt_init(&ca_certificate_list[i]);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+
+               ret =
+                    gnutls_x509_crt_import(ca_certificate_list[i],
+                                        &CA_list[i], GNUTLS_X509_FMT_DER);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+       }
+
+#ifdef ENABLE_PKI
+       /* convert CRL_list to gnutls_x509_crl* list
+        */
+       for (i = 0; i < crl_list_size; i++) {
+               ret = gnutls_x509_crl_init( &crl_list[i]);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+
+               ret =
+                    gnutls_x509_crl_import(crl_list[i],
+                                        &CRL_list[i], GNUTLS_X509_FMT_DER);
+               if (ret < 0) {
+                       gnutls_assert();
+                       goto cleanup;
+               }
+       }
+#endif
+
+       /* Verify certificate 
+        */
+       ret =
+           gnutls_x509_crt_list_verify(peer_certificate_list,
+                                     peer_certificate_list_size,
+                                     ca_certificate_list, ca_certificate_list_size, 
+                                     crl_list, crl_list_size, 0, &verify);
+
+       if (ret < 0) {
+               gnutls_assert();
+               goto cleanup;
+       }
+       
+       ret = verify;
+
+       cleanup:
+
+       if (peer_certificate_list != NULL)
+               for(x=0;x<peer_certificate_list_size;x++) {
+                       if (peer_certificate_list[x] != NULL)
+                               gnutls_x509_crt_deinit(peer_certificate_list[x]);
+               }
+
+       if (ca_certificate_list != NULL)
+               for(x=0;x<ca_certificate_list_size;x++) {
+                       if (ca_certificate_list[x] !=  NULL)
+                               gnutls_x509_crt_deinit(ca_certificate_list[x]);
+               }
+
+#ifdef ENABLE_PKI
+       if (crl_list != NULL)
+               for(x=0;x<crl_list_size;x++) {
+                       if (crl_list[x] != NULL)
+                               gnutls_x509_crl_deinit(crl_list[x]);
+               }
+       
+       gnutls_free( crl_list);
+#endif
+
+       gnutls_free( ca_certificate_list);
+       gnutls_free( peer_certificate_list);
+
+       return ret;
+}
+
+/**
+  * gnutls_x509_extract_key_pk_algorithm - This function returns the keys's PublicKey algorithm
+  * @cert: is a DER encoded private key
+  *
+  * This function will return the public key algorithm of a DER encoded private
+  * key.
+  *
+  * Returns a member of the gnutls_pk_algorithm enumeration on success,
+  * or GNUTLS_E_UNKNOWN_PK_ALGORITHM on error.
+  *
+  **/
+int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key)
+{
+       gnutls_x509_privkey pkey;
+       int ret, pk;
+       
+       ret = gnutls_x509_privkey_init( &pkey);
+       if (ret < 0) {
+               gnutls_assert();
+               return ret;
+       }
+       
+       ret = gnutls_x509_privkey_import( pkey, key, GNUTLS_X509_FMT_DER);
+       if (ret < 0) {
+               gnutls_assert();
+               return ret;
+       }
+
+       pk = gnutls_x509_privkey_get_pk_algorithm( pkey);
+       
+       gnutls_x509_privkey_deinit( pkey);
+       return pk;
+}
+
+#ifdef ENABLE_PKI
+
+/**
+  * gnutls_x509_pkcs7_extract_certificate - This function returns a certificate in a PKCS7 certificate set
+  * @pkcs7_struct: should contain a PKCS7 DER formatted structure
+  * @indx: contains the index of the certificate to extract
+  * @certificate: the contents of the certificate will be copied there
+  * @certificate_size: should hold the size of the certificate
+  *
+  * This function will return a certificate of the PKCS7 or RFC2630 certificate set.
+  * Returns 0 on success. If the provided buffer is not long enough,
+  * then GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
+  *
+  * After the last certificate has been read GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
+  * will be returned.
+  *
+  **/
+int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size)
+{
+       gnutls_pkcs7 pkcs7;
+       int result;
+       size_t size = *certificate_size;
+
+       result = gnutls_pkcs7_init( &pkcs7);
+       if (result < 0) return result;
+       
+       result = gnutls_pkcs7_import( pkcs7, pkcs7_struct, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_pkcs7_deinit( pkcs7);
+               return result;
+       }
+       
+       result = gnutls_pkcs7_get_crt_raw( pkcs7, indx, certificate, &size);
+       *certificate_size = size;
+
+       gnutls_pkcs7_deinit( pkcs7);
+       
+       return result;
+}
+
+
+/**
+  * gnutls_x509_pkcs7_extract_certificate_count - This function returns the number of certificates in a PKCS7 certificate set
+  * @pkcs7_struct: should contain a PKCS7 DER formatted structure
+  *
+  * This function will return the number of certifcates in the PKCS7 or 
+  * RFC2630 certificate set.
+  *
+  * Returns a negative value on failure.
+  *
+  **/
+int gnutls_x509_pkcs7_extract_certificate_count(const gnutls_datum * pkcs7_struct)
+{
+       gnutls_pkcs7 pkcs7;
+       int result;
+
+       result = gnutls_pkcs7_init( &pkcs7);
+       if (result < 0) return result;
+       
+       result = gnutls_pkcs7_import( pkcs7, pkcs7_struct, GNUTLS_X509_FMT_DER);
+       if (result < 0) {
+               gnutls_pkcs7_deinit( pkcs7);
+               return result;
+       }
+       
+       result = gnutls_pkcs7_get_crt_count( pkcs7);
+       
+       gnutls_pkcs7_deinit( pkcs7);
+       
+       return result;
+}
+
+#endif
similarity index 50%
rename from includes/gnutls/compat8.h
rename to libextra/openssl_compat.h
index 23e2b37b303931386025988003d1d3ee098cee04..aa9f931c54c293f94b1c2a1176d1ccfadc28d35d 100644 (file)
@@ -2,71 +2,31 @@
 # define GNUTLS_COMPAT8_H
 
 /* Extra definitions */
+#include <gnutls/openssl.h>
 
-#define GNUTLS_X509_CN_SIZE 256
-#define GNUTLS_X509_C_SIZE 3
-#define GNUTLS_X509_O_SIZE 256
-#define GNUTLS_X509_OU_SIZE 256
-#define GNUTLS_X509_L_SIZE 256
-#define GNUTLS_X509_S_SIZE 256
-#define GNUTLS_X509_EMAIL_SIZE 256
-
-#ifdef __GNUC__
-
-#define _GT_GCC_VERSION (__GNUC__ * 10000 \
-                             + __GNUC_MINOR__ * 100 \
-                             + __GNUC_PATCHLEVEL__)
-
-#if _GT_GCC_VERSION >= 30100
-# ifndef DEPRECATED
-#  define DEPRECATED __attribute__ ((__deprecated__))
-# endif
-#endif
-
-#endif
-
-#ifndef DEPRECATED
-# define DEPRECATED
-#endif
-
-typedef struct {
-       char common_name[GNUTLS_X509_CN_SIZE];
-       char country[GNUTLS_X509_C_SIZE];
-       char organization[GNUTLS_X509_O_SIZE];
-       char organizational_unit_name[GNUTLS_X509_OU_SIZE];
-       char locality_name[GNUTLS_X509_L_SIZE];
-       char state_or_province_name[GNUTLS_X509_S_SIZE];
-       char email[GNUTLS_X509_EMAIL_SIZE];
-} gnutls_x509_dn;
-
-typedef struct {
-       char name[GNUTLS_X509_CN_SIZE];
-       char email[GNUTLS_X509_CN_SIZE];
-} gnutls_openpgp_name;
-
-int gnutls_x509_extract_dn( const gnutls_datum*, gnutls_x509_dn*) DEPRECATED;
+int gnutls_x509_extract_dn( const gnutls_datum*, gnutls_x509_dn*);
 int gnutls_x509_extract_dn_string(const gnutls_datum * idn,
-        char *buf, unsigned int sizeof_buf) DEPRECATED;
-int gnutls_x509_extract_certificate_dn( const gnutls_datum*, gnutls_x509_dn*) DEPRECATED;
+        char *buf, unsigned int sizeof_buf);
+int gnutls_x509_extract_certificate_dn( const gnutls_datum*, gnutls_x509_dn*);
 int gnutls_x509_extract_certificate_dn_string(char *buf, unsigned int sizeof_buf,
-   const gnutls_datum * cert, int issuer) DEPRECATED;
-int gnutls_x509_extract_certificate_issuer_dn(  const gnutls_datum*, gnutls_x509_dn *) DEPRECATED;
-int gnutls_x509_extract_certificate_version( const gnutls_datum*) DEPRECATED;
-int gnutls_x509_extract_certificate_serial(const gnutls_datum * cert, char* result, int* result_size) DEPRECATED;
+   const gnutls_datum * cert, int issuer);
+int gnutls_x509_extract_certificate_issuer_dn(  const gnutls_datum*, gnutls_x509_dn *);
+int gnutls_x509_extract_certificate_version( const gnutls_datum*);
+int gnutls_x509_extract_certificate_serial(const gnutls_datum * cert, char* result, int* result_size);
 time_t gnutls_x509_extract_certificate_activation_time( const gnutls_datum*);
 time_t gnutls_x509_extract_certificate_expiration_time( const gnutls_datum*);
-int gnutls_x509_extract_certificate_subject_alt_name( const gnutls_datum*, int seq, char*, int*) DEPRECATED;
-int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size) DEPRECATED;
-int gnutls_x509_extract_certificate_pk_algorithm( const gnutls_datum * cert, int* bits) DEPRECATED;
-int gnutls_x509_extract_certificate_ca_status(const gnutls_datum * cert) DEPRECATED;
-int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key) DEPRECATED;
+int gnutls_x509_extract_certificate_subject_alt_name( const gnutls_datum*, int seq, char*, int*);
+int gnutls_x509_pkcs7_extract_certificate(const gnutls_datum * pkcs7_struct, int indx, char* certificate, int* certificate_size);
+int gnutls_x509_extract_certificate_pk_algorithm( const gnutls_datum * cert, int* bits);
+int gnutls_x509_extract_certificate_ca_status(const gnutls_datum * cert);
+int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key);
 
-int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list_length, const gnutls_datum * CA_list, int CA_list_length, const gnutls_datum* CRL_list, int CRL_list_length) DEPRECATED;
+int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list_length, const gnutls_datum * CA_list, int CA_list_length, const gnutls_datum* CRL_list, int CRL_list_length);
 
 #define gnutls_x509_fingerprint gnutls_fingerprint
 #define gnutls_x509_certificate_format gnutls_x509_crt_fmt
 
-int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key) DEPRECATED;
+int gnutls_x509_extract_key_pk_algorithm( const gnutls_datum * key);
 
 #define gnutls_certificate_set_rsa_params gnutls_certificate_set_rsa_export_params
 
index 7ec736b7b06e0881060c78fd39e2a08b578206eb..ff62cddee2d3e25cdffddaab851beb847b9e785f 100644 (file)
@@ -137,6 +137,7 @@ void gaa_help(void)
        __gaa_helpsingle('p', "generate-privkey", "", "Generate a private key.");
        __gaa_helpsingle('q', "generate-request", "", "Generate a PKCS #10 certificate request.");
        __gaa_helpsingle('e', "verify-chain", "", "Verify a PEM encoded certificate chain. The last certificate in the chain must be a self signed one.");
+       __gaa_helpsingle(0, "verify-crl", "", "Verify a CRL.");
        __gaa_helpsingle(0, "generate-dh-params", "", "Generate PKCS #3 encoded Diffie Hellman parameters.");
        __gaa_helpsingle(0, "load-privkey", "FILE ", "Private key file to use.");
        __gaa_helpsingle(0, "load-request", "FILE ", "Certificate request file to use.");
@@ -176,35 +177,35 @@ typedef struct _gaainfo gaainfo;
 
 struct _gaainfo
 {
-#line 88 "certtool.gaa"
+#line 90 "certtool.gaa"
        int debug;
-#line 85 "certtool.gaa"
+#line 87 "certtool.gaa"
        char *infile;
-#line 82 "certtool.gaa"
+#line 84 "certtool.gaa"
        char *outfile;
-#line 79 "certtool.gaa"
+#line 81 "certtool.gaa"
        int bits;
-#line 76 "certtool.gaa"
+#line 78 "certtool.gaa"
        int outcert_format;
-#line 73 "certtool.gaa"
+#line 75 "certtool.gaa"
        int incert_format;
-#line 70 "certtool.gaa"
+#line 72 "certtool.gaa"
        int export;
-#line 67 "certtool.gaa"
+#line 69 "certtool.gaa"
        int dsa;
-#line 64 "certtool.gaa"
+#line 66 "certtool.gaa"
        int pkcs8;
-#line 49 "certtool.gaa"
+#line 51 "certtool.gaa"
        char *pass;
-#line 46 "certtool.gaa"
+#line 48 "certtool.gaa"
        char *ca;
-#line 43 "certtool.gaa"
+#line 45 "certtool.gaa"
        char *ca_privkey;
-#line 40 "certtool.gaa"
+#line 42 "certtool.gaa"
        char *cert;
-#line 37 "certtool.gaa"
+#line 39 "certtool.gaa"
        char *request;
-#line 34 "certtool.gaa"
+#line 36 "certtool.gaa"
        char *privkey;
 #line 17 "certtool.gaa"
        int action;
@@ -262,7 +263,7 @@ int gaa_error = 0;
 #define GAA_MULTIPLE_OPTION     3
 
 #define GAA_REST                0
-#define GAA_NB_OPTION           32
+#define GAA_NB_OPTION           33
 #define GAAOPTID_copyright     1
 #define GAAOPTID_version       2
 #define GAAOPTID_help  3
@@ -288,13 +289,14 @@ int gaa_error = 0;
 #define GAAOPTID_load_request  23
 #define GAAOPTID_load_privkey  24
 #define GAAOPTID_generate_dh_params    25
-#define GAAOPTID_verify_chain  26
-#define GAAOPTID_generate_request      27
-#define GAAOPTID_generate_privkey      28
-#define GAAOPTID_update_certificate    29
-#define GAAOPTID_generate_crl  30
-#define GAAOPTID_generate_certificate  31
-#define GAAOPTID_generate_self_signed  32
+#define GAAOPTID_verify_crl    26
+#define GAAOPTID_verify_chain  27
+#define GAAOPTID_generate_request      28
+#define GAAOPTID_generate_privkey      29
+#define GAAOPTID_update_certificate    30
+#define GAAOPTID_generate_crl  31
+#define GAAOPTID_generate_certificate  32
+#define GAAOPTID_generate_self_signed  33
 
 #line 168 "gaa.skel"
 
@@ -597,6 +599,7 @@ int gaa_get_option_num(char *str, int status)
                        GAA_CHECK1STR("l", GAAOPTID_crl_info);
                        GAA_CHECK1STR("i", GAAOPTID_certificate_info);
                        GAA_CHECK1STR("", GAAOPTID_generate_dh_params);
+                       GAA_CHECK1STR("", GAAOPTID_verify_crl);
                        GAA_CHECK1STR("e", GAAOPTID_verify_chain);
                        GAA_CHECK1STR("q", GAAOPTID_generate_request);
                        GAA_CHECK1STR("p", GAAOPTID_generate_privkey);
@@ -633,6 +636,7 @@ int gaa_get_option_num(char *str, int status)
                        GAA_CHECKSTR("load-request", GAAOPTID_load_request);
                        GAA_CHECKSTR("load-privkey", GAAOPTID_load_privkey);
                        GAA_CHECKSTR("generate-dh-params", GAAOPTID_generate_dh_params);
+                       GAA_CHECKSTR("verify-crl", GAAOPTID_verify_crl);
                        GAA_CHECKSTR("verify-chain", GAAOPTID_verify_chain);
                        GAA_CHECKSTR("generate-request", GAAOPTID_generate_request);
                        GAA_CHECKSTR("generate-privkey", GAAOPTID_generate_privkey);
@@ -684,21 +688,21 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
     {
        case GAAOPTID_copyright:
        OK = 0;
-#line 94 "certtool.gaa"
+#line 96 "certtool.gaa"
 { print_license(); exit(0); ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_version:
        OK = 0;
-#line 93 "certtool.gaa"
+#line 95 "certtool.gaa"
 { certtool_version(); exit(0); ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_help:
        OK = 0;
-#line 91 "certtool.gaa"
+#line 93 "certtool.gaa"
 { gaa_help(); exit(0); ;};
 
                return GAA_OK;
@@ -708,7 +712,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_debug.arg1, gaa_getint, GAATMP_debug.size1);
                gaa_index++;
-#line 89 "certtool.gaa"
+#line 91 "certtool.gaa"
 { gaaval->debug = GAATMP_debug.arg1 ;};
 
                return GAA_OK;
@@ -718,7 +722,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_infile.arg1, gaa_getstr, GAATMP_infile.size1);
                gaa_index++;
-#line 86 "certtool.gaa"
+#line 88 "certtool.gaa"
 { gaaval->infile = GAATMP_infile.arg1 ;};
 
                return GAA_OK;
@@ -728,7 +732,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_outfile.arg1, gaa_getstr, GAATMP_outfile.size1);
                gaa_index++;
-#line 83 "certtool.gaa"
+#line 85 "certtool.gaa"
 { gaaval->outfile = GAATMP_outfile.arg1 ;};
 
                return GAA_OK;
@@ -738,84 +742,84 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_bits.arg1, gaa_getint, GAATMP_bits.size1);
                gaa_index++;
-#line 80 "certtool.gaa"
+#line 82 "certtool.gaa"
 { gaaval->bits = GAATMP_bits.arg1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_outder:
        OK = 0;
-#line 77 "certtool.gaa"
+#line 79 "certtool.gaa"
 { gaaval->outcert_format=1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_inder:
        OK = 0;
-#line 74 "certtool.gaa"
+#line 76 "certtool.gaa"
 { gaaval->incert_format=1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_export_ciphers:
        OK = 0;
-#line 71 "certtool.gaa"
+#line 73 "certtool.gaa"
 { gaaval->export=1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_dsa:
        OK = 0;
-#line 68 "certtool.gaa"
+#line 70 "certtool.gaa"
 { gaaval->dsa=1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_pkcs8:
        OK = 0;
-#line 65 "certtool.gaa"
+#line 67 "certtool.gaa"
 { gaaval->pkcs8=1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_to_p12:
        OK = 0;
-#line 62 "certtool.gaa"
+#line 64 "certtool.gaa"
 { gaaval->action = 8; ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_key_info:
        OK = 0;
-#line 60 "certtool.gaa"
+#line 62 "certtool.gaa"
 { gaaval->action = 6; ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_p7_info:
        OK = 0;
-#line 58 "certtool.gaa"
+#line 60 "certtool.gaa"
 { gaaval->action = 12; ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_p12_info:
        OK = 0;
-#line 56 "certtool.gaa"
+#line 58 "certtool.gaa"
 { gaaval->action = 9; ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_crl_info:
        OK = 0;
-#line 54 "certtool.gaa"
+#line 56 "certtool.gaa"
 { gaaval->action = 11; ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_certificate_info:
        OK = 0;
-#line 52 "certtool.gaa"
+#line 54 "certtool.gaa"
 { gaaval->action = 2; ;};
 
                return GAA_OK;
@@ -825,7 +829,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_password.arg1, gaa_getstr, GAATMP_password.size1);
                gaa_index++;
-#line 50 "certtool.gaa"
+#line 52 "certtool.gaa"
 { gaaval->pass = GAATMP_password.arg1 ;};
 
                return GAA_OK;
@@ -835,7 +839,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_load_ca_certificate.arg1, gaa_getstr, GAATMP_load_ca_certificate.size1);
                gaa_index++;
-#line 47 "certtool.gaa"
+#line 49 "certtool.gaa"
 { gaaval->ca = GAATMP_load_ca_certificate.arg1 ;};
 
                return GAA_OK;
@@ -845,7 +849,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_load_ca_privkey.arg1, gaa_getstr, GAATMP_load_ca_privkey.size1);
                gaa_index++;
-#line 44 "certtool.gaa"
+#line 46 "certtool.gaa"
 { gaaval->ca_privkey = GAATMP_load_ca_privkey.arg1 ;};
 
                return GAA_OK;
@@ -855,7 +859,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_load_certificate.arg1, gaa_getstr, GAATMP_load_certificate.size1);
                gaa_index++;
-#line 41 "certtool.gaa"
+#line 43 "certtool.gaa"
 { gaaval->cert = GAATMP_load_certificate.arg1 ;};
 
                return GAA_OK;
@@ -865,7 +869,7 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_load_request.arg1, gaa_getstr, GAATMP_load_request.size1);
                gaa_index++;
-#line 38 "certtool.gaa"
+#line 40 "certtool.gaa"
 { gaaval->request = GAATMP_load_request.arg1 ;};
 
                return GAA_OK;
@@ -875,16 +879,23 @@ int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
                GAA_TESTMOREARGS;
                GAA_FILL(GAATMP_load_privkey.arg1, gaa_getstr, GAATMP_load_privkey.size1);
                gaa_index++;
-#line 35 "certtool.gaa"
+#line 37 "certtool.gaa"
 { gaaval->privkey = GAATMP_load_privkey.arg1 ;};
 
                return GAA_OK;
                break;
        case GAAOPTID_generate_dh_params:
        OK = 0;
-#line 32 "certtool.gaa"
+#line 34 "certtool.gaa"
 { gaaval->action=10; ;};
 
+               return GAA_OK;
+               break;
+       case GAAOPTID_verify_crl:
+       OK = 0;
+#line 32 "certtool.gaa"
+{ gaaval->action=14; ;};
+
                return GAA_OK;
                break;
        case GAAOPTID_verify_chain:
@@ -960,7 +971,7 @@ int gaa(int argc, char **argv, gaainfo *gaaval)
     if(inited == 0)
     {
 
-#line 96 "certtool.gaa"
+#line 98 "certtool.gaa"
 { gaaval->bits = 1024; gaaval->pkcs8 = 0; gaaval->privkey = NULL; gaaval->ca=NULL; gaaval->ca_privkey = NULL; 
        gaaval->debug=1; gaaval->request = NULL; gaaval->infile = NULL; gaaval->outfile = NULL; gaaval->cert = NULL; 
        gaaval->incert_format = 0; gaaval->outcert_format = 0; gaaval->action=-1; gaaval->pass = NULL; 
index 18cca0ca96d5e127181f0d235e9f87aa50cf5fc2..2bef4af05b9ba569dea353921a39d108494b3470 100644 (file)
@@ -8,35 +8,35 @@ typedef struct _gaainfo gaainfo;
 
 struct _gaainfo
 {
-#line 88 "certtool.gaa"
+#line 90 "certtool.gaa"
        int debug;
-#line 85 "certtool.gaa"
+#line 87 "certtool.gaa"
        char *infile;
-#line 82 "certtool.gaa"
+#line 84 "certtool.gaa"
        char *outfile;
-#line 79 "certtool.gaa"
+#line 81 "certtool.gaa"
        int bits;
-#line 76 "certtool.gaa"
+#line 78 "certtool.gaa"
        int outcert_format;
-#line 73 "certtool.gaa"
+#line 75 "certtool.gaa"
        int incert_format;
-#line 70 "certtool.gaa"
+#line 72 "certtool.gaa"
        int export;
-#line 67 "certtool.gaa"
+#line 69 "certtool.gaa"
        int dsa;
-#line 64 "certtool.gaa"
+#line 66 "certtool.gaa"
        int pkcs8;
-#line 49 "certtool.gaa"
+#line 51 "certtool.gaa"
        char *pass;
-#line 46 "certtool.gaa"
+#line 48 "certtool.gaa"
        char *ca;
-#line 43 "certtool.gaa"
+#line 45 "certtool.gaa"
        char *ca_privkey;
-#line 40 "certtool.gaa"
+#line 42 "certtool.gaa"
        char *cert;
-#line 37 "certtool.gaa"
+#line 39 "certtool.gaa"
        char *request;
-#line 34 "certtool.gaa"
+#line 36 "certtool.gaa"
        char *privkey;
 #line 17 "certtool.gaa"
        int action;
index 0d62ed2f12be574af2bdac82dc0040c256adcfa7..d587806454fae55f8dc5f08c53e44d7f9c6c558f 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
@@ -38,6 +39,7 @@ void pkcs7_info( void);
 void pkcs12_info( void);
 void generate_pkcs12( void);
 void verify_chain(void);
+void verify_crl(void);
 gnutls_x509_privkey load_private_key(int mand);
 gnutls_x509_crq load_request(void);
 gnutls_x509_privkey load_ca_private_key(void);
@@ -772,6 +774,9 @@ int ret;
                case 13:
                        generate_signed_crl();
                        break;
+               case 14:
+                       verify_crl();
+                       break;
                default:
                        fprintf(stderr, "GnuTLS' certtool utility.\n");
                        fprintf(stderr, "Please use the --help to get help on this program.\n");
@@ -1114,6 +1119,7 @@ static void print_crl_info( gnutls_x509_crl crl, FILE* out, int all)
        char *print, dn[256];
        const char* cprint;
 
+       fprintf(out, "CRL information:\n");
        fprintf(out, "Version: %d\n", gnutls_x509_crl_get_version(crl));
 
        /* Issuer
@@ -1475,7 +1481,8 @@ static gnutls_x509_crt crt[MAX_CERTS];
 char* ptr;
 int ret, i;
 gnutls_datum dat;
-size_t size, ptr_size;
+size_t size;
+int ptr_size;
 
        *crt_size = 0;
        fprintf(stderr, "Loading certificate list...\n");
@@ -1522,7 +1529,9 @@ size_t size, ptr_size;
                ptr++;
 
                ptr_size = size;
-               ptr_size -= ((void*)ptr - (void*)buffer);
+               ptr_size -= (unsigned int)((unsigned char*)ptr - (unsigned char*)buffer);
+               
+               if (ptr_size < 0) break;
 
                (*crt_size)++;
        }
@@ -1872,8 +1881,6 @@ time_t now = time(0);
                comma = 1;
                fprintf(outfile, "Revoked");
        }
-       
-
 }
 
 void verify_chain( void)
@@ -1881,11 +1888,89 @@ void verify_chain( void)
 size_t size;
 
        size = fread( buffer, 1, sizeof(buffer)-1, infile);
+       buffer[size] = 0;
 
        _verify_x509_mem( buffer, size);
        
 }
 
+void verify_crl( void)
+{
+size_t size, dn_size;
+char dn[128];
+unsigned int output;
+int comma=0;
+int ret;
+gnutls_datum pem;
+gnutls_x509_crl crl;
+time_t now = time(0);
+gnutls_x509_crt issuer;
+
+       issuer = load_ca_cert();
+
+       fprintf(outfile, "\nCA certificate:\n");
+       dn_size = sizeof(dn);
+       ret = gnutls_x509_crt_get_dn(issuer, dn, &dn_size);
+       if (ret >= 0)
+               fprintf(outfile, "\tSubject: %s\n\n", dn);
+
+       size = fread( buffer, 1, sizeof(buffer)-1, infile);
+       buffer[size] = 0;
+
+       pem.data = buffer;
+       pem.size = size;
+
+       gnutls_x509_crl_init( &crl);
+
+       ret = gnutls_x509_crl_import(crl, &pem, in_cert_format);
+       if (ret < 0) {
+               fprintf(stderr, "CRL decoding error: %s\n", gnutls_strerror(ret));
+               exit(1);
+       }
+
+       print_crl_info( crl, outfile, 1);
+
+
+       fprintf(outfile, "Verification output: ");
+       ret = gnutls_x509_crl_verify( crl, &issuer, 1, 0, &output);
+       if (ret < 0) {
+               fprintf(stderr, "Error in verification: %s\n", gnutls_strerror(ret));
+               exit(1);
+       }
+
+       if (output&GNUTLS_CERT_NOT_TRUSTED) {
+               fprintf(outfile, "Not verified");
+               comma = 1;
+       } else {
+               fprintf(outfile, "Verified");
+               comma = 1;
+       }
+
+       if (output&GNUTLS_CERT_SIGNER_NOT_CA) {
+               if (comma) fprintf(outfile, ", ");
+               fprintf(outfile, "Issuer is not a CA");
+               comma = 1;
+       }
+
+       /* Check expiration dates.
+        */
+       
+       if (gnutls_x509_crl_get_this_update(crl) > now) {
+               if (comma) fprintf(outfile, ", ");
+               comma = 1;
+               fprintf(outfile, "Issued in the future!");
+       }
+       
+       if (gnutls_x509_crl_get_next_update(crl) < now) {
+               if (comma) fprintf(outfile, ", ");
+               comma = 1;
+               fprintf(outfile, "CRL is not up to date");
+       }
+       
+       fprintf(outfile, "\n");
+       
+}
+
 #include <gnutls/pkcs12.h>
 #include <unistd.h>
 
index 5418c66f8c33322822a1d144dea3e64102310bcf..9fb257e93f13e1a468747d547fb3990897f02c84 100644 (file)
@@ -29,6 +29,8 @@ option (q, generate-request) { $action=3; } "Generate a PKCS #10 certificate req
 
 option (e, verify-chain) { $action=5; } "Verify a PEM encoded certificate chain. The last certificate in the chain must be a self signed one."
 
+option (verify-crl) { $action=14; } "Verify a CRL."
+
 option (generate-dh-params) { $action=10; } "Generate PKCS #3 encoded Diffie Hellman parameters."
 
 #char *privkey;
index e9a2137fcb04f7e74e35079fbc172fbd3ea40ee3..d4a676c89407f94bb92403c420000cf2c62576a6 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 893804f3380c27b3205434366d95ffc8633a9e44..9fefb5d643634f7c68a9d20db37cc2d385a35d64 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 72edcdf85c7acabfec7d88f882dcc25eea4e85c0..afa45811092e4ce91581726d1d1125139c431402 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index bd43904a7442a4aadfbe4b014ee5e2cd672f9800..561e47664bf716d52b206b3e40232b6b8089c355 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2001,2002 Paul Sheer
  * Portions Copyright (C) 2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index eba1297aabd06c5f0e4701e41572ebc64762d4e3..74060bc69b8fd6b60d52f8b721d9239bbec3f59b 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *
index 83cf5eefad5d61d9e2fc4a1ff6c7f72601540840..bf7691b6186d3f9320b36b6341631868417d5b15 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2000,2001,2002,2003 Nikos Mavroyanopoulos
+ * Copyright (C) 2004 Free Software Foundation
  *
  * This file is part of GNUTLS.
  *