sha1-select.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Top-level vtables to select a SHA-1 implementation.
  3. */
  4. #include <assert.h>
  5. #include <stdlib.h>
  6. #include "putty.h"
  7. #include "ssh.h"
  8. #include "sha1.h"
  9. static ssh_hash *sha1_select(const ssh_hashalg *alg)
  10. {
  11. static const ssh_hashalg *const real_algs[] = {
  12. #if HAVE_SHA_NI
  13. &ssh_sha1_ni,
  14. #endif
  15. #if HAVE_NEON_CRYPTO
  16. &ssh_sha1_neon,
  17. #endif
  18. &ssh_sha1_sw,
  19. NULL,
  20. };
  21. { // WINSCP
  22. size_t i;
  23. for (i = 0; real_algs[i]; i++) {
  24. const ssh_hashalg *alg = real_algs[i];
  25. const struct sha1_extra *alg_extra =
  26. (const struct sha1_extra *)alg->extra;
  27. if (check_availability(alg_extra))
  28. return ssh_hash_new(alg);
  29. }
  30. /* We should never reach the NULL at the end of the list, because
  31. * the last non-NULL entry should be software-only SHA-1, which
  32. * is always available. */
  33. unreachable("sha1_select ran off the end of its list");
  34. } // WINSCP
  35. }
  36. const ssh_hashalg ssh_sha1 = {
  37. // WINSCP
  38. /*.new =*/ sha1_select,
  39. NULL,
  40. NULL,
  41. NULL,
  42. NULL,
  43. /*.hlen =*/ 20,
  44. /*.blocklen =*/ 64,
  45. HASHALG_NAMES_ANNOTATED("SHA-1", "dummy selector vtable"),
  46. NULL,
  47. };