Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/sha1dc_git.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / sha1dc_git.c` 39 lines ยท 869 bytes Raw Blame History 1 #include "git-compat-util.h" 2 #include "sha1dc_git.h" 3 #include "hex.h" 4 5 #ifdef DC_SHA1_EXTERNAL 6 /* 7 * Same as SHA1DCInit, but with default save_hash=0 8 */ 9 void git_SHA1DCInit(SHA1_CTX *ctx) 10 { 11 SHA1DCInit(ctx); 12 SHA1DCSetSafeHash(ctx, 0); 13 } 14 #endif 15 16 /* 17 * Same as SHA1DCFinal, but convert collision attack case into a verbose die(). 18 */ 19 void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx) 20 { 21 if (!SHA1DCFinal(hash, ctx)) 22 return; 23 die("SHA-1 appears to be part of a collision attack: %s", 24 hash_to_hex_algop(hash, &hash_algos[GIT_HASH_SHA1])); 25 } 26 27 /* 28 * Same as SHA1DCUpdate, but adjust types to match git's usual interface. 29 */ 30 void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len) 31 { 32 const char *data = vdata; 33 while (len > INT_MAX) { 34 SHA1DCUpdate(ctx, data, INT_MAX); 35 data += INT_MAX; 36 len -= INT_MAX; 37 } 38 SHA1DCUpdate(ctx, data, len); 39 }