constant_time_invasive.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * \file constant_time_invasive.h
  3. *
  4. * \brief Constant-time module: interfaces for invasive testing only.
  5. *
  6. * The interfaces in this file are intended for testing purposes only.
  7. * They SHOULD NOT be made available in library integrations except when
  8. * building the library for testing.
  9. */
  10. /*
  11. * Copyright The Mbed TLS Contributors
  12. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  13. */
  14. #ifndef MBEDTLS_CONSTANT_TIME_INVASIVE_H
  15. #define MBEDTLS_CONSTANT_TIME_INVASIVE_H
  16. #include "common.h"
  17. #if defined(MBEDTLS_TEST_HOOKS)
  18. /** Turn a value into a mask:
  19. * - if \p low <= \p c <= \p high,
  20. * return the all-bits 1 mask, aka (unsigned) -1
  21. * - otherwise, return the all-bits 0 mask, aka 0
  22. *
  23. * \param low The value to analyze.
  24. * \param high The value to analyze.
  25. * \param c The value to analyze.
  26. *
  27. * \return All-bits-one if \p low <= \p c <= \p high, otherwise zero.
  28. */
  29. unsigned char mbedtls_ct_uchar_mask_of_range(unsigned char low,
  30. unsigned char high,
  31. unsigned char c);
  32. #endif /* MBEDTLS_TEST_HOOKS */
  33. #endif /* MBEDTLS_CONSTANT_TIME_INVASIVE_H */