F
Fernando Barsoba
Hi all,
First of all, I'd like to thank you "Skarmander" and "Flash Gordon" for
the help they provided me: Skarmander's algorithm and Flash's
modifications helped me a lot.
Here's the problem I had and the question which I still have regarding
that problem:
I tried to send a hex string to a function that performed message
authentication using a particular cryptographic function. Concretely, I
used HMAC-SHA1. The string I sent to the integrity check computation
(ICV) was a string over which bit operations were performed.. so the
result was a lot of gibberish. The result from the ICV was a string of
20 or 16 bytes, depending on the algorithm used (sha1 or md5), with the
message digest.
The problem I had was that the result, the output, was always different
each time I executed the program. Most surprising, when executing the
same function but with the following values, as in RFC 2202, test #2:
char msgtest[]="what do ya want for nothing?";
char key[]="Jefe";
I obtained the expected digest, and always the same. I checked sizes,
data types, etc.. but I always got the correct result for this one, but
different values when I executed my program with 'real' values.
Further investigating, I saw that my program wasn't able to deal with
hexadecimal keys. When I tried to use as key an hexadecimal number, as
in RFC 2202 test case #2
char tmp_key[]="0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"; // hex
char msgtest[]="Hi There";
I didn't know how. Skarmander gave a hand and provided me with an
algorithm to convert the text string to an actual sequence of
hexadecimal text string representing the hexadecimal value. Thanks to
his code and some additions from Flash Gordon I could use hexadecimal
keys. *** And then, I realized that perhaps that could help me with my
problem, that I could do the same with my hexadecimal string, the one I
sent to the ICV function. I did so, and my problem was solved: I always
got the same output.
So, the problem solved but still w/o a clue about what happened..why did
I have those problems in the first place? Isn't a string stored always
in hexadecimal values? and shouldn't the functions that manipulate this
string produce the digest correctly (provided that the data type is
unsigned char)?
Thanks,
FBM
First of all, I'd like to thank you "Skarmander" and "Flash Gordon" for
the help they provided me: Skarmander's algorithm and Flash's
modifications helped me a lot.
Here's the problem I had and the question which I still have regarding
that problem:
I tried to send a hex string to a function that performed message
authentication using a particular cryptographic function. Concretely, I
used HMAC-SHA1. The string I sent to the integrity check computation
(ICV) was a string over which bit operations were performed.. so the
result was a lot of gibberish. The result from the ICV was a string of
20 or 16 bytes, depending on the algorithm used (sha1 or md5), with the
message digest.
The problem I had was that the result, the output, was always different
each time I executed the program. Most surprising, when executing the
same function but with the following values, as in RFC 2202, test #2:
char msgtest[]="what do ya want for nothing?";
char key[]="Jefe";
I obtained the expected digest, and always the same. I checked sizes,
data types, etc.. but I always got the correct result for this one, but
different values when I executed my program with 'real' values.
Further investigating, I saw that my program wasn't able to deal with
hexadecimal keys. When I tried to use as key an hexadecimal number, as
in RFC 2202 test case #2
char tmp_key[]="0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"; // hex
char msgtest[]="Hi There";
I didn't know how. Skarmander gave a hand and provided me with an
algorithm to convert the text string to an actual sequence of
hexadecimal text string representing the hexadecimal value. Thanks to
his code and some additions from Flash Gordon I could use hexadecimal
keys. *** And then, I realized that perhaps that could help me with my
problem, that I could do the same with my hexadecimal string, the one I
sent to the ICV function. I did so, and my problem was solved: I always
got the same output.
So, the problem solved but still w/o a clue about what happened..why did
I have those problems in the first place? Isn't a string stored always
in hexadecimal values? and shouldn't the functions that manipulate this
string produce the digest correctly (provided that the data type is
unsigned char)?
Thanks,
FBM