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

On Mon, Jun 9, 2008 at 8:24 PM, Adam Harding <[EMAIL PROTECTED]> wrote:
>
> Hey,
>
> 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? I am just trying to find a way of calculating the MAC and then
> printing it so I can see I have a result...and then getting the
> receiver to do the same calculation and see if they match up in order
> to authenticate the data (ie it has not been changed)...is that the
> way to go?
>
> Since my programming is not great am just trying to find some example
> code that I can use HMAC-SHA for to perform the calculation on some
> test data, see it works by a printf and then adapt this to implement
> by code.
>
> 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:
>
> CC=g++
>
> authentication: auth.o   hmac.o  sha.o
>
>        $(CC)   auth.o  hmac.o  sha.o   -o      authentication
>
> auth.o: auth.cpp hmac.h sha.h
>
>        $(CC)   -c      auth.cpp
>
> sha.o: sha.cpp sha.h
>
>        $(CC)   -c      sha.cpp
>
> hmac.o: hmac.cpp hmac.h
>
>        $(CC)   -c      hmac.cpp
>
>
>  but got this error:
>
> auth.cpp:
> (.text._ZN8CryptoPP21SimpleKeyingInterfaceC2Ev[CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()]
> +0x4): undefined reference to `vtable for
> CryptoPP::SimpleKeyingInterface'
> auth.o: In function `CryptoPP::SecBlock<unsigned char,
> CryptoPP::AllocatorWithCleanup<unsigned char, false>
>>::SecBlock(unsigned int)':
> [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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to