Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revamp the original pure Erlang implementation
- Loading branch information
0 parents
commit 475111d
Showing
47 changed files
with
2,089 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*~ | ||
.eunit | ||
c_src/config.h | ||
c_src/*.o | ||
doc | ||
ebin | ||
priv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Steve Vinoski <vinoski@ieee.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2009-2011 Stephen B. Vinoski | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SHA-224, SHA-256, SHA-384, SHA-512 implemented in Erlang NIFs. | ||
|
||
## Description | ||
|
||
The **erlsha2** library application implements the SHA-2 Secure Hash Standard | ||
(SHA-224, SHA-256, SHA-384, SHA-512) using Erlang NIFs. It also | ||
provides pure Erlang implementations, though they are much slower than | ||
the C NIF implementations. | ||
|
||
See the following links for details: | ||
|
||
* (Secure Hash Standard)[href="http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf"] | ||
* (Wikipedia SHA1 article)[href="http://en.wikipedia.org/wiki/SHA1"] | ||
|
||
The code implemented here was written by simply following the | ||
algorithm descriptions provided in the standard. Provided functions | ||
follow the same style as those found in the standard Erlang `crypto` | ||
module: for each hash variant there's a simple function returning a | ||
binary digest and a set of three functions for initializing a digest | ||
context, updating the context with additional data to be hashed, and | ||
finalizing the context to get a binary digest result. | ||
|
||
## Building and Installing | ||
|
||
The **erlsha2** app is built with | ||
[rebar](https://github.com/basho/rebar), which must be in the command `PATH`. | ||
|
||
### Erlang Version | ||
|
||
The **erlsha2** app requires Erlang R14B or later. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CONFIG_HDR=c_src/config.h | ||
|
||
if [[ $1 = clean ]]; then | ||
rm -f $CONFIG_HDR | ||
exit 0 | ||
fi | ||
|
||
[[ -n "$CC" ]] | ||
|
||
tmpfile=`mktemp /tmp/erlsha2.XXXXXX` | ||
tmpcfile=${tmpfile}.c | ||
trap "rm -f $tmpfile $tmpcfile" EXIT | ||
mv $tmpfile $tmpcfile | ||
echo '#include <stdint.h>' > $tmpcfile | ||
if $CC $CFLAGS -c -o /dev/null $tmpcfile 2>/dev/null ; then | ||
echo '#define HAVE_STDINT_H 1' > $CONFIG_HDR | ||
else | ||
echo '#include <inttypes.h>' > $tmpcfile | ||
if $CC $CFLAGS -c -o /dev/null $tmpcfile 2>/dev/null ; then | ||
echo '#define HAVE_INTTYPES_H 1' > $CONFIG_HDR | ||
else | ||
echo 'neither <stdint.h> nor <inttypes.h> found, aborting' 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
v='16#12345678' | ||
prog="case <<$v:32/native>> of <<$v:32/big>> -> 0; <<$v:32/little>> -> 1 end" | ||
if erl -noinput -noshell -eval "halt($prog)."; then | ||
echo '#define WORDS_BIGENDIAN 1' >> $CONFIG_HDR | ||
else | ||
echo '#undef WORDS_BIGENDIAN' >> $CONFIG_HDR | ||
fi | ||
|
||
exit 0 |
Oops, something went wrong.