diff --git a/hash/blake.cpp b/hash/blake.cpp index 8e59e36..0496caa 100644 --- a/hash/blake.cpp +++ b/hash/blake.cpp @@ -147,17 +147,10 @@ G (int i, const auto j = permute[r][2 * i ]; const auto k = permute[r][2 * i + 1]; - a = a + b + (m[j] ^ traits::pi[k]); - d = cruft::rotater (d ^ a, traits::rotations[0]); - - c = c + d; - b = cruft::rotater (b ^ c, traits::rotations[1]); - - a = a + b + (m[k] ^ traits::pi[j]); - d = cruft::rotater (d ^ a, traits::rotations[2]); - - c = c + d; - b = cruft::rotater (b ^ c, traits::rotations[3]); + a = a + b + (m[j] ^ traits::pi[k]); d = cruft::rotater (d ^ a, traits::rotations[0]); + c = c + d; b = cruft::rotater (b ^ c, traits::rotations[1]); + a = a + b + (m[k] ^ traits::pi[j]); d = cruft::rotater (d ^ a, traits::rotations[2]); + c = c + d; b = cruft::rotater (b ^ c, traits::rotations[3]); } @@ -169,7 +162,7 @@ compress ( std::array::word_t,8> h, const typename traits::word_t m[16], const std::array::word_t,4> s, - uint64_t t + u64 t ) { typename traits::word_t t0 = t & 0xffffffff; typename traits::word_t t1 = (t >> 32u) & 0xffffffff; @@ -212,8 +205,8 @@ compress ( template typename blake::digest_t blake::operator() ( - cruft::view data, - cruft::view salt + cruft::view data, + cruft::view salt ) const { std::array::word_t, 4> fwd {}; @@ -228,7 +221,7 @@ blake::operator() ( template typename blake::digest_t blake::operator() ( - cruft::view data, + cruft::view data, const std::array::word_t, 4> salt ) const noexcept { auto h = traits::iv; @@ -241,10 +234,10 @@ blake::operator() ( // more than simple calls to hton would allow. union { word_t dw[16]; - uint8_t d08[16*sizeof(word_t)]; + u08 d08[16*sizeof(word_t)]; }; - uint64_t t = 0; + u64 t = 0; auto cursor = data.cbegin (); // perform the simple case where we're consuming whole blocks @@ -327,7 +320,6 @@ blake::operator() ( } - /////////////////////////////////////////////////////////////////////////////// template class cruft::crypto::hash::blake<256>; template class cruft::crypto::hash::blake<512>; diff --git a/hash/blake.hpp b/hash/blake.hpp index ce97eaf..6981abc 100644 --- a/hash/blake.hpp +++ b/hash/blake.hpp @@ -3,12 +3,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * Copyright 2018 Danny Robson + * Copyright 2018-2019 Danny Robson */ -#ifndef CRUFT_CRYPTO_HASH_BLAKE_HPP -#define CRUFT_CRYPTO_HASH_BLAKE_HPP +#pragma once +#include #include #include @@ -29,7 +29,7 @@ namespace cruft::crypto::hash { template <> struct traits<256> { - using word_t = uint32_t; + using word_t = u32; static const std::array iv; static const std::array pi; @@ -50,7 +50,7 @@ namespace cruft::crypto::hash { template <> struct traits<512> { - using word_t = uint64_t; + using word_t = u64; static const std::array iv; static const std::array pi; @@ -83,22 +83,20 @@ namespace cruft::crypto::hash { // size of the digest in bytes static const size_t digest_size = width / 8; - using digest_t = std::array; + using digest_t = std::array; digest_t operator() ( - cruft::view data, - cruft::view salt + cruft::view data, + cruft::view salt ) const; - digest_t operator() (cruft::view data, + digest_t operator() (cruft::view data, const std::array salt) const noexcept; - digest_t operator() (cruft::view data) const noexcept + digest_t operator() (cruft::view data) const noexcept { return (*this) (data, {0,0,0,0}); } }; } - -#endif