You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2006/02/19 12:30:26 UTC

svn commit: r378876 - in /xml/security/trunk/c/src/enc: XSECCryptoUtils.cpp XSECCryptoUtils.hpp

Author: blautenb
Date: Sun Feb 19 03:30:21 2006
New Revision: 378876

URL: http://svn.apache.org/viewcvs?rev=378876&view=rev
Log:
Add utility functions to decode base64 buffers

Modified:
    xml/security/trunk/c/src/enc/XSECCryptoUtils.cpp
    xml/security/trunk/c/src/enc/XSECCryptoUtils.hpp

Modified: xml/security/trunk/c/src/enc/XSECCryptoUtils.cpp
URL: http://svn.apache.org/viewcvs/xml/security/trunk/c/src/enc/XSECCryptoUtils.cpp?rev=378876&r1=378875&r2=378876&view=diff
==============================================================================
--- xml/security/trunk/c/src/enc/XSECCryptoUtils.cpp (original)
+++ xml/security/trunk/c/src/enc/XSECCryptoUtils.cpp Sun Feb 19 03:30:21 2006
@@ -180,6 +180,33 @@
 
 }
 
+unsigned int DSIG_EXPORT DecodeFromBase64XMLCh(const XMLCh * input, unsigned char * output, int maxOutputLen) {
+
+	XSECCryptoBase64 * b64 = XSECPlatformUtils::g_cryptoProvider->base64();
+	Janitor<XSECCryptoBase64> j_b64(b64);
+
+	char * tinput = XMLString::transcode(input);
+	ArrayJanitor<char> j_tinput(tinput);
+
+	b64->decodeInit();
+	unsigned int j = b64->decode((unsigned char *) tinput, strlen(tinput), output, maxOutputLen - 1);
+	j += b64->encodeFinish(&output[j], maxOutputLen - j - 1);
+
+	return j;
+}
+
+unsigned int DSIG_EXPORT DecodeFromBase64(const char * input, unsigned char * output, int maxOutputLen) {
+
+	XSECCryptoBase64 * b64 = XSECPlatformUtils::g_cryptoProvider->base64();
+	Janitor<XSECCryptoBase64> j_b64(b64);
+
+	b64->decodeInit();
+	unsigned int j = b64->decode((unsigned char *) input, strlen(input), output, maxOutputLen - 1);
+	j += b64->encodeFinish(&output[j], maxOutputLen - j - 1);
+
+	return j;
+}
+
 
 // --------------------------------------------------------------------------------
 //           Some stuff to help with wierd signatures

Modified: xml/security/trunk/c/src/enc/XSECCryptoUtils.hpp
URL: http://svn.apache.org/viewcvs/xml/security/trunk/c/src/enc/XSECCryptoUtils.hpp?rev=378876&r1=378875&r2=378876&view=diff
==============================================================================
--- xml/security/trunk/c/src/enc/XSECCryptoUtils.hpp (original)
+++ xml/security/trunk/c/src/enc/XSECCryptoUtils.hpp Sun Feb 19 03:30:21 2006
@@ -58,6 +58,8 @@
 // --------------------------------------------------------------------------------
 
 XMLCh DSIG_EXPORT * EncodeToBase64XMLCh(unsigned char * input, int inputLen);
+unsigned int DSIG_EXPORT DecodeFromBase64XMLCh(const XMLCh * input, unsigned char * output, int maxOutputLen);
+unsigned int DSIG_EXPORT DecodeFromBase64(const char * input, unsigned char * output, int maxOutputLen);
 
 // --------------------------------------------------------------------------------
 //           Some stuff to help with wierd signatures