From fe39df888b1ad8cc05418d268eacb4a0bd73b21b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:14:44 +0000 Subject: [PATCH 1/5] Initial plan From c4679f1eaab32bd10fdf59c25a70aee29c9bf6b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:21:06 +0000 Subject: [PATCH 2/5] Implement SHA-256 algorithm with tests Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- src/lib-hash/headers/common_hash.hh | 58 ++++++ src/lib-hash/headers/sha256.hh | 143 +++++++++++++++ src/lib-hash/src/sha256.cc | 267 ++++++++++++++++++++++++++++ src/main.cc | 4 + src/sha_cli.cc | 2 + src/ut_sha_functions.cc | 101 +++++++++++ 6 files changed, 575 insertions(+) create mode 100644 src/lib-hash/headers/sha256.hh create mode 100644 src/lib-hash/src/sha256.cc diff --git a/src/lib-hash/headers/common_hash.hh b/src/lib-hash/headers/common_hash.hh index 7d9f7f4..119b158 100644 --- a/src/lib-hash/headers/common_hash.hh +++ b/src/lib-hash/headers/common_hash.hh @@ -13,6 +13,7 @@ #include "logging.hh" #include "sha0.hh" #include "sha1.hh" +#include "sha256.hh" #include #include #include @@ -112,6 +113,63 @@ openssl_test_sha1(const std::string &message, const bool isPrintable = true) { return hash_string; } +/** + * @brief Funzione di test per l'algoritmo sha256 + * + * @param message + * @param isPrintable + * @return std::string + */ +std::string +cripto_test_sha256(const std::string &message, const bool isPrintable = true) { + + uint8_t digest[cripto::SHA256_DIGEST_SIZE]; + + cripto::SHA256 sha256; + + // Eseguo la prima parte dell'hash e converto la stringa in un array di + // byte + sha256.initialization(reinterpret_cast(message.data()), + message.length()); + + // Eseguo la seconda parte dell'hash ed estraggo il digest a 256 bit + sha256.final(digest); + + // Converto il digest in una stringa esadecimale + std::string result = + cripto::SHA256::toHexString(digest, cripto::SHA256_DIGEST_SIZE); + if (isPrintable) + { + std::cout << "Cripto SHA256: " << result << std::endl; + cripto::log_trace("Cripto SHA256: " + result); + } + + return result; +} + +/** + * @brief Funzione di test per l'algoritmo sha256 tramite la libreria openssl + * + * @param message + * @param isPrintable + * @return std::string + */ +std::string +openssl_test_sha256(const std::string &message, const bool isPrintable = true) { + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256(reinterpret_cast(message.data()), + message.length(), hash); + + std::string hash_string = + cripto::SHA256::toHexString(hash, SHA256_DIGEST_LENGTH); + if (isPrintable) + { + std::cout << "OpenSSL SHA256: " << hash_string << std::endl; + cripto::log_trace("OpenSSL SHA256: " + hash_string); + } + return hash_string; +} + /** * @brief Funzione per convertire un file in una stringa * diff --git a/src/lib-hash/headers/sha256.hh b/src/lib-hash/headers/sha256.hh new file mode 100644 index 0000000..615f2ae --- /dev/null +++ b/src/lib-hash/headers/sha256.hh @@ -0,0 +1,143 @@ +/** + * @file sha256.hh + * @author Andrea Ciccarello + * @brief Definizione classe SHA256 + * @version 1.0 + * @date 2024-11-17 + * + * @copyright Copyright (c) 2024 + * + */ + +#pragma once +#include +#include + +namespace cripto { + +constexpr unsigned int SHA256_BLOCK_SIZE = 64; // 512 bits +constexpr unsigned int SHA256_DIGEST_SIZE = 32; // 256 bits + +class SHA256 { + public: + SHA256(); + void initialization(const uint8_t *data, size_t length); + void final(uint8_t digest[SHA256_DIGEST_SIZE]); + static std::string toHexString(const uint8_t *digest, size_t length); + + private: + void transform(const uint8_t block[SHA256_BLOCK_SIZE]); + void padding(); + + //! I 8 registri di stato inizializzati con i valori iniziali + //! specificati dallo standard SHA-256. + uint32_t state[8]; + + //! Tiene traccia del numero di bit processati fino a questo momento. + uint64_t bitCount; + + /** + * @brief Lunghezza corrente del buffer interno per accumulare i dati + * prima di processarlo. Quando si raggiungono i 64 byte (512 bit) il + * buffer viene processato e il bufferLength azzerato. + * + * @note Il buffer è di 64 byte (512 bit) come specificato dallo + * standard. + */ + size_t bufferLength; + + /** + * @brief Numero del blocco da elaborare che ha come scopo quello di + * migliorare l'output del logging a livello trace. + */ + uint64_t block_number; + + uint8_t buffer[SHA256_BLOCK_SIZE]; +}; + +} // namespace cripto + +// Pseudocodice SHA-256 +// +// Initialize hash values: +// (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19): +// h0 := 0x6a09e667 +// h1 := 0xbb67ae85 +// h2 := 0x3c6ef372 +// h3 := 0xa54ff53a +// h4 := 0x510e527f +// h5 := 0x9b05688c +// h6 := 0x1f83d9ab +// h7 := 0x5be0cd19 +// +// Initialize array of round constants: +// (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311): +// k[0..63] := +// 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, +// 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, +// 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, +// 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, +// 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, +// 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, +// 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, +// 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +// +// Pre-processing (Padding): +// append the bit '1' to the message e.g. by adding 0x80 if message length is a multiple of 8 bits. +// append 0 ≤ k < 512 bits '0', such that the resulting message length in bits +// is congruent to −64 ≡ 448 (mod 512) +// append ml, the original message length, as a 64-bit big-endian integer. +// Thus, the total length is a multiple of 512 bits. +// +// Process the message in successive 512-bit chunks: +// break message into 512-bit chunks +// for each chunk +// create a 64-entry message schedule array w[0..63] of 32-bit words +// copy chunk into first 16 words w[0..15] of the message schedule array +// +// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: +// for i from 16 to 63 +// s0 := (w[i-15] rightrotate 7) xor (w[i-15] rightrotate 18) xor (w[i-15] rightshift 3) +// s1 := (w[i-2] rightrotate 17) xor (w[i-2] rightrotate 19) xor (w[i-2] rightshift 10) +// w[i] := w[i-16] + s0 + w[i-7] + s1 +// +// Initialize working variables to current hash value: +// a := h0 +// b := h1 +// c := h2 +// d := h3 +// e := h4 +// f := h5 +// g := h6 +// h := h7 +// +// Compression function main loop: +// for i from 0 to 63 +// S1 := (e rightrotate 6) xor (e rightrotate 11) xor (e rightrotate 25) +// ch := (e and f) xor ((not e) and g) +// temp1 := h + S1 + ch + k[i] + w[i] +// S0 := (a rightrotate 2) xor (a rightrotate 13) xor (a rightrotate 22) +// maj := (a and b) xor (a and c) xor (b and c) +// temp2 := S0 + maj +// +// h := g +// g := f +// f := e +// e := d + temp1 +// d := c +// c := b +// b := a +// a := temp1 + temp2 +// +// Add the compressed chunk to the current hash value: +// h0 := h0 + a +// h1 := h1 + b +// h2 := h2 + c +// h3 := h3 + d +// h4 := h4 + e +// h5 := h5 + f +// h6 := h6 + g +// h7 := h7 + h +// +// Produce the final hash value (big-endian): +// digest := h0 append h1 append h2 append h3 append h4 append h5 append h6 append h7 diff --git a/src/lib-hash/src/sha256.cc b/src/lib-hash/src/sha256.cc new file mode 100644 index 0000000..a34a150 --- /dev/null +++ b/src/lib-hash/src/sha256.cc @@ -0,0 +1,267 @@ +/** + * @file sha256.cc + * @author Andrea Ciccarello + * @brief Implementazione della classe SHA256 + * @version 1.0 + * @date 2024-11-17 + * + * @copyright Copyright (c) 2024 + * + */ + +#include "sha256.hh" +#include "logging.hh" +#include +#include +#include +#include + +namespace cripto { + +/** + * @brief Funzione che ruota a destra un valore di 32 bit + * + * @param value valore da ruotare + * @param count numero di posizioni di cui ruotare il valore + * @return uint32_t valore ruotato + */ +inline uint32_t +rightRotate(uint32_t value, unsigned int count) { + return (value >> count) | (value << (32 - count)); +} + +/** + * @brief Funzione che shifta a destra un valore di 32 bit + * + * @param value valore da shiftare + * @param count numero di posizioni di cui shiftare il valore + * @return uint32_t valore shiftato + */ +inline uint32_t +rightShift(uint32_t value, unsigned int count) { + return value >> count; +} + +/** + * @brief Costruttore della classe SHA256 + * + * Ci sono 8 registri di stato inizializzati con i valori iniziali + * specificati dallo standard SHA-256. + * + * Questi valori sono i primi 32 bit delle parti frazionarie delle + * radici quadrate dei primi 8 numeri primi (2, 3, 5, 7, 11, 13, 17, 19). + * + * Il contatore di bit è inizializzato a 0 e la lunghezza del buffer a 0. + */ +SHA256::SHA256() + : state{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}, + bitCount(0), bufferLength(0), block_number(0), buffer{} { +} + +/** + * @brief Funzione che ha il compito di dividere i dati in blocchi di 512 bit, + * quando il buffer è pieno verranno processati tramite la funzione transform + * + * @param data puntatore ai dati da processare + * @param length lunghezza dei dati in byte + */ +void +SHA256::initialization(const uint8_t *data, size_t length) { + // tutti i dati devono essere processati + while (length > 0) + { + // Quanti byte posso copiare nel buffer + // minimo tra length e lo spazio disponibile nel buffer. + size_t toCopy = std::min(length, SHA256_BLOCK_SIZE - bufferLength); + // Copio i dati nel buffer + std::memcpy(buffer + bufferLength, data, toCopy); + bufferLength = bufferLength + toCopy; + + // data puntatore alla posizione successiva + data = data + toCopy; + length = length - toCopy; + + // se il buffer è pieno allora lo si deve processare + if (bufferLength == SHA256_BLOCK_SIZE) + { + // processamento del buffer + transform(buffer); + + bitCount += 512; + bufferLength = 0; + } + } +} + +/** + * @brief Funzione di trasformazione che permette di processare un blocco + * + * @param block blocco di 512 bit da processare + */ +void +SHA256::transform(const uint8_t block[SHA256_BLOCK_SIZE]) { + // Array delle costanti K per SHA-256 + // Primi 32 bit delle parti frazionarie delle radici cubiche + // dei primi 64 numeri primi (2..311) + static const uint32_t k[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + }; + + uint32_t w[64]; + + // Incremento block number + ++block_number; + + // Conversione dei blocchi in 16 parole da 32 bit + // 512 bit = 16 parole da 32 bit + for (int i = 0; i < 16; ++i) + { + w[i] = (block[i * 4] << 24) | (block[i * 4 + 1] << 16) | + (block[i * 4 + 2] << 8) | block[i * 4 + 3]; + } + + // Espansione delle parole da 16 parole a 64 parole + for (int i = 16; i < 64; ++i) + { + uint32_t s0 = rightRotate(w[i - 15], 7) ^ rightRotate(w[i - 15], 18) ^ + rightShift(w[i - 15], 3); + uint32_t s1 = rightRotate(w[i - 2], 17) ^ rightRotate(w[i - 2], 19) ^ + rightShift(w[i - 2], 10); + w[i] = w[i - 16] + s0 + w[i - 7] + s1; + } + + std::string block_number_string = std::to_string(block_number); + cripto::log_trace("SHA256: Processing block N°: " + block_number_string); + + // copio gli 8 stati nelle variabili locali + uint32_t a = state[0], b = state[1], c = state[2], d = state[3], + e = state[4], f = state[5], g = state[6], h = state[7]; + + // Le 64 iterazioni per il calcolo dell'hash + for (int i = 0; i < 64; ++i) + { + uint32_t S1 = rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25); + uint32_t ch = (e & f) ^ ((~e) & g); + uint32_t temp1 = h + S1 + ch + k[i] + w[i]; + uint32_t S0 = rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22); + uint32_t maj = (a & b) ^ (a & c) ^ (b & c); + uint32_t temp2 = S0 + maj; + + h = g; + g = f; + f = e; + e = d + temp1; + d = c; + c = b; + b = a; + a = temp1 + temp2; + } + + // Aggiornamento dello stato generale + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; + + for (int i = 0; i < 8; ++i) + { + cripto::log_trace("SHA256: State " + std::to_string(i) + " = " + + std::to_string(state[i])); + } +} + +/** + * @brief Funzione di padding + */ +void +SHA256::padding() { + bitCount += bufferLength * 8; + // aggiunta di un bit a 1 alla fine del messaggio + buffer[bufferLength++] = 0x80; + + // Se la lunghezza del buffer con il bit aggiunto è maggiore di 448 bit + // allora non ci sarà abbastanza spazio per aggiungere la lunghezza + // di 64 bit del messaggio. + if (bufferLength > 56) + { + cripto::log_trace("SHA256: Ultimo blocco non rispetta 448 mod 512"); + // Riempio il buffer con 0 fino a 512 bit + std::memset(buffer + bufferLength, 0, SHA256_BLOCK_SIZE - bufferLength); + // calcolo l'hash parziale del blocco + transform(buffer); + bufferLength = 0; + } + + // padding con 0 fino a 56 byte (448 bit) + std::memset(buffer + bufferLength, 0, 56 - bufferLength); + + // aggiunta della lunghezza del messaggio come un numero a 64 bit + // alla fine del blocco + // 448 + 64 = 512 bit + for (int i = 0; i < 8; ++i) + { + buffer[56 + i] = (bitCount >> ((7 - i) * 8)) & 0xFF; + } + + cripto::log_trace( + "SHA256: Elaborazione blocco finale con padding e lunghezza del messaggio"); + transform(buffer); +} + +/** + * @brief Conclusione dell'hash e restituzione del digest + * + * @param digest array di 32 byte dove verrà scritto il digest + */ +void +SHA256::final(uint8_t digest[SHA256_DIGEST_SIZE]) { + padding(); + + for (int i = 0; i < 8; ++i) + { + digest[i * 4] = (state[i] >> 24) & 0xFF; + digest[i * 4 + 1] = (state[i] >> 16) & 0xFF; + digest[i * 4 + 2] = (state[i] >> 8) & 0xFF; + digest[i * 4 + 3] = state[i] & 0xFF; + } +} + +/** + * @brief Funzione che converte un digest in una stringa esadecimale + * + * @param digest array di byte del digest + * @param length lunghezza del digest in byte + * @return std::string rappresentazione esadecimale del digest + */ +std::string +SHA256::toHexString(const uint8_t *digest, size_t length) { + std::stringstream ss; + ss << std::hex << std::setfill('0'); + for (size_t i = 0; i < length; ++i) + { + ss << std::setw(2) << static_cast(digest[i]); + } + return ss.str(); +} + +} // namespace cripto diff --git a/src/main.cc b/src/main.cc index 74f6be0..95ae627 100644 --- a/src/main.cc +++ b/src/main.cc @@ -55,6 +55,8 @@ main(int argc, char const *argv[]) { cripto::log_trace("Testing message: \"" + test + "\""); (void)cripto_test_sha1(test); (void)openssl_test_sha1(test); + (void)cripto_test_sha256(test); + (void)openssl_test_sha256(test); std::cout << std::endl; } @@ -67,6 +69,8 @@ main(int argc, char const *argv[]) { "Calcolo hash di della Divina Commedia, dentro a commedia.txt"); (void)cripto_test_sha1(commedia_content); (void)openssl_test_sha1(commedia_content); + (void)cripto_test_sha256(commedia_content); + (void)openssl_test_sha256(commedia_content); } catch (const std::exception &e) { std::cerr << "Errore: " << e.what() << std::endl; diff --git a/src/sha_cli.cc b/src/sha_cli.cc index 0c98c53..585568c 100644 --- a/src/sha_cli.cc +++ b/src/sha_cli.cc @@ -25,6 +25,8 @@ main() { (void)cripto_test_sha1(input_string); (void)openssl_test_sha1(input_string); + (void)cripto_test_sha256(input_string); + (void)openssl_test_sha256(input_string); return 0; } \ No newline at end of file diff --git a/src/ut_sha_functions.cc b/src/ut_sha_functions.cc index 7b4c2b9..87bba67 100644 --- a/src/ut_sha_functions.cc +++ b/src/ut_sha_functions.cc @@ -125,6 +125,107 @@ TEST(SHA1Test, Performance) { EXPECT_LT(duration, 1000); } +//! Test SHA256 con stringa vuota +TEST(SHA256Test, EmptyString) { + std::string message = ""; + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Test SHA256 con una stringa breve +TEST(SHA256Test, ShortString) { + std::string message = "Hello, World!"; + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Test SHA256 con una stringa più lunga +TEST(SHA256Test, LongString) { + std::string message = + "This is a longer string to test SHA256 implementation. " + "It should work with various lengths."; + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Test SHA256 con caratteri speciali +TEST(SHA256Test, SpecialCharacters) { + std::string message = "!@#$%^&*()_+{}|:<>?~`-=[]\\;',./"; + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Test SHA256 con una stringa contenente caratteri non ASCII +TEST(SHA256Test, NonASCIICharacters) { + std::string message = "こんにちは世界 Здравствуй Κόσμε"; + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Test SHA256 con una stringa molto lunga +TEST(SHA256Test, VeryLongString) { + std::string message(1000000, 'a'); // Stringa di un milione di 'a' + EXPECT_EQ(cripto_test_sha256(message, false), + openssl_test_sha256(message, false)); +} + +//! Generazione causale di stringhe per SHA256 +TEST(SHA256Test, RandomString) { + for (int k = 0; k < 100; ++k) + { + std::string random_message = ""; + for (int i = 0; i < 100; ++i) + { + random_message += generaStringaCasuale(100); + } + EXPECT_EQ(cripto_test_sha256(random_message, false), + openssl_test_sha256(random_message, false)); + } +} + +//! Test determinismo SHA256 con la stessa stringa +TEST(SHA256Test, Determinism) { + std::string message = "Hello, World!"; + auto digest = cripto_test_sha256(message, false); + + for (int i = 0; i < 10; ++i) + { + EXPECT_EQ(digest, cripto_test_sha256(message, false)); + EXPECT_EQ(digest, openssl_test_sha256(message, false)); + } +} + +//! Test effetto a valanga SHA256 +TEST(SHA256Test, AvalancheEffect) { + std::string message = "Hello, World!"; + auto digest = cripto_test_sha256(message, false); + + for (size_t i = 0; i < message.size(); ++i) + { + std::string modified_message = message; + modified_message[i] = 'a'; + EXPECT_NE(digest, cripto_test_sha256(modified_message, false)); + EXPECT_NE(digest, openssl_test_sha256(modified_message, false)); + } +} + +//! Performance SHA256 +TEST(SHA256Test, Performance) { + std::string message(1000000, 'a'); // Stringa di un milione di 'a' + + auto start = std::chrono::high_resolution_clock::now(); + cripto_test_sha256(message, false); + auto end = std::chrono::high_resolution_clock::now(); + + auto duration = + std::chrono::duration_cast(end - start) + .count(); + cripto::log_trace("SHA256: Performance test completed in " + + std::to_string(duration) + " ms"); + + EXPECT_LT(duration, 1000); +} + int main(int argc, char **argv) { cripto::init_logging(); From 88a67fa18d4dfb586a3b20ded4b8ca7c6aeccc05 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:27:10 +0000 Subject: [PATCH 3/5] Update README to mention SHA-256 implementation Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- README.md | 4 ++-- _codeql_detected_source_root | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 120000 _codeql_detected_source_root diff --git a/README.md b/README.md index 788669d..2739ec5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Italian: Implementazione Secure Hash Algorithm 1 (SHA1) +# Italian: Implementazione Secure Hash Algorithm (SHA) [![Cmake compilation Conan](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/compilation.yaml/badge.svg)](https://github.com/AndreaCicca/SHA-implementation/actions/workflows/compilation.yaml) Corso di Crittografia presso Unipr. -In questo progetto è stata effettuata l'implementazione dell'algoritmo SHA 0-1tramite il linguaggio C++17. +In questo progetto è stata effettuata l'implementazione degli algoritmi SHA-0, SHA-1 e SHA-256 (SHA-2) tramite il linguaggio C++17. La maggior parte delle dipendenze vengono gestite tramite il package manager Conan, per poter la compilazione hai bisogno soltanto di avere un ambiente python, un compilatore C++17 e Cmake. diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..f7ffedd --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +./src \ No newline at end of file From 8cf4efb08637d2fdf7e83a9fb5d2871e21764940 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:28:09 +0000 Subject: [PATCH 4/5] Final verification and completion of SHA-256 implementation Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- src/src | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/src diff --git a/src/src b/src/src new file mode 120000 index 0000000..f7ffedd --- /dev/null +++ b/src/src @@ -0,0 +1 @@ +./src \ No newline at end of file From 6060aeda2a7f416f571d9cf5d5c199b37745f949 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:28:57 +0000 Subject: [PATCH 5/5] Remove accidentally created symlinks Co-authored-by: AndreaCicca <58073848+AndreaCicca@users.noreply.github.com> --- _codeql_detected_source_root | 1 - src/src | 1 - 2 files changed, 2 deletions(-) delete mode 120000 _codeql_detected_source_root delete mode 120000 src/src diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index f7ffedd..0000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -./src \ No newline at end of file diff --git a/src/src b/src/src deleted file mode 120000 index f7ffedd..0000000 --- a/src/src +++ /dev/null @@ -1 +0,0 @@ -./src \ No newline at end of file