Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/chapter11_07a/src/app/led/app_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
#endif

void app_led_task_background (void* pv);
void app_led_task_background(void* pv);
void app_led_task_toggle_led0(void* pv);

#if defined(__cplusplus)
Expand Down
6 changes: 3 additions & 3 deletions examples/chapter11_07a/src/app/pi_spigot/pi_spigot.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////
// //
// Copyright Iliass Mahjoub 2022. //
// Copyright Christopher Kormanyos 2019 - 2025. //
// Copyright Christopher Kormanyos 2019 - 2026. //
// Distributed under the Boost Software License, //
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
Expand Down Expand Up @@ -49,11 +49,11 @@ namespace local
return instance;
}

auto pi_output_digits10 = static_cast<std::uint32_t>(UINT8_C(0));
auto pi_output_digits10 = std::uint32_t { UINT8_C(0) };

using benchmark_port_type = ::mcal::benchmark::benchmark_port_type;

constexpr auto pi_spigot_input_start_address = static_cast<mcal_sram_uintptr_t>(UINT8_C(0));
constexpr auto pi_spigot_input_start_address = mcal_sram_uintptr_t { UINT8_C(0) };

using pi_spigot_input_container_type = mcal::memory::sram::array<std::uint32_t,
pi_spigot_type::get_input_static_size(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////
// //
// Copyright Christopher Kormanyos 2023 - 2025. //
// Copyright Christopher Kormanyos 2023 - 2026. //
// Distributed under the Boost Software License, //
// Version 1.0. (See accompanying file LICENSE_1_0.txt //
// or copy at http://www.boost.org/LICENSE_1_0.txt) //
Expand All @@ -18,7 +18,7 @@ auto pi_lcd_progress(const std::uint32_t pi_output_digits10) -> void;

auto pi_lcd_progress(const std::uint32_t pi_output_digits10) -> void
{
char p_str[std::size_t { UINT8_C(20) }];
char p_str[std::size_t { UINT8_C(16) }];

{
std::fill(p_str, p_str + sizeof(p_str), char { INT8_C(0) });
Expand Down
18 changes: 9 additions & 9 deletions examples/chapter11_07a/src/math/checksums/hash/hash_base.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2025.
// Copyright Christopher Kormanyos 2013 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -63,7 +63,7 @@

if(message_index == message_buffer_static_size())
{
my_perform_algorithm();
perform_algorithm();
}

process_chunk_size = (std::min)(static_cast<count_type>(count - process_index),
Expand Down Expand Up @@ -95,7 +95,7 @@

if(message_top > message_buffer_static_size())
{
my_perform_algorithm();
perform_algorithm();
}

// Encode the total number of bits in the final transform buffer.
Expand Down Expand Up @@ -131,7 +131,7 @@
);
}

my_perform_algorithm();
perform_algorithm();
}

auto get_result(typename result_type::pointer result) -> void
Expand Down Expand Up @@ -185,15 +185,15 @@
);
}

virtual auto perform_algorithm() -> void = 0;
virtual auto my_perform_algorithm() -> void = 0;

auto my_perform_algorithm() -> void
auto perform_algorithm() -> void
{
this->perform_algorithm();
this->my_perform_algorithm();

message_index = static_cast<std::uint_least32_t>(UINT8_C(0));
message_index = std::uint_least32_t { UINT8_C(0) };

message_buffer.fill(static_cast<std::uint8_t>(UINT8_C(0)));
message_buffer.fill(std::uint8_t { UINT8_C(0) });
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Christopher Kormanyos 2013 - 2025.
// Copyright Christopher Kormanyos 2013 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down
37 changes: 20 additions & 17 deletions examples/chapter11_07a/src/math/checksums/hash/hash_sha1.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2025.
// Copyright Christopher Kormanyos 2013 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -46,17 +46,17 @@
{
base_class_type::initialize();

base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(0))] = static_cast<std::uint32_t>(UINT32_C(0x67452301));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(1))] = static_cast<std::uint32_t>(UINT32_C(0xEFCDAB89));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(2))] = static_cast<std::uint32_t>(UINT32_C(0x98BADCFE));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(3))] = static_cast<std::uint32_t>(UINT32_C(0x10325476));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(4))] = static_cast<std::uint32_t>(UINT32_C(0xC3D2E1F0));
base_class_type::transform_context[std::size_t { UINT8_C(0) }] = std::uint32_t { UINT32_C(0x67452301) };
base_class_type::transform_context[std::size_t { UINT8_C(1) }] = std::uint32_t { UINT32_C(0xEFCDAB89) };
base_class_type::transform_context[std::size_t { UINT8_C(2) }] = std::uint32_t { UINT32_C(0x98BADCFE) };
base_class_type::transform_context[std::size_t { UINT8_C(3) }] = std::uint32_t { UINT32_C(0x10325476) };
base_class_type::transform_context[std::size_t { UINT8_C(4) }] = std::uint32_t { UINT32_C(0xC3D2E1F0) };
}

private:
static const std::array<transform_function_type, static_cast<std::size_t>(UINT8_C(4))> transform_functions;

auto perform_algorithm() -> void override;
auto my_perform_algorithm() -> void override;
};

const std::array<hash_sha1::transform_function_type, static_cast<std::size_t>(UINT8_C(4))>
Expand All @@ -68,18 +68,18 @@
[](const std::uint32_t* p) -> std::uint32_t { return (static_cast<std::uint32_t>( p[1U] ^ p[2U]) ^ p[3U]); }
};

auto hash_sha1::perform_algorithm() -> void
auto hash_sha1::my_perform_algorithm() -> void
{
// Apply the hash transformation algorithm to a full data block.

using transform_constants_array_type = std::array<std::uint32_t, static_cast<std::size_t>(UINT8_C(4))>;

const transform_constants_array_type transform_constants
{
static_cast<std::uint32_t>(UINT32_C(0x5A827999)),
static_cast<std::uint32_t>(UINT32_C(0x6ED9EBA1)),
static_cast<std::uint32_t>(UINT32_C(0x8F1BBCDC)),
static_cast<std::uint32_t>(UINT32_C(0xCA62C1D6))
std::uint32_t { UINT32_C(0x5A827999) },
std::uint32_t { UINT32_C(0x6ED9EBA1) },
std::uint32_t { UINT32_C(0x8F1BBCDC) },
std::uint32_t { UINT32_C(0xCA62C1D6) }
};

using transform_block_type = std::array<std::uint32_t, static_cast<std::size_t>(UINT8_C(16))>;
Expand Down Expand Up @@ -139,11 +139,14 @@
}

// Update the hash state with the transformation results.
std::transform(base_class_type::transform_context.cbegin(),
base_class_type::transform_context.cend (),
hash_tmp.cbegin (),
base_class_type::transform_context.begin (),
std::plus<std::uint32_t> ());
std::transform
(
base_class_type::transform_context.cbegin(),
base_class_type::transform_context.cend(),
hash_tmp.cbegin(),
base_class_type::transform_context.begin(),
std::plus<std::uint32_t>()
);
}

} } } // namespace math::checksums::hash
Expand Down
77 changes: 36 additions & 41 deletions examples/chapter11_07a/src/math/checksums/hash/hash_sha256.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2025.
// Copyright Christopher Kormanyos 2013 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -17,15 +17,12 @@

namespace math { namespace checksums { namespace hash {

template<typename CountType>
class hash_sha256 : public hash_base<CountType,
static_cast<std::uint16_t>(UINT16_C(256)),
class hash_sha256 : public hash_base<static_cast<std::uint16_t>(UINT16_C(256)),
static_cast<std::uint16_t>(UINT8_C(64)),
static_cast<std::uint16_t>(UINT8_C(64))>
{
private:
using base_class_type = hash_base<CountType,
static_cast<std::uint16_t>(UINT16_C(256)),
using base_class_type = hash_base<static_cast<std::uint16_t>(UINT16_C(256)),
static_cast<std::uint16_t>(UINT8_C(64)),
static_cast<std::uint16_t>(UINT8_C(64))>;

Expand All @@ -49,27 +46,26 @@
{
base_class_type::initialize();

base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(0))] = static_cast<std::uint32_t>(UINT32_C(0x6A09E667));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(1))] = static_cast<std::uint32_t>(UINT32_C(0xBB67AE85));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(2))] = static_cast<std::uint32_t>(UINT32_C(0x3C6EF372));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(3))] = static_cast<std::uint32_t>(UINT32_C(0xA54FF53A));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(4))] = static_cast<std::uint32_t>(UINT32_C(0x510E527F));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(5))] = static_cast<std::uint32_t>(UINT32_C(0x9B05688C));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(6))] = static_cast<std::uint32_t>(UINT32_C(0x1F83D9AB));
base_class_type::transform_context[static_cast<std::size_t>(UINT8_C(7))] = static_cast<std::uint32_t>(UINT32_C(0x5BE0CD19));
base_class_type::transform_context[std::size_t { UINT8_C(0) }] = std::uint32_t { UINT32_C(0x6A09E667) };
base_class_type::transform_context[std::size_t { UINT8_C(1) }] = std::uint32_t { UINT32_C(0xBB67AE85) };
base_class_type::transform_context[std::size_t { UINT8_C(2) }] = std::uint32_t { UINT32_C(0x3C6EF372) };
base_class_type::transform_context[std::size_t { UINT8_C(3) }] = std::uint32_t { UINT32_C(0xA54FF53A) };
base_class_type::transform_context[std::size_t { UINT8_C(4) }] = std::uint32_t { UINT32_C(0x510E527F) };
base_class_type::transform_context[std::size_t { UINT8_C(5) }] = std::uint32_t { UINT32_C(0x9B05688C) };
base_class_type::transform_context[std::size_t { UINT8_C(6) }] = std::uint32_t { UINT32_C(0x1F83D9AB) };
base_class_type::transform_context[std::size_t { UINT8_C(7) }] = std::uint32_t { UINT32_C(0x5BE0CD19) };
}

private:
auto perform_algorithm() -> void override;
auto my_perform_algorithm() -> void override;

static constexpr auto transform_function1(std::uint32_t x) -> std::uint32_t; // BSIG0
static constexpr auto transform_function2(std::uint32_t x) -> std::uint32_t; // BSIG1
static constexpr auto transform_function3(std::uint32_t x) -> std::uint32_t; // SSIG0
static constexpr auto transform_function4(std::uint32_t x) -> std::uint32_t; // SSIG1
};

template <typename my_count_type>
auto hash_sha256<my_count_type>::perform_algorithm() -> void
auto hash_sha256::my_perform_algorithm() -> void
{
// Apply the hash transformation algorithm to a full data block.

Expand Down Expand Up @@ -163,29 +159,31 @@
)
);

hash_tmp[static_cast<std::size_t>(UINT8_C(7))] = hash_tmp[static_cast<std::size_t>(UINT8_C(6))];
hash_tmp[static_cast<std::size_t>(UINT8_C(6))] = hash_tmp[static_cast<std::size_t>(UINT8_C(5))];
hash_tmp[static_cast<std::size_t>(UINT8_C(5))] = hash_tmp[static_cast<std::size_t>(UINT8_C(4))];
hash_tmp[static_cast<std::size_t>(UINT8_C(4))] = static_cast<std::uint32_t>
(
hash_tmp[static_cast<std::size_t>(UINT8_C(3))] + tmp1
);
hash_tmp[static_cast<std::size_t>(UINT8_C(3))] = hash_tmp[static_cast<std::size_t>(UINT8_C(2))];
hash_tmp[static_cast<std::size_t>(UINT8_C(2))] = hash_tmp[static_cast<std::size_t>(UINT8_C(1))];
hash_tmp[static_cast<std::size_t>(UINT8_C(1))] = hash_tmp[static_cast<std::size_t>(UINT8_C(0))];
hash_tmp[static_cast<std::size_t>(UINT8_C(0))] = static_cast<std::uint32_t>(tmp1 + tmp2);
hash_tmp[std::size_t { UINT8_C(7) }] = hash_tmp[std::size_t { UINT8_C(6) }];
hash_tmp[std::size_t { UINT8_C(6) }] = hash_tmp[std::size_t { UINT8_C(5) }];
hash_tmp[std::size_t { UINT8_C(5) }] = hash_tmp[std::size_t { UINT8_C(4) }];
hash_tmp[std::size_t { UINT8_C(4) }] = static_cast<std::uint32_t>
(
hash_tmp[static_cast<std::size_t>(UINT8_C(3))] + tmp1
);
hash_tmp[std::size_t { UINT8_C(3) }] = hash_tmp[std::size_t { UINT8_C(2) }];
hash_tmp[std::size_t { UINT8_C(2) }] = hash_tmp[std::size_t { UINT8_C(1) }];
hash_tmp[std::size_t { UINT8_C(1) }] = hash_tmp[std::size_t { UINT8_C(0) }];
hash_tmp[std::size_t { UINT8_C(0) }] = static_cast<std::uint32_t>(tmp1 + tmp2);
}

// Update the hash state with the transformation results.
std::transform(base_class_type::transform_context.cbegin(),
base_class_type::transform_context.cend (),
hash_tmp.cbegin (),
base_class_type::transform_context.begin (),
std::plus<std::uint32_t> ());
std::transform
(
base_class_type::transform_context.cbegin(),
base_class_type::transform_context.cend(),
hash_tmp.cbegin(),
base_class_type::transform_context.begin(),
std::plus<std::uint32_t>()
);
}

template <typename my_count_type>
constexpr auto hash_sha256<my_count_type>::transform_function1(std::uint32_t x) -> std::uint32_t
constexpr auto hash_sha256::transform_function1(std::uint32_t x) -> std::uint32_t
{
// BSIG0
return
Expand All @@ -197,8 +195,7 @@
);
}

template <typename my_count_type>
constexpr auto hash_sha256<my_count_type>::transform_function2(std::uint32_t x) -> std::uint32_t
constexpr auto hash_sha256::transform_function2(std::uint32_t x) -> std::uint32_t
{
// BSIG1
return
Expand All @@ -210,8 +207,7 @@
);
}

template <typename my_count_type>
constexpr auto hash_sha256<my_count_type>::transform_function3(std::uint32_t x) -> std::uint32_t
constexpr auto hash_sha256::transform_function3(std::uint32_t x) -> std::uint32_t
{
// SSIG0
return
Expand All @@ -223,8 +219,7 @@
);
}

template <typename my_count_type>
constexpr auto hash_sha256<my_count_type>::transform_function4(std::uint32_t x) -> std::uint32_t
constexpr auto hash_sha256::transform_function4(std::uint32_t x) -> std::uint32_t
{
// SSIG1
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2013 - 2023.
// Copyright Christopher Kormanyos 2013 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -20,8 +20,15 @@
using count_type = std::uint32_t;

hash_stream_base() = default;

hash_stream_base(const hash_stream_base&) = default;
hash_stream_base(hash_stream_base&&) = default;

virtual ~hash_stream_base() = default;

auto operator=(const hash_stream_base&) -> hash_stream_base& = default;
auto operator=(hash_stream_base&&) -> hash_stream_base& = default;

virtual auto initialize() -> void = 0;

virtual auto process(const std::uint8_t* message, const count_type count) -> void = 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/chapter11_07a/target/micros/avr/make/avr_flags.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright Christopher Kormanyos 2007 - 2025.
# Copyright Christopher Kormanyos 2007 - 2026.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -12,7 +12,7 @@
GCC_TARGET = avr
GCC_PREFIX = avr

GCC_VERSION = 15.1.0
GCC_VERSION = 15.2.0

TGT_SUFFIX = elf

Expand All @@ -31,7 +31,7 @@ TGT_ALLFLAGS := $(TGT_ALLFLAGS)

INC_PREFIX := -isystem
STD_C := c11
STD_CPP := c++20
STD_CPP := c++23

else

Expand Down
1 change: 1 addition & 0 deletions ref_app/ref_app.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,7 @@
<ClInclude Include="src\math\checksums\hash\hash_detail.h" />
<ClInclude Include="src\math\checksums\hash\hash_sha1.h" />
<ClInclude Include="src\math\checksums\hash\hash_sha256.h" />
<ClInclude Include="src\math\checksums\hash\hash_stream_base.h" />
<ClInclude Include="src\math\constants\constants.h" />
<ClInclude Include="src\math\constants\constant_functions.h" />
<ClInclude Include="src\math\constants\pi_spigot_base.h" />
Expand Down
3 changes: 3 additions & 0 deletions ref_app/ref_app.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,9 @@
<ClInclude Include="src\mcal_memory\mcal_memory_sram_types.h">
<Filter>src\mcal_memory</Filter>
</ClInclude>
<ClInclude Include="src\math\checksums\hash\hash_stream_base.h">
<Filter>src\math\checksums\hash</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="src\util\STL\algorithm">
Expand Down
Loading
Loading