commit - 82f7e4c89aedcb1b224d85a6a5f2ae78b16bc943
commit + b74bd7ab16a541c7e40d2f73187e0455f5416bb2
blob - 4ddc5aac63e46a5562147f8b561c4dea76cad65c
blob + 2b4f0096cb70775318867148bcf81b8dfbdb3a6c
--- lib/got_lib_inflate.h
+++ lib/got_lib_inflate.h
/* If not NULL, mix input bytes into this SHA1 context. */
SHA1_CTX *input_sha1;
+ /* If not NULL, mix input bytes into this hash context. */
+ struct got_hash *input_ctx;
+
/* 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_sha1;
+
+ /* If not NULL, mix output bytes into this hash context. */
+ struct got_hash *output_ctx;
};
struct got_inflate_buf {
blob - a7430b2862ad5a27a62c256b504986391d92854d
blob + adf582371c406cc4a2a79408bde3913ff792159f
--- lib/inflate.c
+++ lib/inflate.c
#include "got_object.h"
#include "got_path.h"
+#include "got_lib_hash.h"
#include "got_lib_inflate.h"
#include "got_lib_poll.h"
if (csum->input_sha1)
SHA1Update(csum->input_sha1, buf, len);
+
+ if (csum->input_ctx)
+ got_hash_update(csum->input_ctx, buf, len);
}
static void
if (csum->output_sha1)
SHA1Update(csum->output_sha1, buf, len);
+
+ if (csum->output_ctx)
+ got_hash_update(csum->output_ctx, buf, len);
}
const struct got_error *
blob - 0c0ec97bfd02838440149781f11c2183bc65419f
blob + a5bc20986b8717cb89c1b8dbaf04600d65a17802
--- lib/object_parse.c
+++ lib/object_parse.c
const struct got_error *err = NULL;
struct got_object *obj;
struct got_inflate_checksum csum;
- uint8_t sha1[SHA1_DIGEST_LENGTH];
- SHA1_CTX sha1_ctx;
+ uint8_t hash[GOT_OBJECT_ID_MAXLEN];
+ struct got_hash ctx;
size_t len, consumed;
FILE *f = NULL;
*size = 0;
*hdrlen = 0;
- SHA1Init(&sha1_ctx);
+ got_hash_init(&ctx, GOT_HASH_SHA1);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_ctx = &ctx;
if (lseek(infd, SEEK_SET, 0) == -1)
return got_error_from_errno("lseek");
goto done;
}
- SHA1Final(sha1, &sha1_ctx);
- if (memcmp(expected_id->sha1, sha1, SHA1_DIGEST_LENGTH) != 0) {
+ got_hash_final(&ctx, hash);
+ if (got_hash_cmp(&ctx, expected_id->sha1, hash) != 0) {
err = got_error_checksum(expected_id);
goto done;
}
size_t len;
uint8_t *p;
struct got_inflate_checksum csum;
- SHA1_CTX sha1_ctx;
+ struct got_hash ctx;
struct got_object_id id;
- SHA1Init(&sha1_ctx);
+ got_hash_init(&ctx, GOT_HASH_SHA1);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_ctx = &ctx;
err = got_inflate_to_mem_fd(&p, &len, NULL, &csum, expected_size, fd);
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ got_hash_final(&ctx, id.sha1);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
struct got_object *obj = NULL;
size_t len;
struct got_inflate_checksum csum;
- SHA1_CTX sha1_ctx;
+ struct got_hash ctx;
struct got_object_id id;
- SHA1Init(&sha1_ctx);
+ got_hash_init(&ctx, GOT_HASH_SHA1);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_ctx = &ctx;
err = got_inflate_to_mem_fd(p, &len, NULL, &csum, 0, fd);
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ got_hash_final(&ctx, id.sha1);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
size_t len;
uint8_t *p;
struct got_inflate_checksum csum;
- SHA1_CTX sha1_ctx;
+ struct got_hash ctx;
struct got_object_id id;
- SHA1Init(&sha1_ctx);
+ got_hash_init(&ctx, GOT_HASH_SHA1);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_ctx = &ctx;
err = got_inflate_to_mem_fd(&p, &len, NULL, &csum,
expected_size, fd);
if (err)
return err;
- SHA1Final(id.sha1, &sha1_ctx);
+ got_hash_final(&ctx, id.sha1);
if (got_object_id_cmp(expected_id, &id) != 0) {
err = got_error_checksum(expected_id);
goto done;
blob - ed8291ef577fe09d4957c03653a00c031b0cb0dd
blob + 3c3632addec15ad4cda044f1a67ebddc26480865
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
#include "got_object.h"
#include "got_lib_delta.h"
+#include "got_lib_hash.h"
#include "got_lib_inflate.h"
#include "got_lib_object.h"
#include "got_lib_object_parse.h"
struct got_object_id id;
struct got_object_id expected_id;
struct got_inflate_checksum csum;
- SHA1_CTX sha1_ctx;
+ struct got_hash ctx;
- SHA1Init(&sha1_ctx);
+ got_hash_init(&ctx, GOT_HASH_SHA1);
memset(&csum, 0, sizeof(csum));
- csum.output_sha1 = &sha1_ctx;
+ csum.output_ctx = &ctx;
memset(&imsg, 0, sizeof(imsg));
imsg.fd = -1;
if (err)
goto done;
}
- SHA1Final(id.sha1, &sha1_ctx);
+ got_hash_final(&ctx, id.sha1);
if (got_object_id_cmp(&expected_id, &id) != 0) {
err = got_error_checksum(&expected_id);
goto done;