aesgcm-select.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "ssh.h"
  2. #include "aesgcm.h"
  3. static ssh2_mac *aesgcm_mac_selector_new(const ssh2_macalg *alg,
  4. ssh_cipher *cipher)
  5. {
  6. static const ssh2_macalg *const real_algs[] = {
  7. #if HAVE_CLMUL
  8. &ssh2_aesgcm_mac_clmul,
  9. #endif
  10. #if HAVE_NEON_PMULL
  11. &ssh2_aesgcm_mac_neon,
  12. #endif
  13. &ssh2_aesgcm_mac_sw,
  14. NULL,
  15. };
  16. size_t i; // WINSCP
  17. for (i = 0; real_algs[i]; i++) {
  18. const ssh2_macalg *alg = real_algs[i];
  19. const struct aesgcm_extra *alg_extra =
  20. (const struct aesgcm_extra *)alg->extra;
  21. if (check_aesgcm_availability(alg_extra))
  22. return ssh2_mac_new(alg, cipher);
  23. }
  24. /* We should never reach the NULL at the end of the list, because
  25. * the last non-NULL entry should be software-only GCM, which is
  26. * always available. */
  27. unreachable("aesgcm_select ran off the end of its list");
  28. }
  29. const ssh2_macalg ssh2_aesgcm_mac = {
  30. /*.new =*/ aesgcm_mac_selector_new,
  31. NULL, NULL, NULL, NULL, NULL, NULL, // WINSCP
  32. /*.name =*/ "",
  33. /*.etm_name =*/ "", /* Not selectable independently */
  34. /*.len =*/ 16,
  35. /*.keylen =*/ 0,
  36. NULL, // WINSCP
  37. };