Click here to Skip to main content

Chien-Chung, Chung - Professional Profile

906
Author
30
Authority
-1
Debator
10
Editor
5
Organiser
124
Participant
0
Enquirer
Life is nothing but choices.
Member since Thursday, December 13, 2007 (4 years, 5 months)

For more information on Reputation please see the FAQ.
 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
  Refresh
QuestionHMAC-SHA question Pin
Wednesday, June 4, 2008 5:54 AM
Hi there,
 
Really pleased I found your code as is the sort of thing I am looking for.
 
I am just trying to run it first and since my programming knowledge is very limited I have a few questions!!
 
For the test data you suggested:
#include "HMAC_SHA1.h"
 
BYTE Key[20] ;
BYTE digest[20] ; 
 
unsigned char *test = "Hi There" ; 
memset(Key, 20, 0x0b) ;
CHMAC_SHA1 HMAC_SHA1 ;
HMAC_SHA1.HMAC_SHA1(test, strlen(test), Key, sizeof(Key), digest) ;
 
// Check with digest equal to 0xb617318655057264e28bc0b6fb378c8ef146be00
// or not
 
...for this part above, is it just added into an already existing source code file of the program that will be run? At the moment I have linked them together in a makefile:
 
CC=g++
 
HMAC_SHA1++:test.o HMAC_SHA1.o	SHA1.o
 
	$(CC)	test.o	HMAC_SHA1.o	SHA1.o	-o  HMAC_SHA1++
 
test.o: test.cpp HMAC_SHA1.h
 
	$(CC) -c test.cpp
 
SHA1.o: SHA1.cpp SHA1.h
 
	$(CC) -c SHA1.cpp
 
HMAC_SHA1.o: HMAC_SHA1.cpp HMAC_SHA1.h
 
	$(CC) -c HMAC_SHA1.cpp
 
..where the file test.cpp is exactly the contents of test code you suggested above. It is giving some errors about converting between signed/unsigned ints and chars etc...so just wondering how to use that test code...does it need to be inside some sort of main() function etc to work?
 
...after that I am hoping to somehow do the receiver processing where the receiver calculates the digest and then compares into to the senders digest and produces an error if they do not match. I am programming in fields for the security extension header of a ULE subnetwork data unit.
 
Thanks alot for any help!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.5.120528.1 | Last Updated 28 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid