diff --git a/crates/algorithms/algorithms-c/src/hash/sha2.c b/crates/algorithms/algorithms-c/src/hash/sha2.c index e9b4ba1..fe753f6 100644 --- a/crates/algorithms/algorithms-c/src/hash/sha2.c +++ b/crates/algorithms/algorithms-c/src/hash/sha2.c @@ -214,56 +214,6 @@ static void sha2_256_finalize(SHA2Context *context, uint8_t pad_byte) { context->computed = true; } -/* - * SHA256FinalBits - * - * Description: - * This function will add in any final bits of the message. - * - * Parameters: - * context: [in/out] - * The SHA context to update. - * message_bits: [in] - * The final bits of the message, in the upper portion of the - * byte. (Use 0b###00000 instead of 0b00000### to input the - * three bits ###.) - * length: [in] - * The number of bits in message_bits, between 1 and 7. - * - * Returns: - * sha Error Code. - */ -static SHA2Result sha2_256_final_bits(SHA2Context *context, - uint8_t message_bits, size_t len) { - static uint8_t masks[8] = { - /* 0 0b00000000 */ 0x00, /* 1 0b10000000 */ 0x80, - /* 2 0b11000000 */ 0xC0, /* 3 0b11100000 */ 0xE0, - /* 4 0b11110000 */ 0xF0, /* 5 0b11111000 */ 0xF8, - /* 6 0b11111100 */ 0xFC, /* 7 0b11111110 */ 0xFE}; - static uint8_t markbit[8] = { - /* 0 0b10000000 */ 0x80, /* 1 0b01000000 */ 0x40, - /* 2 0b00100000 */ 0x20, /* 3 0b00010000 */ 0x10, - /* 4 0b00001000 */ 0x08, /* 5 0b00000100 */ 0x04, - /* 6 0b00000010 */ 0x02, /* 7 0b00000001 */ 0x01}; - - if (!context) - return shaNull; - if (!len) - return shaSuccess; - if (context->corrupted) - return context->corrupted; - if (context->computed) - return context->corrupted = shaStateError; - if (len >= 8) - return context->corrupted = shaBadArg; - - sha2_256_add_length(context, len); - sha2_256_finalize(context, - (uint8_t)((message_bits & masks[len]) | markbit[len])); - - return context->corrupted; -} - /* * sha2_reset *