1#include"cache.h" 2 3#ifdef DC_SHA1_EXTERNAL 4/* 5 * Same as SHA1DCInit, but with default save_hash=0 6 */ 7voidgit_SHA1DCInit(SHA1_CTX *ctx) 8{ 9SHA1DCInit(ctx); 10SHA1DCSetSafeHash(ctx,0); 11} 12#endif 13 14/* 15 * Same as SHA1DCFinal, but convert collision attack case into a verbose die(). 16 */ 17voidgit_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx) 18{ 19if(!SHA1DCFinal(hash, ctx)) 20return; 21die("SHA-1 appears to be part of a collision attack:%s", 22sha1_to_hex(hash)); 23} 24 25/* 26 * Same as SHA1DCUpdate, but adjust types to match git's usual interface. 27 */ 28voidgit_SHA1DCUpdate(SHA1_CTX *ctx,const void*vdata,unsigned long len) 29{ 30const char*data = vdata; 31/* We expect an unsigned long, but sha1dc only takes an int */ 32while(len > INT_MAX) { 33SHA1DCUpdate(ctx, data, INT_MAX); 34 data += INT_MAX; 35 len -= INT_MAX; 36} 37SHA1DCUpdate(ctx, data, len); 38}