base64_invasive.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * \file base_invasive.h
  3. *
  4. * \brief Base64 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
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  15. * not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * http://www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  22. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. #ifndef MBEDTLS_BASE64_INVASIVE_H
  27. #define MBEDTLS_BASE64_INVASIVE_H
  28. #include "common.h"
  29. #if defined(MBEDTLS_TEST_HOOKS)
  30. /* Return 0xff if low <= c <= high, 0 otherwise.
  31. *
  32. * Constant flow with respect to c.
  33. */
  34. unsigned char mbedtls_base64_mask_of_range( unsigned char low,
  35. unsigned char high,
  36. unsigned char c );
  37. /* Given a value in the range 0..63, return the corresponding Base64 digit.
  38. *
  39. * Operates in constant time (no branches or memory access depending on val).
  40. */
  41. unsigned char mbedtls_base64_enc_char( unsigned char val );
  42. /* Given a Base64 digit, return its value.
  43. * If c is not a Base64 digit ('A'..'Z', 'a'..'z', '0'..'9', '+' or '/'),
  44. * return -1.
  45. *
  46. * Operates in constant time (no branches or memory access depending on c).
  47. */
  48. signed char mbedtls_base64_dec_value( unsigned char c );
  49. #endif /* MBEDTLS_TEST_HOOKS */
  50. #endif /* MBEDTLS_BASE64_INVASIVE_H */