Hi Again,
Still having the same problem with not getting all the data back.
Does anyone have any working examples of what I'm trying to do?
Basically I'm putting 3276 bytes of data in and getting 127 bytes
back. I didnt get the sizes from strlen() or sizeof() I'm watching
them directly with breaks in the debugger.
What I am trying to accomplish is to have varying amounts of data
ascii or binary BASE64 encoded and then passed into a function that
will encrypt it. The algorithm doesnt really matter so if you know of a
way using something other than the 3DES way I'm trying to do this,
I am open to suggestions. The data is then passed on in one block
to a transport function that handles sending it across the wire where
it is decrypted using mcrypt in PHP on my linux server.
for small amounts of data this is working great but anything bigger
than 127 bytes getting dropped. I have tried to iterate through the
output buffer of the encryptor with "encryptor.GetNext". but this is
a no go as well. I have also tried with and without the StringSink
both with no luck.
Anyway here is a snippet of what I'm doing.
//plaintext is 2394 bytes of ascii or binary data
std::string Client::EncryptData(std::string plaintext) {
std::string ciphertext;
const byte key [] = "d0763edaa9d9bd2a9516280e";
const BYTE iv [] = "d0763eda";
ECB_Mode<DES_EDE3>::Encryption ecbEncryption(key, DES_EDE3::DEFAULT_KEYLENGTH, iv);
StringSink *sink = new StringSink(ciphertext);
//using Zero padding for mcrypt compatability
StreamTransformationFilter encryptor(ecbEncryption, sink, StreamTransformationFilter::ZEROS_PADDING);
int szBuff = plaintext.size();
byte * holder = (BYTE *)LocalAlloc(LMEM_FIXED, szBuff + 1);
memset(holder, 0, szBuff + 1);
CopyMemory(holder, plaintext.data(), szBuff);
int szzBuff = Base64EncodeGetRequiredLength(szBuff);
int *szBuff2 = &szzBuff;
byte * holder2 = (BYTE *)LocalAlloc(LMEM_FIXED, szzBuff + 1);
memset(holder2, 0, szzBuff + 1);
//Base64 Encoding All Data before encrypting so ASCII and BINARY and pass transparently
Base64Encode(holder, szBuff, (LPSTR)holder2, szBuff2 );
int foo = *szBuff2;
//Had to do this to get out padding Base64Encode stick on end for troubleshooting
byte * pBuff = (BYTE *)LocalAlloc(LMEM_FIXED, foo);
memset(pBuff, 0, foo + 1);
CopyMemory(pBuff, holder2, foo);
encryptor.Put(pBuff, foo);
encryptor.MessageEnd();
return ciphertext;
}
ciphertext only 127 bytes long.
so any idea, I bet you do sorry about the sloppy code it's just rough draft
till I can get this working.
A.J. Mayorga
FIWC~US. NAVY
RT/RD
