Skip to content
C11 SHA-2 implementation.
C Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
Makefile
README.md
hash-main.c
hmac-main.c
hmac-sha2.c
hmac-sha2.h
license.txt
run-tests.c
sha2.c more restricts Jul 19, 2019
sha2.h
tests.c
tests.h

README.md

Self-contained C11 SHA-2 implementation.

Features:

  • Self-contained (no external dependencies)
  • C11 only (platform-agnostic)
  • MIT-licensed
  • Includes test vectors (via make test)

Includes implementations of the following:

  • SHA-224
  • SHA-256
  • SHA-384
  • SHA-512
  • HMAC-SHA-256
  • HMAC-SHA-512

Usage

See tests.c for usage.

Use make test to run the test vectors.

Benchmarks

Benchmarks.

Partially unrolled compression makes this implementation faster than coreutils, but slower than the assembly-optimized, architecture and family-specific OpenSSL implementation.

> 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
You can’t perform that action at this time.