mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
36f048c5e4
The plumbing code between sha1dc and git is defined in sha1dc_git.[ch], but these aren't compiled / included directly but only via the indirect inclusion from sha1dc code. This is slightly confusing when you try to trace the build flow. This patch brings the following changes for simplification: - Make sha1dc_git.c stand-alone and build from Makefile - sha1dc_git.h is the common header to include further sha1.h depending on the build condition - Move comments for plumbing codes from the header to definitions This is also meant as a preliminary work for further plumbing with external sha1dc shlib. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
679 B
C
28 lines
679 B
C
#include "cache.h"
|
|
|
|
/*
|
|
* Same as SHA1DCFinal, but convert collision attack case into a verbose die().
|
|
*/
|
|
void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)
|
|
{
|
|
if (!SHA1DCFinal(hash, ctx))
|
|
return;
|
|
die("SHA-1 appears to be part of a collision attack: %s",
|
|
sha1_to_hex(hash));
|
|
}
|
|
|
|
/*
|
|
* Same as SHA1DCUpdate, but adjust types to match git's usual interface.
|
|
*/
|
|
void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)
|
|
{
|
|
const char *data = vdata;
|
|
/* We expect an unsigned long, but sha1dc only takes an int */
|
|
while (len > INT_MAX) {
|
|
SHA1DCUpdate(ctx, data, INT_MAX);
|
|
data += INT_MAX;
|
|
len -= INT_MAX;
|
|
}
|
|
SHA1DCUpdate(ctx, data, len);
|
|
}
|