This is my setup:

...
ECB_Mode<AES>::Encryption  m_Encryptor;
m_Encryptor.SetKey(key, sizeof(key);

StreamTransformationFilter* m_pStream = new StreamTransformationFilter
(m_Encryptor);
...

void CAESBase::Encrypt(const byte* _pData, int _iSize, byte*
_pBufferOut)
{
  if (_pData && _pBufferOut)
  {
    m_pStream->Initialize();
    m_pStream->Put(_pData, _iSize);
    m_pStream->MessageEnd();

    int iSize = m_pStream->TotalBytesRetrievable();
    if (_pBufferOut->Init(iSize) == RET_OK)
    {
      byte* pOut = (byte*) _pBufferOut->GetNextPtrToWrite(iSize);
      m_pStream->Get(pOut, iSize);
    }
  }
}

When I call the Encrypt method, if _iSize is an exact multiple of
block size (16 bytes), the StreamTransformationFilter adds one full
block of padding data, so when I call TotalBytesRetrievable I get
_iSize + 16.

I've been debugging through Crypto++ code and I think it should be
necessary to check the remaining data size in m_queue before calling
LastPut from FilterWithBufferedInput::PutMaybeModifiable. If the queue
size is 0, LastPuts adds a full block with just padding data.

Is this a bug or it's the expected result? We're working in an
environment where data size send accross network is critical.

Thank you very much for your help!

--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to