[xmlsec] define and export xmlSecCryptoAppKeyLoadMemory()

Bernd Becker bb at bernd-becker.de
Fri Jun 25 07:16:22 PDT 2004


Hi,

I finally added the LoadMemory functions to app.h and app.c. Most of the 
corresponding
xmlSec<crypto>AppXXLoadMemory functions were already there in
include/<crypto>/symbols.h and include/<crypto>/app.h and 
src/<crypto>/app.c.
Only in gnutls and skeleton some were missing in app.c and or app.h.
The patch adds all these (as unimplemented).

If I understand correctly, the docs (sgml and html) are generated from the 
source,
so nothing to be changed there (?).

I also changed 3 calls to xmlSecError where the third parameter was 
referring
to some "...AppPemLoad" function.

I have compiled with openssl and gnutls.

Let me know if something is missing.

Thanks,
Bernd

--On Wednesday, June 16, 2004 14:26:22 -0700 Aleksey Sanin 
<aleksey at aleksey.com> wrote:

> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: loadmem.diff.gz
Type: application/x-gunzip
Size: 2268 bytes
Desc: not available
Url : http://www.aleksey.com/pipermail/xmlsec/attachments/20040625/75c0be67/loadmem.diff-0002.bin


More information about the xmlsec mailing list