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 // 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]; X[32 + i] = X[16 + i] ^ X[i];
// Perform the processing rounds // Perform the processing rounds
for (size_t i = 0, t = 0; i < 18; ++i) { for (int i = 0, t = 0; i < 18; ++i) {
for (size_t j = 0; j < 48; ++j) for (auto &j: X)
t = X[j] ^= S[t]; t = j ^= S[t];
t = (t + i) % 256; t = (t + i) % 256;
} }
@ -78,7 +78,7 @@ transform (std::array<u08,16> &C, std::array<u08,48> &X) noexcept
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
MD2::digest_t 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 // zero initialise the state vectors, and create a simple window `M' into
// the middle of the `X' state vector. // 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 * 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/. * 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 #pragma once
#define CRUFT_CRYPTO_HASH_MD2_HPP
#include <cruft/util/view.hpp> #include <cruft/util/view.hpp>
#include <cruft/util/std.hpp>
#include <array> #include <array>
#include <cstdint> #include <cstdint>
@ -22,8 +22,6 @@ namespace cruft::crypto::hash {
typedef std::array<uint8_t,16> digest_t; typedef std::array<uint8_t,16> digest_t;
public: public:
digest_t operator() (cruft::view<const uint8_t*>) const noexcept; digest_t operator() (cruft::view<u08 const*>) const noexcept;
}; };
} }
#endif