Here is a simplified example of how i'm trying to use
it. I think i've discovered the problem. Correct me if
i'm wrong, I have to set the key/iv again after
Initialize call right?
using namespace CryptoPP;
byte
IV[16]={1,5,8,12,46,4,250,234,35,79,36,89,34,79,45,67};
byte
Key[32]={1,24,45,7,4,6,83,60,245,232,68,90,34,95,25,78,
67,4,42,37,74,16,48,66,215,132,62,93,35,91,35,15};
SymmetricCipher* enc = new
CBC_Mode<AES>::Encryption();
enc->SetKeyWithIV(Key, sizeof(Key), IV);
StreamTransformationFilter filterEnc(*enc, 0,
StreamTransformationFilter::BlockPaddingScheme::PKCS_PADDING);
SymmetricCipher* dec = new
CBC_Mode<AES>::Decryption();
dec->SetKeyWithIV(Key, sizeof(Key), IV);
StreamTransformationFilter filterDec(*dec, 0,
StreamTransformationFilter::BlockPaddingScheme::PKCS_PADDING);
filterEnc.Put((byte*)"1234567890123456", 16);
filterEnc.PutMessageEnd((byte*)"12345", 5);
unsigned long cntenc = filterEnc.MaxRetrievable();
byte encbuf[32];
if(cntenc > 0 && cntenc<= sizeof(encbuf))
cntenc = filterEnc.Get(encbuf, sizeof(encbuf));
if(cntenc > 0)
{
filterDec.Put(encbuf, cntenc);
filterDec.PutMessageEnd(0, 0);
int cntdec = filterDec.MaxRetrievable();
byte decbuf[32];
if(cntdec > 0 && cntdec <= sizeof(decbuf))
{
cntdec = filterDec.Get(decbuf, sizeof(decbuf));
filterDec.Initialize();
//next line fixes the problem
//dec->SetKeyWithIV(Key, sizeof(Key), IV);
filterDec.Put(encbuf, cntenc);
filterDec.PutMessageEnd(0, 0);
cntdec = filterDec.MaxRetrievable();
cntdec = filterDec.Get(decbuf, sizeof(decbuf));
}
}
delete enc; delete dec;
I'm trying to ReInitialize and use the same instance
(same key/iv) of SymmetricCipher and
StreamTransformationFilter again. Do i have to call
SetKeyWithIV after Initialize call?
Am i using the library wrong?
Thanx a lot
--- Wei Dai <[EMAIL PROTECTED]> wrote:
> Initialize() is the right method. If it doesn't work
> for you, please
> follow instructions at
> http://www.eskimo.com/~weidai/cryptlib.html#lists
> for reporting
> problems.
>
> On Mon, Aug 04, 2003 at 08:44:46AM -0700, cppdev
> wrote:
> > Hello All,
> >
> > What isthe proper way to reinitialize the
> > StreamTransformationFilter? I tried calling
> > its Initialize() method, it partially works,
> > but i get garbage for the first block (16 for AES)
> > COuld anyone help?
> >
> > Thanx a lot
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> > http://sitebuilder.yahoo.com
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com