blob: 98bee7e48c066a14d343aacc04b9a2a15d346505 [file] [log] [blame]
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001/**
2 * \file constant_flow.h
3 *
4 * \brief This file contains tools to ensure tested code has constant flow.
5 */
6
7/*
8 * Copyright (C) 2020, ARM Limited, All Rights Reserved
9 * SPDX-License-Identifier: Apache-2.0
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may
12 * not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 *
23 * This file is part of mbed TLS (https://tls.mbed.org)
24 */
25
26#ifndef TEST_CONSTANT_FLOW_H
27#define TEST_CONSTANT_FLOW_H
28
29#if !defined(MBEDTLS_CONFIG_FILE)
30#include "mbedtls/config.h"
31#else
32#include MBEDTLS_CONFIG_FILE
33#endif
34
35#if defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
36#include <sanitizer/msan_interface.h>
37
38/* Use macros to avoid messing up with origin tracking */
39#define TEST_CF_SECRET __msan_allocated_memory
40// void __msan_allocated_memory(const volatile void* data, size_t size);
41#define TEST_CF_PUBLIC __msan_unpoison
42// void __msan_unpoison(const volatile void *a, size_t size);
43
44#else /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
45
46#define TEST_CF_SECRET(ptr, size)
47#define TEST_CF_PUBLIC(ptr, size)
48
49#endif /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
50
51#endif /* TEST_CONSTANT_FLOW_H */