Viktor Szakáts wrote:
Pls see a Harbour library which implements SHA2 related
checksumming and SHA2 MAC creation, here:
http://www.syenar.hu/harbour/hbsha2.zip
Usage from .prg:
HB_SHA224( <cMessage> ) -> <cDigest>
HB_SHA256( <cMessage> ) -> <cDigest>
HB_SHA384( <cMessage> ) -> <cDigest>
HB_SHA512( <cMessage> ) -> <cDigest>
HB_SHA224_HMAC( <cMessage>, <cKey> ) -> <cMAC>
HB_SHA256_HMAC( <cMessage>, <cKey> ) -> <cMAC>
HB_SHA384_HMAC( <cMessage>, <cKey> ) -> <cMAC>
HB_SHA512_HMAC( <cMessage>, <cKey> ) -> <cMAC>
This is a thin wrapper around this code:
http://www.ouah.org/ogay/sha2/
http://www.ouah.org/ogay/hmac/
Above code has BSD license, the same as used in PCRE, so I assume
it's also safe to include it in Harbour.
You can unzip the attached code in the contrib dir, and build
it just like any other contribs.
If there are no objections and I've received feedback, I plan to
add these functions to the core.
Hi,
just a few quick ideas:
1) it would be nice to have C also interface and to have names
compatible to existing MD5 hasing;
2) SHA1 is also member of the family and often used (SHA224 is seldom);
3) HMAC calculation is algorithm independent from hasing. Maybe we can
have universal HB_HMAC() instead of HB_*_HMAC(),
I guess code is:
FUNC HB_HMAC(fHash, cMessage, cKey)
IF LEN(cKey) > 64; cKey := HB_HexToStr(EVAL(fHash, cKey))
ENDIF
cKey := PADR(cKey, 64, CHR(0))
RETURN EVAL(fHash, HB_STRXOR(cKey, 0x5C) + ;
EVAL(fHash, HB_STRXOR(cKey, 0x36) + cMessage))
4) If there are some licence problem, we can find public domain
implementations. I guess rfc or standarts implementation is also free by
some mean;
5) I'm starting to think about some generic HB_CRYPT*() library. I
should stop think :)
Best regards,
Mindaugas
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour