<div dir="ltr">2013/3/24 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 24.03.2013 19:35, silvioprog wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
2013/3/24 Sven Barth <<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a><br>
<mailto:<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@<u></u>googlemail.com</a>>><div class="im"><br>
<br>
On 24.03.2013 16:59, silvioprog wrote:<br>
<br>
My function is more fast that cHash<br></div>
(<a href="http://fundementals." target="_blank">http://fundementals.</a>__<a href="http://sourceforge.net/dl.html" target="_blank">sourcef<u></u>orge.net/dl.html</a><br>
<<a href="http://fundementals.sourceforge.net/dl.html" target="_blank">http://fundementals.<u></u>sourceforge.net/dl.html</a>>). The comparison<div class="im"><br>
result is:<br>
<br>
HMAC: 00:00:01:689 cHash: 00:00:02:038<br>
<br>
My final unit is:<br>
<br>
<a href="http://pastebin.com/4484g9i8" target="_blank">http://pastebin.com/4484g9i8</a><br>
<br>
<br>
Could you maybe run your unit through some test vectors if you<br>
haven't done already? E.g. these:<br></div>
<a href="http://tools.ietf.org/html/__rfc4231" target="_blank">http://tools.ietf.org/html/__<u></u>rfc4231</a><div class="im"><br>
<<a href="http://tools.ietf.org/html/rfc4231" target="_blank">http://tools.ietf.org/html/<u></u>rfc4231</a>><br>
<br>
If that works satisfactory you could create a bug report and we<br>
could include it in the hash package.<br>
<br>
Regards,<br>
Sven<br>
<br>
<br>
Yes. I'll try to implement it now! :)<br>
<br>
For SHA1 this is the final implementation: <a href="http://pastebin.com/t4e3tvXa" target="_blank">http://pastebin.com/t4e3tvXa</a><br>
<br>
Now I'll implement it for MD5 conforming<br>
<a href="http://tools.ietf.org/html/rfc2202" target="_blank">http://tools.ietf.org/html/<u></u>rfc2202</a>, create some samples showing HMACMD5<br>
and HMACSHA1 and finally create a bug report.<br>
<br>
Thank you very much Sven! :)<br>
</div></blockquote>
<br>
Some comments:<br>
- Maybe you should have HMACSHA1 return a TSHA1Digest; if the user wants a String she can use SHA1Print herself (and HMACMD5 should consequently return a TMD5Digest) [Note: this will work, because the digest always has a fixed length for MD5 and SHA1 and this is also true for HMAC as you can see in the test vectors in RFC2202)<br>
</blockquote><div><br></div><div style>Hm... You are right. Those looking for more speed might prefer TSHA1Digest. I'll use TSHA1Digest instead string.</div><div><br></div><div style>So, I'm tested the test cases and all worked fine, ex (test 2):</div>
<div style><br></div><div style>=====</div><div style><pre class="" style="font-size:1em;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0)">test_case = 2
key = "Jefe"
key_len = 4
data = "what do ya want for nothing?"
data_len = 28
digest = 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79</pre></div><div style>=====</div><div style><br></div><div style><div> with TFileStream.Create('test.txt', fmCreate) do</div><div> try</div><div> X := HMACSHA1('Jefe', 'what do ya want for nothing?');</div>
<div> Write(Pointer(X)^, Length(X));</div><div> finally</div><div> Free;</div><div> end;</div><div><br></div><div style>Content in test.txt: effcdf6ae5eb2fa2d27416d5f184df9c259a7c79. Perfect! :-*</div></div><div>
<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
- I'm not that happy with SHA1Raw and the constants being exported in the interface...</blockquote></div><div><br></div><div>:/ I also think not. I'll remove it from the interface.</div><div><br></div>-- <br>Silvio Clécio<br>
My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>