]> git.ipfire.org Git - thirdparty/git.git/blame - sha1dc_git.c
sha1dc: build git plumbing code more explicitly
[thirdparty/git.git] / sha1dc_git.c
CommitLineData
36f048c5
TI
1#include "cache.h"
2
a0103914 3/*
36f048c5 4 * Same as SHA1DCFinal, but convert collision attack case into a verbose die().
a0103914 5 */
a0103914
ÆAB
6void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)
7{
8 if (!SHA1DCFinal(hash, ctx))
9 return;
10 die("SHA-1 appears to be part of a collision attack: %s",
11 sha1_to_hex(hash));
12}
13
36f048c5
TI
14/*
15 * Same as SHA1DCUpdate, but adjust types to match git's usual interface.
16 */
a0103914
ÆAB
17void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)
18{
19 const char *data = vdata;
20 /* We expect an unsigned long, but sha1dc only takes an int */
21 while (len > INT_MAX) {
22 SHA1DCUpdate(ctx, data, INT_MAX);
23 data += INT_MAX;
24 len -= INT_MAX;
25 }
26 SHA1DCUpdate(ctx, data, len);
27}