From 3eda31260dfb5d86a950f186dc447daebb7618f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Witas?= Date: Fri, 21 Jun 2024 10:15:43 +0200 Subject: [PATCH 1/2] Patches for Embarcadero C++ Builder (classic Borland compiler) Small code corrections to allow compilation by Borland BCC32.exe compiler. --- include/plusaes/plusaes.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/plusaes/plusaes.hpp b/include/plusaes/plusaes.hpp index 2c59a54..7fc8e9c 100644 --- a/include/plusaes/plusaes.hpp +++ b/include/plusaes/plusaes.hpp @@ -503,7 +503,7 @@ std::bitset inc32(const std::bitset X) { /** Algorithm 1 @private */ inline Block mul_blocks(const Block X, const Block Y) { - const bitset128 R = (std::bitset<8>("11100001") || std::bitset<120>()); + const bitset128 R = (std::bitset<8>(0xe1) || std::bitset<120>()); bitset128 X_bits = X.to_bits(); bitset128 Z; @@ -556,7 +556,8 @@ std::bitset make_bitset(const unsigned char * bytes, const std::size_t bytes_ } /** Algorithm 3 @private */ -inline std::vector gctr(const detail::RoundKeys & rkeys, const Block & ICB, const unsigned char * X, const std::size_t X_size){ +inline std::vector gctr(const detail::RoundKeys & rkeys, const Block & ICB, const unsigned char * X, const std::size_t X_size) +{ if (!X || X_size == 0) { return std::vector(); } @@ -576,7 +577,7 @@ inline std::vector gctr(const detail::RoundKeys & rkeys, const Bl // CIPH Block eCB; - encrypt_state(rkeys, CB.data(), eCB.data()); + detail::encrypt_state(rkeys, CB.data(), eCB.data()); // Y int op_size = 0; @@ -612,7 +613,7 @@ inline void push_back_zero_bits(std::vector& bytes, const std::si inline Block calc_H(const RoundKeys & rkeys) { std::vector H_raw(gcm::kBlockByteSize); - encrypt_state(rkeys, &H_raw[0], &H_raw[0]); + detail::encrypt_state(rkeys, &H_raw[0], &H_raw[0]); return gcm::Block(H_raw); } @@ -807,7 +808,7 @@ inline bool check_padding(const unsigned long padding, const unsigned char data[ } for (unsigned long i = 0; i < padding; ++i) { - if (data[kStateSize - 1 - i] != padding) { + if ((unsigned long)data[kStateSize - 1 - i] != padding) { return false; } } @@ -980,7 +981,7 @@ inline Error encrypt_cbc( const unsigned long data_size, const unsigned char * key, const unsigned long key_size, - const unsigned char (* iv)[16], + const unsigned char iv[16], unsigned char * encrypted, const unsigned long encrypted_size, const bool pads @@ -1008,7 +1009,7 @@ inline Error encrypt_cbc( memcpy(s, data, data_size); } if (iv) { - detail::xor_data(s, *iv); + detail::xor_data(s, iv); } detail::encrypt_state(rkeys, s, encrypted); From 376220d8911f79f5a038304c8a07345e614847f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Witas?= Date: Fri, 21 Jun 2024 10:22:40 +0200 Subject: [PATCH 2/2] Add files via upload --- include/plusaes/plusaes.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/plusaes/plusaes.hpp b/include/plusaes/plusaes.hpp index 7fc8e9c..bda28c4 100644 --- a/include/plusaes/plusaes.hpp +++ b/include/plusaes/plusaes.hpp @@ -556,8 +556,7 @@ std::bitset make_bitset(const unsigned char * bytes, const std::size_t bytes_ } /** Algorithm 3 @private */ -inline std::vector gctr(const detail::RoundKeys & rkeys, const Block & ICB, const unsigned char * X, const std::size_t X_size) -{ +inline std::vector gctr(const detail::RoundKeys & rkeys, const Block & ICB, const unsigned char * X, const std::size_t X_size){ if (!X || X_size == 0) { return std::vector(); }