Botan
3.9.0
Crypto and TLS for C&
src
lib
utils
stack_scrubbing.h
Go to the documentation of this file.
1
/*
2
* Helpers for compiler-assisted stack scrubbing
3
* (C) 2025 Jack Lloyd
4
* 2025 René Meusel - Rohde & Schwarz Cybersecurity
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8
9
#ifndef BOTAN_UTIL_STACK_SCRUBBING_H_
10
#define BOTAN_UTIL_STACK_SCRUBBING_H_
11
12
#include <botan/compiler.h>
13
#include <botan/internal/target_info.h>
14
15
// TODO(Botan4): Move this to compiler.h (currently still a public header)
16
17
#if !defined(BOTAN_SCRUB_STACK_AFTER_RETURN)
18
#if BOTAN_COMPILER_HAS_ATTRIBUTE(strub) && defined(BOTAN_USE_COMPILER_ASSISTED_STACK_SCRUBBING)
19
/**
20
* When a function definition is annotated with this macro, the compiler
21
* generates a wrapper for the function's body to handle stack scrubbing
22
* in the wrapper. In contrast to 'strub("at-calls")' this does not alter
23
* the function's ABI.
24
*
25
* It is okay to use this annotation on C++ method definitions (in *.cpp),
26
* even if the function is a public API.
27
*
28
* Currently this is supported on GCC 14+ only
29
* See: https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Common-Type-Attributes.html#index-strub-type-attribute
30
*/
31
#define BOTAN_SCRUB_STACK_AFTER_RETURN BOTAN_COMPILER_ATTRIBUTE(strub("internal"))
32
#else
33
#define BOTAN_SCRUB_STACK_AFTER_RETURN
34
#endif
35
#endif
36
37
#endif
Generated by
1.14.0