hash/md2: style

This commit is contained in:
Danny Robson 2019-02-09 19:21:42 +11:00
parent 46c0c81918
commit a2474e6b09
2 changed files with 9 additions and 11 deletions

View File

@ -63,13 +63,13 @@ transform (std::array<u08,16> &C, std::array<u08,48> &X) noexcept
// Setup the blocks
for (size_t i = 0; i < 16; ++i)
for (int i = 0; i < 16; ++i)
X[32 + i] = X[16 + i] ^ X[i];
// Perform the processing rounds
for (size_t i = 0, t = 0; i < 18; ++i) {
for (size_t j = 0; j < 48; ++j)
t = X[j] ^= S[t];
for (int i = 0, t = 0; i < 18; ++i) {
for (auto &j: X)
t = j ^= S[t];
t = (t + i) % 256;
}
@ -78,7 +78,7 @@ transform (std::array<u08,16> &C, std::array<u08,48> &X) noexcept
///////////////////////////////////////////////////////////////////////////////
MD2::digest_t
MD2::operator() (const cruft::view<const u08*> data) const noexcept
MD2::operator() (cruft::view<u08 const*> const data) const noexcept
{
// zero initialise the state vectors, and create a simple window `M' into
// the middle of the `X' state vector.

View File

@ -3,13 +3,13 @@
* 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 2013 Danny Robson <danny@nerdcruft.net>
* Copyright 2013-2019 Danny Robson <danny@nerdcruft.net>
*/
#ifndef CRUFT_CRYPTO_HASH_MD2_HPP
#define CRUFT_CRYPTO_HASH_MD2_HPP
#pragma once
#include <cruft/util/view.hpp>
#include <cruft/util/std.hpp>
#include <array>
#include <cstdint>
@ -22,8 +22,6 @@ namespace cruft::crypto::hash {
typedef std::array<uint8_t,16> digest_t;
public:
digest_t operator() (cruft::view<const uint8_t*>) const noexcept;
digest_t operator() (cruft::view<u08 const*>) const noexcept;
};
}
#endif