Hi Adam,
> Yeah I think the actual code is fine
It is. I ran it. Every now and agian I get lazy and shoot from the
hip, but not this time.
> Does the key need to be entered into the code before a calculation can
> be made?
Yes. It is a keyed hash. See [1] and [2].
> How would I go about that if i wanted to hard code it in?
Initialize the byte array key[] to the agreed upon value.
> Is the string "hello world" the data to be hashed?
Yes. It can be any data. Crypto++ is bytes/bytes out. Just present
your data as a byte*.
> Where abouts should I add that code to print the result?
It can be dumped after the mac is calculated. It would not make sense
to dump it before the mac is calculated.
string encoded;
StringSource( mac, true,
new HexEncoder( new StringSink( encoded ),
true, // uppercase
2 // grouping size
)
);
cout << encoded << endl;
Or, you could use a printf string:
printf("%02X %02X ... %02X %02X", digest[0], digest[1]...);
> Is the variable mac the variable that holds the result of
> the mac calculation?
Yes.
> And therefore it is mac that is compared at the receiver
> to verify for authentication?
Yes.
> What do the verifier pieces of code do and how do they work?
The concept is the same as a digital signature. One side generates a
signature on the message, the other verifies the signature. I placed
it in one program separating the roles with the comment/equal signs.
Jeff
[1] http://en.wikipedia.org/wiki/HMAC
[2] http://www.codeproject.com/KB/security/BlockCiphers.aspx
On Tue, Jun 10, 2008 at 11:20 AM, Adam Harding
<[EMAIL PROTECTED]> wrote:
>
> Hi Jeff,
>
> Thanks alot for your help. Really appreciate it.
>
> Yeah I think the actual code is fine but just think I have compiled
> the cryptopp library incorrectly or using the wrong gcc command when
> it comes to running it on my computer. Hopefully will get it working
> in the lab though.
>
> Could you please quickly explain a few things about the code you gave
> me to make sure I understand it?
>
> Does the key need to be entered into the code before a calculation can
> be made? How would I go about that if i wanted to hard code it in?
> Is the string "hello world" the data to be hashed?
> Where abouts should I add that code to print the result?
> Is the variable mac the variable that holds the result of the mac
> calculation? And therefore it is mac that is compared at the receiver
> to verify for authentication?
> What do the verifier pieces of code do and how do they work?
>
> Cheers,
>
> Adam.
>
> On Jun 10, 1:45 am, "Jeffrey Walton" <[EMAIL PROTECTED]> wrote:
>> Hi Adam,
>>
>> > Basically am just trying to implement the MAC field in a packet header
>> > for authentication. Is the digest the result of the calculation on the
>> > data?
>>
>> What to MAC and how to MAC it depends on your protocol. I presume it
>> is TLS or IPSec? Unfortunately, I have not looked at the standard(s)
>> lately, so I can't say what you should do.
>>
>> > I am just trying to find a way of calculating the MAC
>>
>> You now have the code.
>>
>> > and then printing it so I can see I have a result
>>
>> Add the following after including "hex.h":
>>
>> string encoded;
>> StringSource( mac, true,
>> new HexEncoder( new StringSink( encoded ),
>> true, // uppercase
>> 2 // grouping size
>> )
>> );
>>
>> > I tried implementing the code you gave me in a file called auth.cpp
>> > and used this makefile to try and put it all together:
>>
>> I haven't seen Tux in quite some time, but I believe you need to
>> include the library as an arument to gcc. I think it is -lcryptlib.a
>>
>> Jeff
>>
>> [SNIP]
--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---