Skip to content

Commit

Permalink
Add SHA-1 message digest
Browse files Browse the repository at this point in the history
SHA-1 is an important message digest. E.g. it is used by git. This implementation features:
- optimized standard implementation. E.g. if compiled with -O -inline -release then there is not single function call or loop.
- if SSSE3 support is detected then a special assembler function is used. This gives a speedup of 1.4 on 32 bit and about 1.8 on 64 bit
The 64 bit implementation is a bit clumsy because of some issues with the dmd compiler (issues 6459 and 5355).
Supports 32 bit Windows and 32 bit and 64 Linux. MacOS X, FreeBSD are untested.
  • Loading branch information
redstar committed Aug 25, 2011
1 parent bf9eeee commit 4592a4b
Show file tree
Hide file tree
Showing 4 changed files with 1,242 additions and 3 deletions.
6 changes: 4 additions & 2 deletions posix.mak
Expand Up @@ -160,7 +160,7 @@ STD_MODULES = $(addprefix std/, algorithm array ascii base64 bigint \
encoding exception file format functional getopt gregorian \
json loader math mathspecial md5 metastrings mmfile numeric \
outbuffer parallelism path perf process random range regex \
regexp signals socket socketstream stdint stdio stdiobase \
regexp sha1 signals socket socketstream stdint stdio stdiobase \
stream string syserror system traits typecons typetuple uni \
uri utf variant xml zip zlib)

Expand All @@ -182,7 +182,9 @@ endif
EXTRA_DOCUMENTABLES += $(addprefix etc/c/,curl zlib) $(addprefix \
std/c/, fenv locale math process stdarg stddef stdio stdlib string \
time wcharh)
EXTRA_MODULES += $(EXTRA_DOCUMENTABLES) $(addprefix \
EXTRA_MODULES_DIGEST += $(EXTRA_DOCUMENTABLES) $(addprefix \
std/internal/digest/, sha1_SSSE3)
EXTRA_MODULES += $(EXTRA_MODULES_DIGEST) $(addprefix \
std/internal/math/, biguintcore biguintnoasm biguintx86 \
gammafunction errorfunction)

Expand Down

1 comment on commit 4592a4b

@dsimcha
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I do think it's silly, though, to put sha1 and md5 in separate modules, especially in the top level std package. I think we should schedule std.md5 for deprecation and do one of the following:

  1. Combine this code and std.md5 into a new module called std.hash or std.digest or something. This would be publicly imported by std.md5 while it still exists.
  2. Create a new package called std.hash and move this code to std.hash.sha1 and move md5 to std.hash.md5. (Or, s/hash/digest or whatever. The exact name isn't what's important.) Again, std.hash.md5 would be publicly imported by std.md5 until std.md5 is removed.

Please sign in to comment.