COPYING: fe2a4177a760fd110e78788734f167bd633be8de Makefile: 770595e02be4a9a55ff98910c53617c3b0f1e145 --- Makefile +++ Makefile 2005-04-17 19:38:00.000000000 +0900 @@ -7,7 +7,7 @@ # BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly # break unless your underlying filesystem supports those sub-second times # (my ext3 doesn't). -CFLAGS=-g -O3 -Wall +CFLAGS=-g -O3 -Wall $(shell libgcrypt-config --cflags) CC=gcc @@ -21,7 +21,7 @@ install: $(PROG) install $(PROG) $(HOME)/bin/ -LIBS= -lssl -lz +LIBS= $(shell libgcrypt-config --libs) -lz init-db: init-db.o README: eeed997e557fb079f38961354473113ca0d0b115 cache.h: 5948db759b3f6fb5ade3b027f202330f71a8cb6a --- cache.h +++ cache.h 2005-04-17 19:25:40.000000000 +0900 @@ -12,7 +12,7 @@ #include #include -#include +#include #include /* cat-file.c: 45be1badaa8517d4e3a69e0bf1cac2e90191e475 check-files.c: 927b0b9aca742183fc8e7ccd73d73d8d5427e98f checkout-cache.c: 4af3b7c1d0e12a3c51653f41c8ea13ce5335d389 commit-tree.c: 10690e421694af03b5d51fdf18b66474acfa0819 diff-tree.c: a9d58870fa41281e927155884b4c592145fea857 --- diff-tree.c +++ diff-tree.c 2005-04-17 18:10:39.000000000 +0900 @@ -1,3 +1,4 @@ +/* test by dancerj */ #include "cache.h" static int recursive = 0; @@ -17,6 +18,7 @@ *sizep = size - len; } +/* test by dancerj */ static const unsigned char *extract(void *tree, unsigned long size, const char **pathp, unsigned int *modep) { int len = strlen(tree)+1; fsck-cache.c: 9130c09a9b67ee9b2ead1b38c805232215900e6e init-db.c: aa00fbb1b95624f6c30090a17354c9c08a6ac596 ls-tree.c: 936bb19a5525046a5a784d5f14c3ea7da406cc62 read-cache.c: 740ffcce7026b268bd4dfe1d0a773ad7e3a24f96 --- read-cache.c +++ read-cache.c 2005-04-17 19:34:37.000000000 +0900 @@ -116,11 +116,14 @@ int check_sha1_signature(unsigned char *sha1, void *map, unsigned long size) { unsigned char real_sha1[20]; - SHA_CTX c; + gcry_md_hd_t c; - SHA1_Init(&c); - SHA1_Update(&c, map, size); - SHA1_Final(real_sha1, &c); + gcry_md_open(&c, GCRY_MD_SHA1, 0); + gcry_md_write(c, map, size); + gcry_md_final(c); + memcpy(real_sha1, gcry_md_read(c, 0), 20); + gcry_md_close(c); + return memcmp(sha1, real_sha1, 20) ? -1 : 0; } @@ -203,7 +206,7 @@ char *compressed; z_stream stream; unsigned char sha1[20]; - SHA_CTX c; + gcry_md_hd_t c; /* Set it up */ memset(&stream, 0, sizeof(stream)); @@ -222,9 +225,11 @@ size = stream.total_out; /* Sha1.. */ - SHA1_Init(&c); - SHA1_Update(&c, compressed, size); - SHA1_Final(sha1, &c); + gcry_md_open(&c, GCRY_MD_SHA1, 0); + gcry_md_write(c, compressed, size); + gcry_md_final(c); + memcpy(sha1, gcry_md_read(c, 0), 20); + gcry_md_close(c); if (write_sha1_buffer(sha1, compressed, size) < 0) return -1; @@ -425,17 +430,20 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size) { - SHA_CTX c; + gcry_md_hd_t c; unsigned char sha1[20]; if (hdr->hdr_signature != htonl(CACHE_SIGNATURE)) return error("bad signature"); if (hdr->hdr_version != htonl(1)) return error("bad version"); - SHA1_Init(&c); - SHA1_Update(&c, hdr, offsetof(struct cache_header, sha1)); - SHA1_Update(&c, hdr+1, size - sizeof(*hdr)); - SHA1_Final(sha1, &c); + gcry_md_open(&c, GCRY_MD_SHA1, 0); + gcry_md_write(c, hdr, offsetof(struct cache_header, sha1)); + gcry_md_write(c, hdr+1, size - sizeof(*hdr)); + gcry_md_final(c); + memcpy(sha1, gcry_md_read(c, 0), 20); + gcry_md_close(c); + if (memcmp(sha1, hdr->sha1, 20)) return error("bad header sha1"); return 0; @@ -498,7 +506,8 @@ int write_cache(int newfd, struct cache_entry **cache, int entries) { - SHA_CTX c; + gcry_md_hd_t c; + struct cache_header hdr; int i; @@ -506,14 +515,16 @@ hdr.hdr_version = htonl(1); hdr.hdr_entries = htonl(entries); - SHA1_Init(&c); - SHA1_Update(&c, &hdr, offsetof(struct cache_header, sha1)); + gcry_md_open(&c, GCRY_MD_SHA1, 0); + gcry_md_write(c, &hdr, offsetof(struct cache_header, sha1)); for (i = 0; i < entries; i++) { struct cache_entry *ce = cache[i]; int size = ce_size(ce); - SHA1_Update(&c, ce, size); + gcry_md_write(c, ce, size); } - SHA1_Final(hdr.sha1, &c); + gcry_md_final(c); + memcpy(hdr.sha1, gcry_md_read(c, 0), 20); + gcry_md_close(c); if (write(newfd, &hdr, sizeof(hdr)) != sizeof(hdr)) return -1; read-tree.c: 42556c82def1d23f21116a2c1b3e7ae27c0605c5 rev-tree.c: 9443f4560beedcf81f2f5e7e0664d169cb5c8527 revision.h: 28d0de3261a61f68e4e0948a25a416a515cd2e83 show-diff.c: d85d79b97a59342390bd34da09049dd58d56900f show-files.c: f4ccc765e612e9b68e11136fc38571f8822c9a02 update-cache.c: 5afecd1a4fd90d2505753ce2d5044d780fe69a7f --- update-cache.c +++ update-cache.c 2005-04-17 19:36:40.000000000 +0900 @@ -22,7 +22,7 @@ void *out = malloc(max_out_bytes); void *metadata = malloc(namelen + 200); void *in; - SHA_CTX c; + gcry_md_hd_t c; in = ""; if (size) @@ -54,9 +54,11 @@ deflateEnd(&stream); - SHA1_Init(&c); - SHA1_Update(&c, out, stream.total_out); - SHA1_Final(ce->sha1, &c); + gcry_md_open(&c, GCRY_MD_SHA1, 0); + gcry_md_write(c, out, stream.total_out); + gcry_md_final(c); + memcpy(ce->sha1, gcry_md_read(c, 0), 20); + gcry_md_close(c); return write_sha1_buffer(ce->sha1, out, stream.total_out); } write-tree.c: 34a351b20fb38ea588f34bd9634f101b9dc533cb