|
1 | 1 | # SHA256 |
2 | 2 |
|
3 | | -SHA-256 implementation to compliment a portable byte-oriented AES-256 |
4 | | -implementation in C at http://www.literatecode.com/aes256 |
| 3 | +This is an implementation of the SHA-256 secure hash algorithm defined in |
| 4 | +[FIPS 180-4](https://csrc.nist.gov/publications/detail/fips/180/4/final) |
5 | 5 |
|
6 | | -There is also a newer version in the [mark2](mark2) directory. This version is |
7 | | -cleaner and closer to a reference implementation. It no longer has |
8 | | -built-in support features for endianness, but you may easily adapt |
9 | | -the code to different endianness shall you need that. |
| 6 | +It is not a byte-oriented implementation. Still, it may complement |
| 7 | +a portable byte-oriented C version of AES-256 at |
| 8 | +[www.literatecode.com/aes256](http://www.literatecode.com/aes256) |
10 | 9 |
|
11 | | -Unlike the previous implementation, the Mark 2 one is formally |
12 | | -verifiable with [CBMC](http://www.cprover.org/cbmc/) |
13 | 10 |
|
| 11 | +## Compile |
| 12 | + |
| 13 | +This implementation supports `clang` (recommended) and `GCC` C compilers. |
| 14 | +Other compilers may also work with some minor code tweaking. Apologies for |
| 15 | +not caring about the seamless support of the MSVC compiler any longer. |
| 16 | +Check the legacy section below if you still need that. |
| 17 | + |
| 18 | +Use `make` or `sh sha256.c -c -o sha256.o` to compile into an object file |
| 19 | +that you may link with your project later. |
| 20 | + |
| 21 | +Use `make test` or `sh sha256.c -DSHA256_SELF_TEST__` to compile an |
| 22 | +executable binary that will perform a few known answer tests for SHA-256. |
| 23 | + |
| 24 | + |
| 25 | +## Formal verification |
| 26 | + |
| 27 | +We rely on [C Bounded Model Checker](http://www.cprover.org/cbmc/) to formally |
| 28 | +verify code properties. |
| 29 | + |
| 30 | +Use `make verify` to verify the self-testing code. |
| 31 | + |
| 32 | +If you want to focus verification on a single function, use |
| 33 | +`make verify FUNC=XYZ`, where `XYZ` is a function name. |
| 34 | + |
| 35 | +Check [https://github.com/diffblue/cbmc](https://github.com/diffblue/cbmc) |
| 36 | +for the latest version of CBMC. |
| 37 | + |
| 38 | + |
| 39 | +## History |
| 40 | + |
| 41 | +* 2010: The original code was written. |
| 42 | +* 2013: The original code was published on [GitHub](https://github.com/ilvn/SHA256). |
| 43 | +* 2014: The Mark 2 version was written (cleaner, closer to a reference implementation, formally verifiable). |
| 44 | +* 2017: The Mark 2 version was added to the repository. |
| 45 | +* 2022: The revamped Mark 2 version superseded the original code. |
| 46 | + |
| 47 | +### Legacy |
| 48 | + |
| 49 | +The original version is still available under the tag |
| 50 | +[legacy](https://github.com/ilvn/SHA256/releases/tag/legacy) and provided |
| 51 | +only for reference. Therefore, it is no longer supported or recommended. |
0 commit comments