Skip to content

Commit

Permalink
Replace flawed sha1 implementation with WaterJuice WjCryptLib_Sha1 (f…
Browse files Browse the repository at this point in the history
…ixes issue bradenmcd#4)
  • Loading branch information
gertoe committed Jan 10, 2021
1 parent d9461a9 commit d3ffe61
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 223 deletions.
6 changes: 3 additions & 3 deletions libmultihash/multihash.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void multihash_init (multihash *mh) {
#endif
#ifdef USE_SHA1
(mh -> sha1_s)[0] = '\0';
SHA1Init (&(mh -> sha1));
Sha1Initialise (&(mh -> sha1));
#endif

return;
Expand All @@ -64,7 +64,7 @@ void multihash_update (multihash *mh, unsigned char *data, int bytes) {
// ed2khash_update (&(mh -> ed2k), data, bytes);
#endif
#ifdef USE_SHA1
SHA1Update (&(mh -> sha1), data, bytes); /* WARNING: SHA1Update() destroys data! */
Sha1Update (&(mh -> sha1), data, bytes); /* WARNING: SHA1Update() destroys data! */
#endif

return;
Expand Down Expand Up @@ -98,7 +98,7 @@ void multihash_finish (multihash *mh) {
(mh -> ed2k_s)[LEN_ED2K] = '\0';
#endif
#ifdef USE_SHA1
SHA1Final (buf, &(mh -> sha1));
Sha1Finalise (buf, &(mh -> sha1));
for (bytes = 0; bytes < LEN_SHA1 / 2; bytes++)
sprintf (mh -> sha1_s, "%s%02x", mh -> sha1_s, buf[bytes]);
(mh -> sha1_s)[LEN_SHA1] = '\0';
Expand Down
2 changes: 1 addition & 1 deletion libmultihash/multihash.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef struct {
char ed2k_s[LEN_ED2K + 1];
#endif
#ifdef USE_SHA1
SHA1_CTX sha1;
Sha1Context sha1;
char sha1_s[LEN_SHA1 + 1];
#endif
} multihash;
Expand Down
Loading

0 comments on commit d3ffe61

Please sign in to comment.