Thanks for the help. I did manage to get the GCM<AES> with
FileSource/FileSink working so nicely. As a result I can say definately now
that my main problem is with encrypting large files in chunks. My decryption
is correct and I have verified that by testing and I know that my final
issue is with encrypting the last chunk of plaintext.
I am almost there, My problem has to do with the final "TAG_SIZE" amount of
plaintext going into the ef. I'm encrypting as follows:
GCM< AES >::Encryption e;
e.SetKeyWithIV( bKey, sizeof(bKey), bIv, sizeof(bIv) );
AuthenticatedEncryptionFilter ef(e, new CryptoPP::ByteQueue(), false,
TAG_SIZE, DEFAULT_CHANNEL, DEFAULT_PADDING );
if(inFile.Open(szFileIn, CFile::modeRead | CFile::typeBinary |
CFile::shareExclusive, &Exception))
{
if(outFile.Open(szFileOut, CFile::modeCreate | CFile::modeReadWrite |
CFile::shareExclusive, &Exception))
{
dwActual = (DWORD)inFile.SeekToEnd();
dwRem = dwActual;
if(dwActual > dwMax)
{
readBuff = new BYTE[dwMax];
dwRead = dwMax;
}
else
{
readBuff = new BYTE[dwActual];
dwRead = dwActual;
}
inFile.SeekToBegin();
do
{
inFile.Read(readBuff, dwRead);
//The last chunk requires attention!
if(bLast)
{
ef.Put(readBuff, ((size_t)dwRead + TAG_SIZE));
//Without this, text is
missing upon Decryption!
maxRetrieve = ef.MaxRetrievable();
}
else
{
ef.Put(readBuff, dwRead);
maxRetrieve = ef.MaxRetrievable();
}
cipher.clear();
cipher.reserve(dwRead);
ef.Get((byte*)cipher.data(), dwRead);//Getback the
container string
if(maxRetrieve != 0)
{
outFile.Write((BYTE*)cipher.c_str(),
(UINT)maxRetrieve);
}
dwRem = dwRem - dwRead;
if(dwRem > dwMax)
dwRead = dwMax;
else
{
bLast = true;
dwRead = dwRem;
}
} while(dwRem != 0);
ef.MessageEnd();
delete [] readBuff;
outFile.Close();
}
else
return false ;//out file failed to open
inFile.Close();
Thanks again
--
View this message in context:
http://crypto-users.996303.n3.nabble.com/Re-AuthenticatedDecryptionFilter-and-ByteQueue-tp4768p4777.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.