[xmlsec] define and export xmlSecCryptoAppKeyLoadMemory()
Aleksey Sanin
aleksey at aleksey.com
Wed Jun 16 14:26:22 PDT 2004
Hi, Bernd!
This is defenetly correct however there are a couple more things
that needs to be done here:
0) Every function needs to be documented :)
1) The needs to be a define in <crypto>/symbols.h file for the
new function. This is required because xmlsec-<crypto> libraries
can be linked directly to the appliaction and not loaded dynamicaly.
For example, "xmlSecCryptoAppPkcs12LoadMemory" is defined as follows
(I added few \n's to the grep output):
[xmlsec-tip]$ grep -r xmlSecCryptoAppPkcs12LoadMemory include/
include/xmlsec/gnutls/symbols.h:
#define xmlSecCryptoAppPkcs12LoadMemory
xmlSecGnuTLSAppPkcs12LoadMemory
include/xmlsec/mscrypto/symbols.h:
#define xmlSecCryptoAppPkcs12LoadMemory
xmlSecMSCryptoAppPkcs12LoadMemory
include/xmlsec/nss/symbols.h:
#define xmlSecCryptoAppPkcs12LoadMemory
xmlSecNssAppPkcs12LoadMemory
include/xmlsec/openssl/symbols.h:
#define xmlSecCryptoAppPkcs12LoadMemory
xmlSecOpenSSLAppPkcs12LoadMemory
include/xmlsec/skeleton/symbols.h:
#define xmlSecCryptoAppPkcs12LoadMemory
xmlSecSkeletonAppPkcs12LoadMemory
And from your permission, I would be glad to apply your patch
when you'll have it :)
Best,
Aleksey
Bernd Becker wrote:
> 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
>
>
> ------------------------------------------------------------------------
>
> --- 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:
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> xmlsec mailing list
> xmlsec at aleksey.com
> http://www.aleksey.com/mailman/listinfo/xmlsec
More information about the xmlsec
mailing list