[xmlsec] define and export xmlSecCryptoAppKeyLoadMemory()

Bernd Becker bb at bernd-becker.de
Wed Jun 16 12:22:12 PDT 2004


Hi,

I wanted to load a private key from a buffer instead of a file by using 
something
like xmlSecCryptoAppKeyLoadMemory() instead of xmlSecCryptoAppKeyLoad().
For this to work I defined the function xmlSecCryptoAppKeyLoadMemory()
(patch to include/xmlsec/app.h and src/app.c attached).
Is this the right thing to do or is there something I missed?

If this is the right way to go then the same would have to be done for some
other functions that read certs/keys from memory, e.g. as for openssl:
 xmlSecOpenSSLAppKeysMngrCertLoadMemory
 xmlSecOpenSSLAppPkcs12LoadMemory
 xmlSecOpenSSLAppKeyCertLoadMemory


Regards,
Bernd

-- 
Bernd Becker
-------------- next part --------------
--- xmlsec1-1.2.5.org/include/xmlsec/app.h	2003-09-26 08:12:43.000000000 +0200
+++ xmlsec1-1.2.5/include/xmlsec/app.h	2004-06-16 15:23:27.000000000 +0200
@@ -256,6 +256,12 @@
 										 const char *pwd,
 										 void* pwdCallback,
 										 void* pwdCallbackCtx);
+XMLSEC_EXPORT xmlSecKeyPtr			xmlSecCryptoAppKeyLoadMemory	(const xmlSecByte* data,
+										 xmlSecSize dataSize,
+										 xmlSecKeyDataFormat format,
+										 const char *pwd,
+										 void* pwdCallback,
+										 void* pwdCallbackCtx);
 XMLSEC_EXPORT xmlSecKeyPtr			xmlSecCryptoAppPkcs12Load	(const char* filename, 
 										 const char* pwd,
 										 void* pwdCallback, 
--- xmlsec1-1.2.5.org/src/app.c	2003-09-10 09:12:27.000000000 +0200
+++ xmlsec1-1.2.5/src/app.c	2004-06-16 15:22:38.000000000 +0200
@@ -894,6 +894,20 @@
     return(xmlSecCryptoDLGetFunctions()->cryptoAppKeyLoad(filename, format, pwd, pwdCallback, pwdCallbackCtx));
 }
 
+xmlSecKeyPtr 
+xmlSecCryptoAppKeyLoadMemory(const xmlSecByte* data, xmlSecSize dataSize, xmlSecKeyDataFormat format,
+		       const char *pwd, void* pwdCallback, void* pwdCallbackCtx) {
+    if((xmlSecCryptoDLGetFunctions() == NULL) || (xmlSecCryptoDLGetFunctions()->cryptoAppKeyLoadMemory == NULL)) {
+	xmlSecError(XMLSEC_ERRORS_HERE,
+		    NULL,
+		    "cryptoAppKeyLoadMemory",
+		    XMLSEC_ERRORS_R_NOT_IMPLEMENTED,
+		    XMLSEC_ERRORS_NO_MESSAGE);
+        return(NULL);
+    }
+    
+    return(xmlSecCryptoDLGetFunctions()->cryptoAppKeyLoadMemory(data, dataSize, format, pwd, pwdCallback, pwdCallbackCtx));
+}
 				
 /**
  * xmlSecCryptoAppPkcs12Load:


More information about the xmlsec mailing list