Mixe for Privacy and Anonymity in the Internet
Static Public Member Functions | List of all members
CABase64 Class Reference

#include <CABase64.hpp>

Collaboration diagram for CABase64:

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. More...
 
static SINT32 encode (const UINT8 *in, UINT32 len, UINT8 *out, UINT32 *outlen)
 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff Makes a Base64-Encoding on the input byte array. More...
 

Detailed Description

Definition at line 28 of file CABase64.hpp.

Member Function Documentation

◆ decode()

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.

42  {
43  if (outlen == NULL)
44  return E_UNKNOWN;
45  if (in == NULL || inlen == 0)
46  {
47  *outlen = 0;
48  return E_SUCCESS;
49  }
50  EVP_ENCODE_CTX* pCTX = NULL;
51 #if OPENSSL_VERSION_NUMBER > 0x100020cfL
52  pCTX=EVP_ENCODE_CTX_new();
53 #else
54  pCTX = new EVP_ENCODE_CTX;
55 #endif
56  EVP_DecodeInit(pCTX);
57  int len = 0;
58  *outlen = 0;
59  SINT32 ret = -1;
60  //ensure that in and out are disjunct - otherwise copy in
61  if (((out >= in) && (in + inlen > out)) || ((out < in) && (out + *outlen > in)))
62  {
63  UINT8*tmpIn = new UINT8[inlen];
64  memcpy(tmpIn, in, inlen);
65  ret = EVP_DecodeUpdate(pCTX, out, (int*) outlen, tmpIn, (int) inlen);
66  delete[] tmpIn;
67  tmpIn = NULL;
68  }
69  else
70  {
71  ret = EVP_DecodeUpdate(pCTX, out, (int*) outlen, (unsigned char*) in, (int) inlen);
72  }
73  if (ret < 0 || EVP_DecodeFinal(pCTX, out + (*outlen), &len) < 0)
74  {
75  ret=E_UNKNOWN;
76  }
77  else
78  {
79  (*outlen) += len;
80  ret = E_SUCCESS;
81  }
82 #if OPENSSL_VERSION_NUMBER > 0x100020cfL
83  EVP_ENCODE_CTX_free(pCTX);
84 #else
85  delete pCTX;
86 #endif
87 
88  return ret;
89  }
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3
UINT16 len
Definition: typedefs.hpp:0

References E_SUCCESS, E_UNKNOWN, and len.

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

Here is the caller graph for this function:

◆ encode()

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 102 of file CABase64.cpp.

103  {
104  if (outlen == NULL)
105  return E_UNKNOWN;
106  if (in == NULL || inlen == 0)
107  {
108  *outlen = 0;
109  return E_SUCCESS;
110  }
111  if (inlen > *outlen)
112  return E_UNKNOWN;
113  EVP_ENCODE_CTX* pCTX = NULL;
114 #if OPENSSL_VERSION_NUMBER > 0x100020cfL
115  pCTX=EVP_ENCODE_CTX_new();
116 #else
117  pCTX = new EVP_ENCODE_CTX;
118 #endif
119  EVP_EncodeInit(pCTX);
120  UINT32 len = 0;
121  *outlen = 0;
122 
123  //ensure that in and out are disjunct - otherwise copy in
124  if (((out >= in) && (in + inlen > out)) || ((out < in) && (out + *outlen > in)))
125  {
126  UINT8*tmpIn = new UINT8[inlen];
127  memcpy(tmpIn, in, inlen);
128  EVP_EncodeUpdate(pCTX, out, (int*) outlen, tmpIn, (int) inlen);
129  delete[] tmpIn;
130  tmpIn = NULL;
131  }
132  else
133  {
134  EVP_EncodeUpdate(pCTX, out, (int*) outlen, (unsigned char*) in, (int) inlen);
135  }
136  EVP_EncodeFinal(pCTX, out + (*outlen), (int*) &len);
137  (*outlen) += len;
138 #if OPENSSL_VERSION_NUMBER > 0x100020cfL
139  EVP_ENCODE_CTX_free(pCTX);
140 #else
141  delete pCTX;
142 #endif
143  return E_SUCCESS;
144  }
unsigned int UINT32
Definition: basetypedefs.h:131

References E_SUCCESS, E_UNKNOWN, and len.

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

Here is the caller graph for this function:

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