Mixe for Privacy and Anonymity in the Internet
Static Public Member Functions
CABase64 Class Reference

#include <CABase64.hpp>

List of all members.

Static Public Member Functions

static SINT32 decode (const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff Makes a Base64-Decoding on the input byte array.
static SINT32 encode (const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff Makes a Base64-Encoding on the input byte array.

Detailed Description

Definition at line 28 of file CABase64.hpp.


Member Function Documentation

SINT32 CABase64::decode ( const UINT8 in,
UINT32  inlen,
UINT8 out,
UINT32 outlen 
) [static]

ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff Makes a Base64-Decoding on the input byte array.

It decodes in to out.

Parameters:
ininput byte array
inlensize of the input byte array
outoutput byte array
outlenon input must contain the size of the byte array for output, on return it contains the size of the decoded output
Return values:
E_SUCCESSif no error occurs
E_UNKNOWNif an error occurs fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Definition at line 41 of file CABase64.cpp.

References E_SUCCESS, E_UNKNOWN, and len.

Referenced by decodeXMLEncryptedKey(), decryptXMLElement(), CAFirstMix::doUserLogin_internal(), CAASymCipher::getKeyPart(), CAAccountingInstance::handleChallengeResponse_internal(), CASignature::parseSignKeyXML(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), CAASymCipher::setPublicKey(), CASignature::setSignKey(), CASignature::setVerifyKey(), CAMultiSignature::verifyXML(), and CASignature::verifyXML().

{
  if(outlen==NULL)
    return E_UNKNOWN;
  if(in==NULL||inlen==0)
  {
    *outlen=0;
    return E_SUCCESS;
  }
  EVP_ENCODE_CTX oCTX;
  EVP_DecodeInit(&oCTX);
  int len=0;
  *outlen=0;
  SINT32 ret=-1;
  //ensure that in and out are disjunct - otherwise copy in
  if(((out>=in)&&(in+inlen>out))||((out<in)&&(out+*outlen>in)))
  {
    UINT8*tmpIn=new UINT8[inlen];
    memcpy(tmpIn, in, inlen);
    ret=EVP_DecodeUpdate(&oCTX, out, (int*) outlen, tmpIn, (int)inlen);
    delete[] tmpIn;
    tmpIn = NULL;
  }
  else
  {
    ret=EVP_DecodeUpdate(&oCTX, out, (int*) outlen, (unsigned char*) in, (int)inlen);
  }
  if(ret<0||EVP_DecodeFinal(&oCTX, out+(*outlen), &len)<0)
    {
      return E_UNKNOWN;
    }
  (*outlen)+=len;
  return E_SUCCESS;
}
SINT32 CABase64::encode ( const UINT8 in,
UINT32  inlen,
UINT8 out,
UINT32 outlen 
) [static]

ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff Makes a Base64-Encoding on the input byte array.

It encodes in to out.

Parameters:
ininput byte array
inlensize of the input byte array
outoutput byte array
outlenon input must contain the size of the byte array for output, on return it contains the size of the encoded output
Return values:
E_SUCCESSif no error occurs
E_UNKNOWNif an error occurs

fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Definition at line 87 of file CABase64.cpp.

References E_SUCCESS, E_UNKNOWN, and len.

Referenced by __encryptKey(), CAASymCipher::addKeyPart(), CAFirstMix::doUserLogin_internal(), encryptXMLElement(), CASignature::getSignKey(), CAAccountingInstance::handleAccountCertificate_internal(), CAMsg::openEncryptedLog(), CAAccountingInstance::prepareCCRequest(), CALocalProxy::processKeyExchange(), CAMiddleMix::processKeyExchange(), CALastMix::processKeyExchange(), CAFirstMix::processKeyExchange(), and CAMultiSignature::signXML().

{
  if(outlen==NULL)
    return E_UNKNOWN;
  if(in==NULL||inlen==0)
  {
    *outlen=0;
    return E_SUCCESS;
  }
  if(inlen>*outlen)
    return E_UNKNOWN;

  EVP_ENCODE_CTX oCTX;
  EVP_EncodeInit(&oCTX);
  UINT32 len=0;
  *outlen=0;

  //ensure that in and out are disjunct - otherwise copy in
  if(((out>=in)&&(in+inlen>out))||((out<in)&&(out+*outlen>in)))
  {
    UINT8*tmpIn=new UINT8[inlen];
    memcpy(tmpIn, in, inlen);
    EVP_EncodeUpdate(&oCTX, out, (int*) outlen, tmpIn, (int)inlen);
    delete[] tmpIn;
    tmpIn = NULL;
  }
  else
  {
    EVP_EncodeUpdate(&oCTX, out, (int*) outlen, (unsigned char*) in, (int)inlen);
  }
  EVP_EncodeFinal(&oCTX, out+(*outlen), (int*)&len);
  (*outlen)+=len;
  return E_SUCCESS;
}

The documentation for this class was generated from the following files: