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 2004/06/09 06:05:16 UTC

cvs commit: xml-security/c/src/enc/OpenSSL OpenSSLCryptoX509.cpp OpenSSLCryptoBase64.cpp

blautenb    2004/06/08 21:05:16

  Modified:    c/src/enc/OpenSSL OpenSSLCryptoX509.cpp
                        OpenSSLCryptoBase64.cpp
  Log:
  Move to internal Base64 decoder to handle non-wrapping data
  
  Revision  Changes    Path
  1.9       +18 -3     xml-security/c/src/enc/OpenSSL/OpenSSLCryptoX509.cpp
  
  Index: OpenSSLCryptoX509.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoX509.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- OpenSSLCryptoX509.cpp	8 Feb 2004 10:22:50 -0000	1.8
  +++ OpenSSLCryptoX509.cpp	9 Jun 2004 04:05:16 -0000	1.9
  @@ -34,10 +34,12 @@
   #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.hpp>
   #include <xsec/enc/OpenSSL/OpenSSLCryptoKeyRSA.hpp>
   #include <xsec/enc/XSECCryptoException.hpp>
  +#include <xsec/enc/XSCrypt/XSCryptCryptoBase64.hpp>
   
   #include <xercesc/util/Janitor.hpp>
   
   XSEC_USING_XERCES(ArrayJanitor);
  +XSEC_USING_XERCES(Janitor);
   
   #include <openssl/evp.h>
   
  @@ -106,6 +108,19 @@
   	XSECnew(outBuf, unsigned char[len + 1]);
   	ArrayJanitor<unsigned char> j_outBuf(outBuf);
   
  +	/* Had to move to our own Base64 decoder because it handles non-wrapped b64
  +	   better.  Grrr. */
  +
  +	XSCryptCryptoBase64 *b64;
  +	XSECnew(b64, XSCryptCryptoBase64);
  +	Janitor<XSCryptCryptoBase64> j_b64(b64);
  +
  +	b64->decodeInit();
  +	bufLen = b64->decode((unsigned char *) buf, len, outBuf, len);
  +	bufLen += b64->decodeFinish(&outBuf[bufLen], len-bufLen);
  +
  +	/*
  +
   	EVP_ENCODE_CTX m_dctx;
   	EVP_DecodeInit(&m_dctx);
   
  @@ -120,12 +135,12 @@
   		throw XSECCryptoException(XSECCryptoException::Base64Error,
   			"OpenSSL:Base64 - Error during Base64 Decode of X509 Certificate");
   	}
  -
  +	
   	int finalLen;
   	EVP_DecodeFinal(&m_dctx, &outBuf[bufLen], &finalLen); 
   
   	bufLen += finalLen;
  -
  +	*/
   	if (bufLen > 0) {
   		mp_X509=  d2i_X509(NULL, &outBuf, bufLen);
   	}
  
  
  
  1.7       +16 -1     xml-security/c/src/enc/OpenSSL/OpenSSLCryptoBase64.cpp
  
  Index: OpenSSLCryptoBase64.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/enc/OpenSSL/OpenSSLCryptoBase64.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OpenSSLCryptoBase64.cpp	8 Feb 2004 10:22:50 -0000	1.6
  +++ OpenSSLCryptoBase64.cpp	9 Jun 2004 04:05:16 -0000	1.7
  @@ -32,9 +32,16 @@
   
   #include <xsec/enc/OpenSSL/OpenSSLCryptoBase64.hpp>
   #include <xsec/enc/XSECCryptoException.hpp>
  +#include <xsec/enc/XSCrypt/XSCryptCryptoBase64.hpp>
  +#include <xsec/framework/XSECError.hpp>
  +
  +#include <xercesc/util/Janitor.hpp>
   
   #include <openssl/err.h>
   
  +XERCES_CPP_NAMESPACE_USE
  +
  +
   // --------------------------------------------------------------------------------
   //           Decoding
   // --------------------------------------------------------------------------------
  @@ -160,7 +167,7 @@
   
   	int bufLen;
   	unsigned char buf[1024];
  -
  +/*
   	EVP_ENCODE_CTX m_dctx;
   	EVP_DecodeInit(&m_dctx);
   	int rc = EVP_DecodeUpdate(&m_dctx, 
  @@ -179,6 +186,14 @@
   	EVP_DecodeFinal(&m_dctx, &buf[bufLen], &finalLen); 
   
   	bufLen += finalLen;
  +*/
  +	XSCryptCryptoBase64 *b64;
  +	XSECnew(b64, XSCryptCryptoBase64);
  +	Janitor<XSCryptCryptoBase64> j_b64(b64);
  +
  +	b64->decodeInit();
  +	bufLen = b64->decode((unsigned char *) b64in, len, buf, len);
  +	bufLen += b64->decodeFinish(&buf[bufLen], len-bufLen);
   
   	// Now translate to a bignum
   	return BN_dup(BN_bin2bn(buf, bufLen, NULL));