[xmlsec] support der private key for xmlsec-gnutls



commit 2e153b439ba6ffc39ec461fb263914e52a71bb89
Author: Aleksey Sanin <aleksey aleksey com>
Date:   Thu May 13 19:29:48 2010 -0700

    support der private key for xmlsec-gnutls

 TODO             |   12 ------------
 src/gnutls/app.c |   44 ++++++++++++++++----------------------------
 tests/testrun.sh |    4 ++--
 3 files changed, 18 insertions(+), 42 deletions(-)
---
diff --git a/TODO b/TODO
index 9041f84..98d7f4e 100644
--- a/TODO
+++ b/TODO
@@ -84,12 +84,6 @@ aleksey-xmldsig-01/enveloping-sha512-rsa-sha512
 aleksey-xmldsig-01/enveloping-expired-cert
 aleksey-xmldsig-01/x509data-test
 aleksey-xmldsig-01/x509data-sn-test
-merlin-xmldsig-twenty-three/signature-enveloped-dsa
-merlin-xmldsig-twenty-three/signature-enveloping-dsa
-merlin-xmldsig-twenty-three/signature-enveloping-b64-dsa
-merlin-xmldsig-twenty-three/signature-enveloping-rsa
-merlin-xmldsig-twenty-three/signature-external-b64-dsa
-merlin-xmldsig-twenty-three/signature-external-dsa
 merlin-xmldsig-twenty-three/signature-keyname
 merlin-xmldsig-twenty-three/signature-x509-crt
 merlin-xmldsig-twenty-three/signature-x509-sn
@@ -97,12 +91,6 @@ merlin-xmldsig-twenty-three/signature-x509-is
 merlin-xmldsig-twenty-three/signature-x509-ski
 merlin-xmldsig-twenty-three/signature-retrievalmethod-rawx509crt
 merlin-xmldsig-twenty-three/signature
-merlin-xmlenc-five/encsig-ripemd160-hmac-ripemd160-kw-tripledes
-merlin-exc-c14n-one/exc-signature
-merlin-exc-c14n-one/exc-signature
-merlin-c14n-three/signature
-merlin-xpath-filter2-three/sign-xfdl
-merlin-xpath-filter2-three/sign-spec
 phaos-xmldsig-three/signature-big
 phaos-xmldsig-three/signature-dsa-detached
 phaos-xmldsig-three/signature-dsa-enveloped
diff --git a/src/gnutls/app.c b/src/gnutls/app.c
index 264a489..d936b8a 100644
--- a/src/gnutls/app.c
+++ b/src/gnutls/app.c
@@ -20,6 +20,15 @@
 #include <xmlsec/gnutls/app.h>
 #include <xmlsec/gnutls/crypto.h>
 
+/**************************************************************************
+ *
+ * We use xmlsec-gcrypt for all the basic crypto ops
+ *
+ *****************************************************************************/
+#include <xmlsec/gcrypt/crypto.h>
+#include <xmlsec/gcrypt/app.h>
+
+
 /**
  * xmlSecGnuTLSAppInit:
  * @config:             the path to GnuTLS configuration (unused).
@@ -31,7 +40,7 @@
  * Returns: 0 on success or a negative value otherwise.
  */
 int
-xmlSecGnuTLSAppInit(const char* config ATTRIBUTE_UNUSED) {
+xmlSecGnuTLSAppInit(const char* config) {
     int ret;
 
     ret = gnutls_global_init();
@@ -43,7 +52,8 @@ xmlSecGnuTLSAppInit(const char* config ATTRIBUTE_UNUSED) {
                     "ret=%d", ret);
         return(-1);
     }
-    return(0);
+
+    return(xmlSecGCryptAppInit(config));
 }
 
 /**
@@ -58,7 +68,8 @@ xmlSecGnuTLSAppInit(const char* config ATTRIBUTE_UNUSED) {
 int
 xmlSecGnuTLSAppShutdown(void) {
     gnutls_global_deinit();
-    return(0);
+
+    return(xmlSecGCryptAppShutdown());
 }
 
 /**
@@ -81,19 +92,7 @@ xmlSecGnuTLSAppKeyLoad(const char *filename, xmlSecKeyDataFormat format,
     xmlSecAssert2(filename != NULL, NULL);
     xmlSecAssert2(format != xmlSecKeyDataFormatUnknown, NULL);
 
-
-    if (format == xmlSecKeyDataFormatPkcs12) {
-        return (xmlSecGnuTLSAppPkcs12Load(filename, pwd, pwdCallback,
-                                          pwdCallbackCtx));
-    }
-
-    /* TODO */
-    xmlSecError(XMLSEC_ERRORS_HERE,
-                NULL,
-                "xmlSecGnuTLSAppKeyLoad",
-                XMLSEC_ERRORS_R_NOT_IMPLEMENTED,
-                XMLSEC_ERRORS_NO_MESSAGE);
-    return(NULL);
+    return(xmlSecGCryptAppKeyLoad(filename, format, pwd, pwdCallback, pwdCallbackCtx));
 }
 
 /**
@@ -116,18 +115,7 @@ xmlSecGnuTLSAppKeyLoadMemory(const xmlSecByte* data, xmlSecSize dataSize,
     xmlSecAssert2(data != NULL, NULL);
     xmlSecAssert2(format != xmlSecKeyDataFormatUnknown, NULL);
 
-    if (format == xmlSecKeyDataFormatPkcs12) {
-        return (xmlSecGnuTLSAppPkcs12LoadMemory(data, dataSize, pwd,
-                                        pwdCallback, pwdCallbackCtx));
-    }
-
-    /* TODO */
-    xmlSecError(XMLSEC_ERRORS_HERE,
-                NULL,
-                "xmlSecGnuTLSAppKeyLoadMemory",
-                XMLSEC_ERRORS_R_NOT_IMPLEMENTED,
-                XMLSEC_ERRORS_NO_MESSAGE);
-    return(NULL);
+    return(xmlSecGCryptAppKeyLoadMemory(data, dataSize, format, pwd, pwdCallback, pwdCallbackCtx));
 }
 
 #ifndef XMLSEC_NO_X509
diff --git a/tests/testrun.sh b/tests/testrun.sh
index 503f271..846caf9 100755
--- a/tests/testrun.sh
+++ b/tests/testrun.sh
@@ -64,9 +64,9 @@ pub_key_format=$file_format
 cert_format=$file_format
 
 #
-# GCrypt only supports DER format for now, others are good to go with PKCS12
+# GCrypt/GnuTLS only supports DER format for now, others are good to go with PKCS12
 #
-if [ "z$crypto" != "zgcrypt" ] ; then
+if [ "z$crypto" != "zgcrypt" -a "z$crypto" != "zgnutls" ] ; then
     priv_key_option="--pkcs12"
     priv_key_format="p12"
 else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]