aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2019-08-25-sha2.md
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2021-10-14 12:47:50 -0400
committerPaul Duncan <pabs@pablotron.org>2021-10-14 12:47:50 -0400
commit4b6c0e31385f5f27a151088c0a2b614495c4e589 (patch)
tree12243cdcd00704bc1a9d94ac9cc128459417370c /content/posts/2019-08-25-sha2.md
downloadpablotron.org-4b6c0e31385f5f27a151088c0a2b614495c4e589.tar.bz2
pablotron.org-4b6c0e31385f5f27a151088c0a2b614495c4e589.zip
initial commit, including theme
Diffstat (limited to 'content/posts/2019-08-25-sha2.md')
-rw-r--r--content/posts/2019-08-25-sha2.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/content/posts/2019-08-25-sha2.md b/content/posts/2019-08-25-sha2.md
new file mode 100644
index 0000000..fdeb6d4
--- /dev/null
+++ b/content/posts/2019-08-25-sha2.md
@@ -0,0 +1,49 @@
+---
+date: "2019-08-25T07:35:23Z"
+title: Self-Contained C11 SHA-2 Implementation
+---
+
+Last month I wrote a [C11][] [SHA-2][] implementation.
+
+Features:
+* Self-contained (no external dependencies)
+* C11 only (platform-agnostic)
+* MIT-licensed
+* Includes [test vectors][] (via `make test`).
+
+The code is available [here][].
+
+It includes implementations of the following:
+* SHA-224
+* SHA-256
+* SHA-384
+* SHA-512
+* HMAC-SHA256
+* HMAC-SHA512
+
+This implementation is faster than [coreutils][], but slower than the
+[assembly-optimized, processor family-specific OpenSSL SHA-2
+implementation][openssl-asm-sha]:
+
+```
+> time -p ./sha256 ~/Videos/8x*avi > /dev/null
+rleal 9.39
+user 9.10
+sys 0.29
+> time -p sha256sum ~/Videos/8x*avi > /dev/null
+real 12.04
+user 11.73
+sys 0.31
+> time -p openssl sha256 ~/Videos/8x*avi > /dev/null
+real 6.36
+user 6.01
+sys 0.32
+```
+
+ [sha-2]: https://en.wikipedia.org/wiki/SHA-2 "Secure Hash Algorithm 2"
+ [c11]: https://en.wikipedia.org/wiki/C11_(C_standard_revision) "C11 standard of the C programming language"
+ [coreutils]: https://www.gnu.org/software/coreutils/ "GNU core utilities"
+ [openssl-asm-sha]: https://github.com/openssl/openssl/tree/master/crypto/sha/asm "assembly-optimized OpenSSL SHA-2 implementation."
+ [here]: https://github.com/pablotron/sha2 "C11 SHA-2 implementation."
+ [test vectors]: https://www.di-mgt.com.au/sha_testvectors.html "SHA test vectors."
+