diff options
author | chriseth <c@ethdev.com> | 2016-10-25 21:31:36 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-10-25 21:32:37 +0800 |
commit | 2353da71c77dd235b35d16e7e024fa62408df610 (patch) | |
tree | 756604eaddf853a77c1fb04248f2305e1a33739a /libdevcore/SHA3.cpp | |
parent | af6afb0415761b53721f89c7f65064807f41cbd3 (diff) | |
parent | e3761bdf928e6a06e6620bc1b570d44264d24734 (diff) | |
download | dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar.gz dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar.bz2 dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar.lz dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar.xz dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.tar.zst dexon-solidity-2353da71c77dd235b35d16e7e024fa62408df610.zip |
Merge remote-tracking branch 'origin/develop' into release
Diffstat (limited to 'libdevcore/SHA3.cpp')
-rw-r--r-- | libdevcore/SHA3.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/libdevcore/SHA3.cpp b/libdevcore/SHA3.cpp index 584ef07e..3b12f39f 100644 --- a/libdevcore/SHA3.cpp +++ b/libdevcore/SHA3.cpp @@ -24,7 +24,7 @@ #include <cstdio> #include <cstdlib> #include <cstring> -#include "picosha2.h" + using namespace std; using namespace dev; @@ -49,12 +49,19 @@ namespace keccak #define decsha3(bits) \ int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t); +#define deckeccak(bits) \ + int keccak##bits(uint8_t*, size_t, const uint8_t*, size_t); + decshake(128) decshake(256) decsha3(224) decsha3(256) decsha3(384) decsha3(512) +deckeccak(224) +deckeccak(256) +deckeccak(384) +deckeccak(512) /******** The Keccak-f[1600] permutation ********/ @@ -192,6 +199,14 @@ static inline int hash(uint8_t* out, size_t outlen, if (outlen > (bits/8)) { \ return -1; \ } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x06); \ + } +#define defkeccak(bits) \ + int keccak##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ } @@ -205,17 +220,20 @@ defsha3(256) defsha3(384) defsha3(512) -} +/*** KECCAK FOFs ***/ +defkeccak(224) +defkeccak(256) +defkeccak(384) +defkeccak(512) -unsigned g_sha3Counter = 0; +} -bool sha3(bytesConstRef _input, bytesRef o_output) +bool keccak256(bytesConstRef _input, bytesRef o_output) { // FIXME: What with unaligned memory? if (o_output.size() != 32) return false; - ++g_sha3Counter; - keccak::sha3_256(o_output.data(), 32, _input.data(), _input.size()); + keccak::keccak256(o_output.data(), 32, _input.data(), _input.size()); // keccak::keccak(ret.data(), 32, (uint64_t const*)_input.data(), _input.size()); return true; } |