CMAC encoding failed with padding bytes

View: New views
2 Messages — Rating Filter:   Alert me  

CMAC encoding failed with padding bytes

by Ger-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


CMAC encoding works fine when the message to encode has 8, 16 32 etc.
bytes. When ever the length is not a standard block size, the results
are not correct (I have a list with testvectors to check the result).
According the the standard (NIST 800-38B) the message should be
extended with padding byte, first byte 0x80, the others 0x00. When I
do this the result is also incorrect.
I can imaging that I have to set a parameter to indicate padding is
provided, but it is not clear what must be done to get the encoding
correct when using padding bytes.
Does anyone has a suggestion?
The relevant piece of source code is:

        CMAC<AES> Cmac;

// Fill bKey; bTestdata with testdata : result in bTestDecr

        Cmac.SetKey(bKey, sizeof(bKey));
        Cmac.Update(bTestdata, sizeof(bTestdata));
        Cmac.Final(bTestDecr);

regards,
Ger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---


Re: CMAC encoding failed with padding bytes

by Wei Dai :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Crypto++ should do the CMAC padding for you, and there is no option to turn
it on or off. If you look in TestVectors/cmac.txt, there are a bunch of test
vectors (with sources annotated) that Crypto++ passes, some of which involve
messages that are not multiples of 8 bytes.

So, I don't know what is the problem here without more information. Can you
tell me where you got your test vectors, and provide source code to the test
program you wrote to test Crypto++ against those vectors?

--------------------------------------------------
From: "Ger" <haven@...>
Sent: Thursday, October 29, 2009 12:22 AM
To: "Crypto++ Users" <cryptopp-users@...>
Subject: CMAC encoding failed with padding bytes

>
> CMAC encoding works fine when the message to encode has 8, 16 32 etc.
> bytes. When ever the length is not a standard block size, the results
> are not correct (I have a list with testvectors to check the result).
> According the the standard (NIST 800-38B) the message should be
> extended with padding byte, first byte 0x80, the others 0x00. When I
> do this the result is also incorrect.
> I can imaging that I have to set a parameter to indicate padding is
> provided, but it is not clear what must be done to get the encoding
> correct when using padding bytes.
> Does anyone has a suggestion?
> The relevant piece of source code is:
>
> CMAC<AES> Cmac;
>
> // Fill bKey; bTestdata with testdata : result in bTestDecr
>
> Cmac.SetKey(bKey, sizeof(bKey));
> Cmac.Update(bTestdata, sizeof(bTestdata));
> Cmac.Final(bTestDecr);
>
> regards,
> Ger
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscribe@....
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---