commit 89720b41149f2c392d7641dcf30b1259d3f71af6 from: Omar Polo date: Sat Feb 04 14:00:31 2023 UTC inflate: support sha256 commit - 5cf598c49a15d941d4a6f3b46fb5d81143ea998e commit + 89720b41149f2c392d7641dcf30b1259d3f71af6 blob - 276955ef59f1f876bd0d16fd0ae8c624cbb843c0 blob + afe822662422c5ef26e0f9b4ba75b6a3101bd1ff --- lib/got_lib_inflate.h +++ lib/got_lib_inflate.h @@ -19,13 +19,19 @@ struct got_inflate_checksum { uint32_t *input_crc; /* If not NULL, mix input bytes into this SHA1 context. */ - SHA1_CTX *input_hash; + SHA1_CTX *input_sha1; + /* If not NULL, mix input bytes into this SHA1 context. */ + SHA2_CTX *input_sha256; + /* If not NULL, mix output bytes into this CRC checksum. */ uint32_t *output_crc; /* If not NULL, mix output bytes into this SHA1 context. */ - SHA1_CTX *output_hash; + SHA1_CTX *output_sha1; + + /* If not NULL, mix output bytes into this SHA1 context. */ + SHA2_CTX *output_sha256; }; struct got_inflate_buf { blob - 87054d7de41467a73c89b7354f659f43387acfe3 blob + 688f0ca1c1580a72e701d51ed7e807085e2f640a --- lib/inflate.c +++ lib/inflate.c @@ -92,8 +92,11 @@ csum_input(struct got_inflate_checksum *csum, const ui if (csum->input_crc) *csum->input_crc = crc32(*csum->input_crc, buf, len); - if (csum->input_hash) - SHA1Update(csum->input_hash, buf, len); + if (csum->input_sha1) + SHA1Update(csum->input_sha1, buf, len); + + if (csum->input_sha256) + SHA256Update(csum->input_sha256, buf, len); } static void @@ -102,8 +105,11 @@ csum_output(struct got_inflate_checksum *csum, const u if (csum->output_crc) *csum->output_crc = crc32(*csum->output_crc, buf, len); - if (csum->output_hash) - SHA1Update(csum->output_hash, buf, len); + if (csum->output_sha1) + SHA1Update(csum->output_sha1, buf, len); + + if (csum->output_sha256) + SHA256Update(csum->output_sha256, buf, len); } const struct got_error *