2013/3/24 Sven Barth <pascaldra...@googlemail.com> > On 24.03.2013 19:35, silvioprog wrote: > >> 2013/3/24 Sven Barth <pascaldra...@googlemail.com >> <mailto:pascaldragon@**googlemail.com <pascaldra...@googlemail.com>>> >> >> >> On 24.03.2013 16:59, silvioprog wrote: >> >> My function is more fast that cHash >> >> (http://fundementals.__sourcef**orge.net/dl.html<http://sourceforge.net/dl.html> >> >> <http://fundementals.**sourceforge.net/dl.html<http://fundementals.sourceforge.net/dl.html>>). >> The comparison >> >> result is: >> >> HMAC: 00:00:01:689 cHash: 00:00:02:038 >> >> My final unit is: >> >> http://pastebin.com/4484g9i8 >> >> >> Could you maybe run your unit through some test vectors if you >> haven't done already? E.g. these: >> >> http://tools.ietf.org/html/__**rfc4231<http://tools.ietf.org/html/__rfc4231> >> >> <http://tools.ietf.org/html/**rfc4231<http://tools.ietf.org/html/rfc4231> >> > >> >> If that works satisfactory you could create a bug report and we >> could include it in the hash package. >> >> Regards, >> Sven >> >> >> Yes. I'll try to implement it now! :) >> >> For SHA1 this is the final implementation: http://pastebin.com/t4e3tvXa >> >> Now I'll implement it for MD5 conforming >> http://tools.ietf.org/html/**rfc2202 <http://tools.ietf.org/html/rfc2202>, >> create some samples showing HMACMD5 >> and HMACSHA1 and finally create a bug report. >> >> Thank you very much Sven! :) >> > > Some comments: > - 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) >
Hm... You are right. Those looking for more speed might prefer TSHA1Digest. I'll use TSHA1Digest instead string. So, I'm tested the test cases and all worked fine, ex (test 2): ===== test_case = 2 key = "Jefe" key_len = 4 data = "what do ya want for nothing?" data_len = 28 digest = 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79 ===== with TFileStream.Create('test.txt', fmCreate) do try X := HMACSHA1('Jefe', 'what do ya want for nothing?'); Write(Pointer(X)^, Length(X)); finally Free; end; Content in test.txt: effcdf6ae5eb2fa2d27416d5f184df9c259a7c79. Perfect! :-* - I'm not that happy with SHA1Raw and the constants being exported in the > interface... :/ I also think not. I'll remove it from the interface. -- Silvio Clécio My public projects - github.com/silvioprog
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal