aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/ta_utils.h
blob: 36ee551ccad0d0257cf1b68be37076fc7252abb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Timing Attack Countermeasure Functions
* (C) 2010 Falko Strenzke, Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#ifndef BOTAN_TIMING_ATTACK_CM_H__
#define BOTAN_TIMING_ATTACK_CM_H__

#include <botan/types.h>

namespace Botan {

namespace TA_CM {

/**
* Function used in timing attack countermeasures
* See Wagner, Molnar, et al "The Program Counter Security Model"
*
* @param in an integer
* @return 0 if in == 0 else 0xFFFFFFFF
*/
u32bit gen_mask_u32bit(u32bit in);

/**
* Branch-free maximum
* Note: assumes twos-complement signed representation
* @param a an integer
* @param b an integer
* @return max(a,b)
*/
u32bit max_32(u32bit a, u32bit b);

/**
* Branch-free minimum
* Note: assumes twos-complement signed representation
* @param a an integer
* @param b an integer
* @return min(a,b)
*/
u32bit min_32(u32bit a, u32bit b);

}

}

#endif