Hi
I want to calcualte a MAC with a DES_EDE2 key, but I always get a wrong
result.
If I calculate it by hand or use DES and DES2 encryption the result is
correct.
I'm using Crypto++ 5.2.1 on Windows XP.

Here the example:

BYTE pbSMMACKey[16] = {0xED, 0x43, 0x3E, 0x1A, 0x97, 0x34, 0x99, 0x6C, 0xD9,
0x93, 0xD9, 0xFA, 0xFD, 0xCE, 0x0C, 0xAB};

BYTE pbTestdata[] = {0xC1, 0x6F, 0xE7, 0x89, 0x49, 0xF9, 0xF1, 0xDD, 0x99,
0x02, 0x90, 0x00, 0x80, 0x00, 0x00, 0x00};

BYTE pbIV[8] = {0x00, };
BYTE pbDesOut[256];
BYTE pbMACOutBuffer[8];

CBC_MAC<DES_EDE2> cbcMac(pbSMMACKey);
cbcMac.CalculateDigest(pbMACOutBuffer, pbTestdata, 16);

The (incorrect) result is: 78 69 6b fb fe d3 4b 65


When using DES for the first Block and DES2 with IV for the second Block the
result is OK:

CBC_Mode<DES>::Encryption desCBCenc(pbSMMACKey, 8, pbIV);
desCBCenc.ProcessBlocks(pbDesOut, pbTestdata, 1);
CBC_Mode<DES_EDE2>::Encryption desCBCEDE2enc;
desCBCEDE2enc.SetKeyWithIV(pbSMMACKey, 16, pbDesOut);
desCBCEDE2enc.ProcessBlocks(pbMACOutBuffer, pbTestdata+8, 1);

The correct result is: ff a1 75 fc 99 4b 79 6c


Do you have any Idea what I make wrong?

Additionaly I get an exception if I want to use the SetKeyWithIV for a
CBC_MAC object:
cbcMac.SetKeyWithIV(pbSMMACKey, 16, pbIV);

The exception is: 
exception: CryptoPP::AlgorithmParametersBase::ParameterNotUsed

Thanks
regards
Alexander
-- 
View this message in context: 
http://www.nabble.com/Get-incorrect-Result-using-CBC_MAC%3CDES_EDE2%3E-tf2165260.html#a5985221
Sent from the Crypto++ forum at Nabble.com.

Reply via email to