constant_time_impl.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /**
  2. * Constant-time functions
  3. *
  4. * Copyright The Mbed TLS Contributors
  5. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  6. */
  7. #ifndef MBEDTLS_CONSTANT_TIME_IMPL_H
  8. #define MBEDTLS_CONSTANT_TIME_IMPL_H
  9. #include <stddef.h>
  10. #include "common.h"
  11. #if defined(MBEDTLS_BIGNUM_C)
  12. #include "mbedtls/bignum.h"
  13. #endif
  14. /*
  15. * To improve readability of constant_time_internal.h, the static inline
  16. * definitions are here, and constant_time_internal.h has only the declarations.
  17. *
  18. * This results in duplicate declarations of the form:
  19. * static inline void f(); // from constant_time_internal.h
  20. * static inline void f() { ... } // from constant_time_impl.h
  21. * when constant_time_internal.h is included.
  22. *
  23. * This appears to behave as if the declaration-without-definition was not present
  24. * (except for warnings if gcc -Wredundant-decls or similar is used).
  25. *
  26. * Disable -Wredundant-decls so that gcc does not warn about this. This is re-enabled
  27. * at the bottom of this file.
  28. */
  29. #if defined(MBEDTLS_COMPILER_IS_GCC) && (__GNUC__ > 4)
  30. #pragma GCC diagnostic push
  31. #pragma GCC diagnostic ignored "-Wredundant-decls"
  32. #endif
  33. /* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */
  34. #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && (!defined(__ARMCC_VERSION) || \
  35. __ARMCC_VERSION >= 6000000)
  36. #define MBEDTLS_CT_ASM
  37. #if (defined(__arm__) || defined(__thumb__) || defined(__thumb2__))
  38. #define MBEDTLS_CT_ARM_ASM
  39. #elif defined(__aarch64__)
  40. #define MBEDTLS_CT_AARCH64_ASM
  41. #elif defined(__amd64__) || defined(__x86_64__)
  42. #define MBEDTLS_CT_X86_64_ASM
  43. #elif defined(__i386__)
  44. #define MBEDTLS_CT_X86_ASM
  45. #endif
  46. #endif
  47. #define MBEDTLS_CT_SIZE (sizeof(mbedtls_ct_uint_t) * 8)
  48. /* ============================================================================
  49. * Core const-time primitives
  50. */
  51. /* Ensure that the compiler cannot know the value of x (i.e., cannot optimise
  52. * based on its value) after this function is called.
  53. *
  54. * If we are not using assembly, this will be fairly inefficient, so its use
  55. * should be minimised.
  56. */
  57. #if !defined(MBEDTLS_CT_ASM)
  58. extern volatile mbedtls_ct_uint_t mbedtls_ct_zero;
  59. #endif
  60. /**
  61. * \brief Ensure that a value cannot be known at compile time.
  62. *
  63. * \param x The value to hide from the compiler.
  64. * \return The same value that was passed in, such that the compiler
  65. * cannot prove its value (even for calls of the form
  66. * x = mbedtls_ct_compiler_opaque(1), x will be unknown).
  67. *
  68. * \note This is mainly used in constructing mbedtls_ct_condition_t
  69. * values and performing operations over them, to ensure that
  70. * there is no way for the compiler to ever know anything about
  71. * the value of an mbedtls_ct_condition_t.
  72. */
  73. static inline mbedtls_ct_uint_t mbedtls_ct_compiler_opaque(mbedtls_ct_uint_t x)
  74. {
  75. #if defined(MBEDTLS_CT_ASM)
  76. asm volatile ("" : [x] "+r" (x) :);
  77. return x;
  78. #else
  79. return x ^ mbedtls_ct_zero;
  80. #endif
  81. }
  82. /*
  83. * Selecting unified syntax is needed for gcc, and harmless on clang.
  84. *
  85. * This is needed because on Thumb 1, condition flags are always set, so
  86. * e.g. "negs" is supported but "neg" is not (on Thumb 2, both exist).
  87. *
  88. * Under Thumb 1 unified syntax, only the "negs" form is accepted, and
  89. * under divided syntax, only the "neg" form is accepted. clang only
  90. * supports unified syntax.
  91. *
  92. * On Thumb 2 and Arm, both compilers are happy with the "s" suffix,
  93. * although we don't actually care about setting the flags.
  94. *
  95. * For old versions of gcc (see #8516 for details), restore divided
  96. * syntax afterwards - otherwise old versions of gcc seem to apply
  97. * unified syntax globally, which breaks other asm code.
  98. */
  99. #if defined(MBEDTLS_COMPILER_IS_GCC) && defined(__thumb__) && !defined(__thumb2__) && \
  100. (__GNUC__ < 11) && !defined(__ARM_ARCH_2__)
  101. #define RESTORE_ASM_SYNTAX ".syntax divided \n\t"
  102. #else
  103. #define RESTORE_ASM_SYNTAX
  104. #endif
  105. /* Convert a number into a condition in constant time. */
  106. static inline mbedtls_ct_condition_t mbedtls_ct_bool(mbedtls_ct_uint_t x)
  107. {
  108. /*
  109. * Define mask-generation code that, as far as possible, will not use branches or conditional instructions.
  110. *
  111. * For some platforms / type sizes, we define assembly to assure this.
  112. *
  113. * Otherwise, we define a plain C fallback which (in May 2023) does not get optimised into
  114. * conditional instructions or branches by trunk clang, gcc, or MSVC v19.
  115. */
  116. #if defined(MBEDTLS_CT_AARCH64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  117. mbedtls_ct_uint_t s;
  118. asm volatile ("neg %x[s], %x[x] \n\t"
  119. "orr %x[x], %x[s], %x[x] \n\t"
  120. "asr %x[x], %x[x], 63 \n\t"
  121. :
  122. [s] "=&r" (s),
  123. [x] "+&r" (x)
  124. :
  125. :
  126. );
  127. return (mbedtls_ct_condition_t) x;
  128. #elif defined(MBEDTLS_CT_ARM_ASM) && defined(MBEDTLS_CT_SIZE_32)
  129. uint32_t s;
  130. asm volatile (".syntax unified \n\t"
  131. "negs %[s], %[x] \n\t"
  132. "orrs %[x], %[x], %[s] \n\t"
  133. "asrs %[x], %[x], #31 \n\t"
  134. RESTORE_ASM_SYNTAX
  135. :
  136. [s] "=&l" (s),
  137. [x] "+&l" (x)
  138. :
  139. :
  140. "cc" /* clobbers flag bits */
  141. );
  142. return (mbedtls_ct_condition_t) x;
  143. #elif defined(MBEDTLS_CT_X86_64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  144. uint64_t s;
  145. asm volatile ("mov %[x], %[s] \n\t"
  146. "neg %[s] \n\t"
  147. "or %[x], %[s] \n\t"
  148. "sar $63, %[s] \n\t"
  149. :
  150. [s] "=&a" (s)
  151. :
  152. [x] "D" (x)
  153. :
  154. );
  155. return (mbedtls_ct_condition_t) s;
  156. #elif defined(MBEDTLS_CT_X86_ASM) && defined(MBEDTLS_CT_SIZE_32)
  157. uint32_t s;
  158. asm volatile ("mov %[x], %[s] \n\t"
  159. "neg %[s] \n\t"
  160. "or %[s], %[x] \n\t"
  161. "sar $31, %[x] \n\t"
  162. :
  163. [s] "=&c" (s),
  164. [x] "+&a" (x)
  165. :
  166. :
  167. );
  168. return (mbedtls_ct_condition_t) x;
  169. #else
  170. const mbedtls_ct_uint_t xo = mbedtls_ct_compiler_opaque(x);
  171. #if defined(_MSC_VER)
  172. /* MSVC has a warning about unary minus on unsigned, but this is
  173. * well-defined and precisely what we want to do here */
  174. #pragma warning( push )
  175. #pragma warning( disable : 4146 )
  176. #endif
  177. // y is negative (i.e., top bit set) iff x is non-zero
  178. mbedtls_ct_int_t y = (-xo) | -(xo >> 1);
  179. // extract only the sign bit of y so that y == 1 (if x is non-zero) or 0 (if x is zero)
  180. y = (((mbedtls_ct_uint_t) y) >> (MBEDTLS_CT_SIZE - 1));
  181. // -y has all bits set (if x is non-zero), or all bits clear (if x is zero)
  182. return (mbedtls_ct_condition_t) (-y);
  183. #if defined(_MSC_VER)
  184. #pragma warning( pop )
  185. #endif
  186. #endif
  187. }
  188. static inline mbedtls_ct_uint_t mbedtls_ct_if(mbedtls_ct_condition_t condition,
  189. mbedtls_ct_uint_t if1,
  190. mbedtls_ct_uint_t if0)
  191. {
  192. #if defined(MBEDTLS_CT_AARCH64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  193. asm volatile ("and %x[if1], %x[if1], %x[condition] \n\t"
  194. "mvn %x[condition], %x[condition] \n\t"
  195. "and %x[condition], %x[condition], %x[if0] \n\t"
  196. "orr %x[condition], %x[if1], %x[condition]"
  197. :
  198. [condition] "+&r" (condition),
  199. [if1] "+&r" (if1)
  200. :
  201. [if0] "r" (if0)
  202. :
  203. );
  204. return (mbedtls_ct_uint_t) condition;
  205. #elif defined(MBEDTLS_CT_ARM_ASM) && defined(MBEDTLS_CT_SIZE_32)
  206. asm volatile (".syntax unified \n\t"
  207. "ands %[if1], %[if1], %[condition] \n\t"
  208. "mvns %[condition], %[condition] \n\t"
  209. "ands %[condition], %[condition], %[if0] \n\t"
  210. "orrs %[condition], %[if1], %[condition] \n\t"
  211. RESTORE_ASM_SYNTAX
  212. :
  213. [condition] "+&l" (condition),
  214. [if1] "+&l" (if1)
  215. :
  216. [if0] "l" (if0)
  217. :
  218. "cc"
  219. );
  220. return (mbedtls_ct_uint_t) condition;
  221. #elif defined(MBEDTLS_CT_X86_64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  222. asm volatile ("and %[condition], %[if1] \n\t"
  223. "not %[condition] \n\t"
  224. "and %[condition], %[if0] \n\t"
  225. "or %[if1], %[if0] \n\t"
  226. :
  227. [condition] "+&D" (condition),
  228. [if1] "+&S" (if1),
  229. [if0] "+&a" (if0)
  230. :
  231. :
  232. );
  233. return if0;
  234. #elif defined(MBEDTLS_CT_X86_ASM) && defined(MBEDTLS_CT_SIZE_32)
  235. asm volatile ("and %[condition], %[if1] \n\t"
  236. "not %[condition] \n\t"
  237. "and %[if0], %[condition] \n\t"
  238. "or %[condition], %[if1] \n\t"
  239. :
  240. [condition] "+&c" (condition),
  241. [if1] "+&a" (if1)
  242. :
  243. [if0] "b" (if0)
  244. :
  245. );
  246. return if1;
  247. #else
  248. mbedtls_ct_condition_t not_cond =
  249. (mbedtls_ct_condition_t) (~mbedtls_ct_compiler_opaque(condition));
  250. return (mbedtls_ct_uint_t) ((condition & if1) | (not_cond & if0));
  251. #endif
  252. }
  253. static inline mbedtls_ct_condition_t mbedtls_ct_uint_lt(mbedtls_ct_uint_t x, mbedtls_ct_uint_t y)
  254. {
  255. #if defined(MBEDTLS_CT_AARCH64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  256. uint64_t s1;
  257. asm volatile ("eor %x[s1], %x[y], %x[x] \n\t"
  258. "sub %x[x], %x[x], %x[y] \n\t"
  259. "bic %x[x], %x[x], %x[s1] \n\t"
  260. "and %x[s1], %x[s1], %x[y] \n\t"
  261. "orr %x[s1], %x[x], %x[s1] \n\t"
  262. "asr %x[x], %x[s1], 63"
  263. :
  264. [s1] "=&r" (s1),
  265. [x] "+&r" (x)
  266. :
  267. [y] "r" (y)
  268. :
  269. );
  270. return (mbedtls_ct_condition_t) x;
  271. #elif defined(MBEDTLS_CT_ARM_ASM) && defined(MBEDTLS_CT_SIZE_32)
  272. uint32_t s1;
  273. asm volatile (
  274. ".syntax unified \n\t"
  275. #if defined(__thumb__) && !defined(__thumb2__)
  276. "movs %[s1], %[x] \n\t"
  277. "eors %[s1], %[s1], %[y] \n\t"
  278. #else
  279. "eors %[s1], %[x], %[y] \n\t"
  280. #endif
  281. "subs %[x], %[x], %[y] \n\t"
  282. "bics %[x], %[x], %[s1] \n\t"
  283. "ands %[y], %[s1], %[y] \n\t"
  284. "orrs %[x], %[x], %[y] \n\t"
  285. "asrs %[x], %[x], #31 \n\t"
  286. RESTORE_ASM_SYNTAX
  287. :
  288. [s1] "=&l" (s1),
  289. [x] "+&l" (x),
  290. [y] "+&l" (y)
  291. :
  292. :
  293. "cc"
  294. );
  295. return (mbedtls_ct_condition_t) x;
  296. #elif defined(MBEDTLS_CT_X86_64_ASM) && (defined(MBEDTLS_CT_SIZE_32) || defined(MBEDTLS_CT_SIZE_64))
  297. uint64_t s;
  298. asm volatile ("mov %[x], %[s] \n\t"
  299. "xor %[y], %[s] \n\t"
  300. "sub %[y], %[x] \n\t"
  301. "and %[s], %[y] \n\t"
  302. "not %[s] \n\t"
  303. "and %[s], %[x] \n\t"
  304. "or %[y], %[x] \n\t"
  305. "sar $63, %[x] \n\t"
  306. :
  307. [s] "=&a" (s),
  308. [x] "+&D" (x),
  309. [y] "+&S" (y)
  310. :
  311. :
  312. );
  313. return (mbedtls_ct_condition_t) x;
  314. #elif defined(MBEDTLS_CT_X86_ASM) && defined(MBEDTLS_CT_SIZE_32)
  315. uint32_t s;
  316. asm volatile ("mov %[x], %[s] \n\t"
  317. "xor %[y], %[s] \n\t"
  318. "sub %[y], %[x] \n\t"
  319. "and %[s], %[y] \n\t"
  320. "not %[s] \n\t"
  321. "and %[s], %[x] \n\t"
  322. "or %[y], %[x] \n\t"
  323. "sar $31, %[x] \n\t"
  324. :
  325. [s] "=&b" (s),
  326. [x] "+&a" (x),
  327. [y] "+&c" (y)
  328. :
  329. :
  330. );
  331. return (mbedtls_ct_condition_t) x;
  332. #else
  333. /* Ensure that the compiler cannot optimise the following operations over x and y,
  334. * even if it knows the value of x and y.
  335. */
  336. const mbedtls_ct_uint_t xo = mbedtls_ct_compiler_opaque(x);
  337. const mbedtls_ct_uint_t yo = mbedtls_ct_compiler_opaque(y);
  338. /*
  339. * Check if the most significant bits (MSB) of the operands are different.
  340. * cond is true iff the MSBs differ.
  341. */
  342. mbedtls_ct_condition_t cond = mbedtls_ct_bool((xo ^ yo) >> (MBEDTLS_CT_SIZE - 1));
  343. /*
  344. * If the MSB are the same then the difference x-y will be negative (and
  345. * have its MSB set to 1 during conversion to unsigned) if and only if x<y.
  346. *
  347. * If the MSB are different, then the operand with the MSB of 1 is the
  348. * bigger. (That is if y has MSB of 1, then x<y is true and it is false if
  349. * the MSB of y is 0.)
  350. */
  351. // Select either y, or x - y
  352. mbedtls_ct_uint_t ret = mbedtls_ct_if(cond, yo, (mbedtls_ct_uint_t) (xo - yo));
  353. // Extract only the MSB of ret
  354. ret = ret >> (MBEDTLS_CT_SIZE - 1);
  355. // Convert to a condition (i.e., all bits set iff non-zero)
  356. return mbedtls_ct_bool(ret);
  357. #endif
  358. }
  359. static inline mbedtls_ct_condition_t mbedtls_ct_uint_ne(mbedtls_ct_uint_t x, mbedtls_ct_uint_t y)
  360. {
  361. /* diff = 0 if x == y, non-zero otherwise */
  362. const mbedtls_ct_uint_t diff = mbedtls_ct_compiler_opaque(x) ^ mbedtls_ct_compiler_opaque(y);
  363. /* all ones if x != y, 0 otherwise */
  364. return mbedtls_ct_bool(diff);
  365. }
  366. static inline unsigned char mbedtls_ct_uchar_in_range_if(unsigned char low,
  367. unsigned char high,
  368. unsigned char c,
  369. unsigned char t)
  370. {
  371. const unsigned char co = (unsigned char) mbedtls_ct_compiler_opaque(c);
  372. const unsigned char to = (unsigned char) mbedtls_ct_compiler_opaque(t);
  373. /* low_mask is: 0 if low <= c, 0x...ff if low > c */
  374. unsigned low_mask = ((unsigned) co - low) >> 8;
  375. /* high_mask is: 0 if c <= high, 0x...ff if c > high */
  376. unsigned high_mask = ((unsigned) high - co) >> 8;
  377. return (unsigned char) (~(low_mask | high_mask)) & to;
  378. }
  379. /* ============================================================================
  380. * Everything below here is trivial wrapper functions
  381. */
  382. static inline size_t mbedtls_ct_size_if(mbedtls_ct_condition_t condition,
  383. size_t if1,
  384. size_t if0)
  385. {
  386. return (size_t) mbedtls_ct_if(condition, (mbedtls_ct_uint_t) if1, (mbedtls_ct_uint_t) if0);
  387. }
  388. static inline unsigned mbedtls_ct_uint_if(mbedtls_ct_condition_t condition,
  389. unsigned if1,
  390. unsigned if0)
  391. {
  392. return (unsigned) mbedtls_ct_if(condition, (mbedtls_ct_uint_t) if1, (mbedtls_ct_uint_t) if0);
  393. }
  394. static inline mbedtls_ct_condition_t mbedtls_ct_bool_if(mbedtls_ct_condition_t condition,
  395. mbedtls_ct_condition_t if1,
  396. mbedtls_ct_condition_t if0)
  397. {
  398. return (mbedtls_ct_condition_t) mbedtls_ct_if(condition, (mbedtls_ct_uint_t) if1,
  399. (mbedtls_ct_uint_t) if0);
  400. }
  401. #if defined(MBEDTLS_BIGNUM_C)
  402. static inline mbedtls_mpi_uint mbedtls_ct_mpi_uint_if(mbedtls_ct_condition_t condition,
  403. mbedtls_mpi_uint if1,
  404. mbedtls_mpi_uint if0)
  405. {
  406. return (mbedtls_mpi_uint) mbedtls_ct_if(condition,
  407. (mbedtls_ct_uint_t) if1,
  408. (mbedtls_ct_uint_t) if0);
  409. }
  410. #endif
  411. static inline size_t mbedtls_ct_size_if_else_0(mbedtls_ct_condition_t condition, size_t if1)
  412. {
  413. return (size_t) (condition & if1);
  414. }
  415. static inline unsigned mbedtls_ct_uint_if_else_0(mbedtls_ct_condition_t condition, unsigned if1)
  416. {
  417. return (unsigned) (condition & if1);
  418. }
  419. static inline mbedtls_ct_condition_t mbedtls_ct_bool_if_else_0(mbedtls_ct_condition_t condition,
  420. mbedtls_ct_condition_t if1)
  421. {
  422. return (mbedtls_ct_condition_t) (condition & if1);
  423. }
  424. #if defined(MBEDTLS_BIGNUM_C)
  425. static inline mbedtls_mpi_uint mbedtls_ct_mpi_uint_if_else_0(mbedtls_ct_condition_t condition,
  426. mbedtls_mpi_uint if1)
  427. {
  428. return (mbedtls_mpi_uint) (condition & if1);
  429. }
  430. #endif /* MBEDTLS_BIGNUM_C */
  431. static inline int mbedtls_ct_error_if(mbedtls_ct_condition_t condition, int if1, int if0)
  432. {
  433. /* Coverting int -> uint -> int here is safe, because we require if1 and if0 to be
  434. * in the range -32767..0, and we require 32-bit int and uint types.
  435. *
  436. * This means that (0 <= -if0 < INT_MAX), so negating if0 is safe, and similarly for
  437. * converting back to int.
  438. */
  439. return -((int) mbedtls_ct_if(condition, (mbedtls_ct_uint_t) (-if1),
  440. (mbedtls_ct_uint_t) (-if0)));
  441. }
  442. static inline int mbedtls_ct_error_if_else_0(mbedtls_ct_condition_t condition, int if1)
  443. {
  444. return -((int) (condition & (-if1)));
  445. }
  446. static inline mbedtls_ct_condition_t mbedtls_ct_uint_eq(mbedtls_ct_uint_t x,
  447. mbedtls_ct_uint_t y)
  448. {
  449. return ~mbedtls_ct_uint_ne(x, y);
  450. }
  451. static inline mbedtls_ct_condition_t mbedtls_ct_uint_gt(mbedtls_ct_uint_t x,
  452. mbedtls_ct_uint_t y)
  453. {
  454. return mbedtls_ct_uint_lt(y, x);
  455. }
  456. static inline mbedtls_ct_condition_t mbedtls_ct_uint_ge(mbedtls_ct_uint_t x,
  457. mbedtls_ct_uint_t y)
  458. {
  459. return ~mbedtls_ct_uint_lt(x, y);
  460. }
  461. static inline mbedtls_ct_condition_t mbedtls_ct_uint_le(mbedtls_ct_uint_t x,
  462. mbedtls_ct_uint_t y)
  463. {
  464. return ~mbedtls_ct_uint_gt(x, y);
  465. }
  466. static inline mbedtls_ct_condition_t mbedtls_ct_bool_ne(mbedtls_ct_condition_t x,
  467. mbedtls_ct_condition_t y)
  468. {
  469. return (mbedtls_ct_condition_t) (x ^ y);
  470. }
  471. static inline mbedtls_ct_condition_t mbedtls_ct_bool_and(mbedtls_ct_condition_t x,
  472. mbedtls_ct_condition_t y)
  473. {
  474. return (mbedtls_ct_condition_t) (x & y);
  475. }
  476. static inline mbedtls_ct_condition_t mbedtls_ct_bool_or(mbedtls_ct_condition_t x,
  477. mbedtls_ct_condition_t y)
  478. {
  479. return (mbedtls_ct_condition_t) (x | y);
  480. }
  481. static inline mbedtls_ct_condition_t mbedtls_ct_bool_not(mbedtls_ct_condition_t x)
  482. {
  483. return (mbedtls_ct_condition_t) (~x);
  484. }
  485. #if defined(MBEDTLS_COMPILER_IS_GCC) && (__GNUC__ > 4)
  486. /* Restore warnings for -Wredundant-decls on gcc */
  487. #pragma GCC diagnostic pop
  488. #endif
  489. #endif /* MBEDTLS_CONSTANT_TIME_IMPL_H */