THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
855B

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