Skip to content

Commit

Permalink
Removed trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
marcizhu committed Jul 24, 2019
1 parent 92dc9b3 commit 6460289
Show file tree
Hide file tree
Showing 61 changed files with 194 additions and 284 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ public:
// If the requested output size is not supported by the algorithm, std::runtime_error will be thrown.
template<typename H=HashProvider, typename std::enable_if<!detail::is_xof<H>::value>::type* = nullptr>
hasher(size_t hashsize);

// Absorbs bytes from a C-style pointer to character buffer
template<typename T, typename std::enable_if<detail::is_byte<T>::value>::type* = nullptr>
inline hasher& absorb(const T* data, size_t len);

// Absorbs bytes from std::basic_string
template<typename T,
typename std::enable_if<detail::is_byte<T>::value
typename std::enable_if<detail::is_byte<T>::value
&& !std::is_same<T, std::string::value_type>::value>::type* = nullptr>
inline hasher& absorb(const std::basic_string<T>& str);

Expand All @@ -112,43 +112,43 @@ public:
// Absorbs bytes from std::istream
template<typename T, typename std::enable_if<detail::is_byte<T>::value>::type* = nullptr>;
inline hasher& absorb(std::basic_istream<T>& istr);

// Absorbs bytes from an iterator sequence
template<typename IT>
inline hasher& absorb(IT begin, IT end);

// In case HashProvider is an extendable output function, squeeze <len> bytes from absorbed data
// into user-provided preallocated buffer.
template<typename T, typename H=HashProvider,
typename std::enable_if<detail::is_byte<T>::value && detail::is_xof<H>::value>::type* = nullptr>
inline void squeeze(T* buf, size_t len);

// In case HashProvider is an extendable output function, squeeze <len> bytes from absorbed data
// and write them into the output iterator.
template<typename OI, typename H=HashProvider,
template<typename OI, typename H=HashProvider,
typename std::enable_if<detail::is_xof<H>::value>::type* = nullptr>
inline void squeeze(size_t len, OI it);

// In case HashProvider is an extendable output function, squeeze <len> bytes from absorbed data
// and return them as a hex string.
template<typename H=HashProvider, typename std::enable_if<detail::is_xof<H>::value>::type* = nullptr>
inline std::string hexsqueeze(size_t len);

// In case HashProvider is a hash function, output binary digest to user-provided preallocated buffer.
template<typename T, typename H=HashProvider,
typename std::enable_if<detail::is_byte<T>::value && !detail::is_xof<H>::value>::type* = nullptr>
inline void digest(T* buf, size_t len) const;
// In case HashProvider is a hash function, generates binary digest from absorbed data

// In case HashProvider is a hash function, generates binary digest from absorbed data
// and write it via output iterator.
template<typename OI, typename H=HashProvider,
template<typename OI, typename H=HashProvider,
typename std::enable_if<!detail::is_xof<H>::value>::type* = nullptr>
inline void digest(OI it) const;

// In case HashProvider is a hash function, returns hex digest of absorbed data.
template<typename H=HashProvider, typename std::enable_if<!detail::is_xof<H>::value>::type* = nullptr>
inline std::string hexdigest() const;

// Resets the state to start new digest computation.
// If resetParameters is true, all customization parameters such as salt will also be cleared.
inline void reset(bool resetParameters = false);
Expand Down
3 changes: 1 addition & 2 deletions algorithm/blake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ typedef hasher<detail::blake_provider, mixin::blake_mixin> blake;

} // namespace digestpp

#endif // DIGESTPP_ALGORITHM_BLAKE_HPP

#endif // DIGESTPP_ALGORITHM_BLAKE_HPP
7 changes: 3 additions & 4 deletions algorithm/blake2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace digestpp
*
* @defaultsize 512 bits
*
* @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes),
* @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes),
* or is not within the supported range
*
* @mixinparams salt, personalization, key
Expand Down Expand Up @@ -53,7 +53,7 @@ typedef hasher<detail::blake2_provider<uint64_t, detail::blake2_type::hash>, mix
*
* @defaultsize 256 bits
*
* @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes),
* @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes),
* or is not within the supported range
*
* @mixinparams salt, personalization, key
Expand Down Expand Up @@ -193,5 +193,4 @@ typedef hasher<detail::blake2_provider<uint32_t, detail::blake2_type::xof>, mixi

} // namespace digestpp

#endif // DIGESTPP_ALGORITHM_BLAKE2_HPP

#endif // DIGESTPP_ALGORITHM_BLAKE2_HPP
5 changes: 2 additions & 3 deletions algorithm/detail/blake2_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class blake2_provider

inline void update(const unsigned char* data, size_t len)
{
detail::absorb_bytes(data, len, N / 4, N / 4 + 1, m.data(), pos, total,
detail::absorb_bytes(data, len, N / 4, N / 4 + 1, m.data(), pos, total,
[this](const unsigned char* data, size_t len) { transform(data, len, false); });
}

Expand Down Expand Up @@ -337,5 +337,4 @@ class blake2_provider

} // namespace digestpp

#endif

#endif
17 changes: 8 additions & 9 deletions algorithm/detail/blake_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@ namespace blake_functions
{
static inline void G(int r, int i, uint32_t& a, uint32_t& b, uint32_t& c, uint32_t& d, uint32_t* M)
{
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i]]
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i]]
^ blake_constants<void>::c[blake_constants<void>::S[r % 10][2 * i + 1]]);
d = rotate_right(d ^ a, 16);
c = c + d;
b = rotate_right(b ^ c, 12);
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i + 1]]
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i + 1]]
^ blake_constants<void>::c[blake_constants<void>::S[r % 10][2 * i]]);
d = rotate_right(d ^ a, 8);
c = c + d;
b = rotate_right(b ^ c, 7);
}

static inline void G(int r, int i, uint64_t& a, uint64_t& b, uint64_t& c, uint64_t& d, uint64_t* M)
static inline void G(int r, int i, uint64_t& a, uint64_t& b, uint64_t& c, uint64_t& d, uint64_t* M)
{
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i]]
^ blake_constants<void>::c512[blake_constants<void>::S[r % 10][2 * i + 1]]);
d = rotate_right(d ^ a, 32);
c = c + d;
b = rotate_right(b ^ c, 25);
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i + 1]]
a = a + b + (M[blake_constants<void>::S[r % 10][2 * i + 1]]
^ blake_constants<void>::c512[blake_constants<void>::S[r % 10][2 * i]]);
d = rotate_right(d ^ a, 16);
c = c + d;
b = rotate_right(b ^ c, 11);
}

template<typename T>
static inline void round(int r, T* M, T* v)
static inline void round(int r, T* M, T* v)
{
G(r, 0, v[0], v[4], v[8], v[12], M);
G(r, 1, v[1], v[5], v[9], v[13], M);
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace blake_functions
if (saltlen)
for (int i = 0; i < 4; i++)
H[8 + i] = byteswap(reinterpret_cast<const T*>(salt)[i]);
else
else
H[8] = H[9] = H[10] = H[11] = 0;
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ class blake_provider

inline void update(const unsigned char* data, size_t len)
{
detail::absorb_bytes(data, len, block_bytes(), block_bytes(), m.data(), pos, total,
detail::absorb_bytes(data, len, block_bytes(), block_bytes(), m.data(), pos, total,
[this](const unsigned char* data, size_t len) { transform(data, len, false, false); });
}

Expand Down Expand Up @@ -298,5 +298,4 @@ class blake_provider

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/blake2_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ enum class blake2_type

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/blake_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ const uint32_t blake_constants<T>::S[10][16] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/groestl_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,5 +554,4 @@ const uint64_t groestl_constants<V>::T[8][256] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/jh_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ const uint64_t jh_constants<T>::C[168] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/kupyna_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,5 +554,4 @@ const uint64_t kupyna_constants<V>::T[8][256] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/md5_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ const unsigned char md5_constants<T>::S[64] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/sha1_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ const uint32_t sha1_constants<T>::K[4] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/sha2_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,4 @@ const uint32_t sha256_constants<T>::K[64] = {

} // namespace digestpp

#endif

#endif
6 changes: 2 additions & 4 deletions algorithm/detail/constants/sha3_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct sha3_constants

template<typename T>
const uint64_t sha3_constants<T>::RC[24] = {
0x0000000000000001ull, 0x0000000000008082ull, 0x800000000000808Aull, 0x8000000080008000ull,
0x0000000000000001ull, 0x0000000000008082ull, 0x800000000000808Aull, 0x8000000080008000ull,
0x000000000000808Bull, 0x0000000080000001ull, 0x8000000080008081ull, 0x8000000000008009ull,
0x000000000000008Aull, 0x0000000000000088ull, 0x0000000080008009ull, 0x000000008000000Aull,
0x000000008000808Bull, 0x800000000000008Bull, 0x8000000000008089ull, 0x8000000000008003ull,
Expand All @@ -32,6 +32,4 @@ const uint64_t sha3_constants<T>::RC[24] = {

} // namespace digestpp

#endif // DIGESTPP_PROVIDERS_SHA3_CONSTANTS_HPP


#endif // DIGESTPP_PROVIDERS_SHA3_CONSTANTS_HPP
13 changes: 4 additions & 9 deletions algorithm/detail/constants/skein_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct skein_constants
};

template<typename T>
const unsigned skein_constants<T>::C4[8][2] = {
const unsigned skein_constants<T>::C4[8][2] = {
{ 14, 16 }, { 52, 57 }, { 23, 40 }, { 5, 37 }, { 25, 33 }, { 46, 12 }, { 58, 22 }, { 32, 32 }
};

Expand All @@ -50,9 +50,9 @@ const unsigned skein_constants<T>::I4[8][4]= {

template<typename T>
const unsigned skein_constants<T>::I8[8][8]= {
{ 0, 1, 2, 3, 4, 5, 6, 7 }, { 2, 1, 4, 7, 6, 5, 0, 3 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }, { 2, 1, 4, 7, 6, 5, 0, 3 },
{ 4, 1, 6, 3, 0, 5, 2, 7 }, { 6, 1, 0, 7, 2, 5, 4, 3 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }, { 2, 1, 4, 7, 6, 5, 0, 3 },
{ 0, 1, 2, 3, 4, 5, 6, 7 }, { 2, 1, 4, 7, 6, 5, 0, 3 },
{ 4, 1, 6, 3, 0, 5, 2, 7 }, { 6, 1, 0, 7, 2, 5, 4, 3 }
};

Expand All @@ -72,9 +72,4 @@ const unsigned skein_constants<T>::I16[8][16] = {

} // namespace digestpp

#endif





#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/streebog_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,5 +583,4 @@ const uint64_t streebog_constants<V>::RC[12][8] = {

} // namespace digestpp

#endif

#endif
3 changes: 1 addition & 2 deletions algorithm/detail/constants/whirlpool_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,5 +568,4 @@ const uint64_t whirlpool_constants<V>::T[8][256] = {

} // namespace digestpp

#endif

#endif
15 changes: 7 additions & 8 deletions algorithm/detail/groestl_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ namespace groestl_functions
x[idx] ^= (static_cast<uint64_t>(idx) << 4) ^ i;

for (int c = R - 1; c >= 0; c--)
y[c] = groestl_constants<void>::T[0][static_cast<unsigned char>(x[(c + 0) % R])]
^ groestl_constants<void>::T[1][static_cast<unsigned char>(x[(c + 1) % R] >> 8)]
^ groestl_constants<void>::T[2][static_cast<unsigned char>(x[(c + 2) % R] >> 16)]
y[c] = groestl_constants<void>::T[0][static_cast<unsigned char>(x[(c + 0) % R])]
^ groestl_constants<void>::T[1][static_cast<unsigned char>(x[(c + 1) % R] >> 8)]
^ groestl_constants<void>::T[2][static_cast<unsigned char>(x[(c + 2) % R] >> 16)]
^ groestl_constants<void>::T[3][static_cast<unsigned char>(x[(c + 3) % R] >> 24)]
^ groestl_constants<void>::T[4][static_cast<unsigned char>(x[(c + 4) % R] >> 32)]
^ groestl_constants<void>::T[4][static_cast<unsigned char>(x[(c + 4) % R] >> 32)]
^ groestl_constants<void>::T[5][static_cast<unsigned char>(x[(c + 5) % R] >> 40)]
^ groestl_constants<void>::T[6][static_cast<unsigned char>(x[(c + 6) % R] >> 48)]
^ groestl_constants<void>::T[7][static_cast<unsigned char>(x[(c + (R == 16 ? 11 : 7)) % R] >> 56)];
Expand All @@ -43,7 +43,7 @@ namespace groestl_functions
x[idx] ^= (0xffffffffffffffffull - (static_cast<uint64_t>(idx) << 60)) ^ i;

for (int c = R - 1; c >= 0; c--)
y[c] = groestl_constants<void>::T[0][static_cast<unsigned char>(x[(c + 1) % R])]
y[c] = groestl_constants<void>::T[0][static_cast<unsigned char>(x[(c + 1) % R])]
^ groestl_constants<void>::T[1][static_cast<unsigned char>(x[(c + 3) % R] >> 8)]
^ groestl_constants<void>::T[2][static_cast<unsigned char>(x[(c + 5) % R] >> 16)]
^ groestl_constants<void>::T[3][static_cast<unsigned char>(x[(c + (R == 16 ? 11 : 7)) % R] >> 24)]
Expand Down Expand Up @@ -126,7 +126,7 @@ class groestl_provider

inline void update(const unsigned char* data, size_t len)
{
detail::absorb_bytes(data, len, block_bytes(), block_bytes(), m.data(), pos, total,
detail::absorb_bytes(data, len, block_bytes(), block_bytes(), m.data(), pos, total,
[this](const unsigned char* data, size_t len) { transform(data, len); });
}

Expand Down Expand Up @@ -198,5 +198,4 @@ class groestl_provider

} // namespace digestpp

#endif

#endif
Loading

0 comments on commit 6460289

Please sign in to comment.