Software APIs
Typedefs | Enumerations
hardened.h File Reference

(30d7e787c7)

Data Types for use in Hardened Code. More...

Go to the source code of this file.

Typedefs

typedef enum hardened_bool hardened_bool_t
 This is a boolean type for use in hardened contexts. More...
 

Enumerations

enum  hardened_bool {
  kHardenedBoolTrue = HARDENED_BOOL_TRUE ,
  kHardenedBoolFalse = HARDENED_BOOL_FALSE ,
  kHardenedBoolTrue = 0x739 ,
  kHardenedBoolFalse = 0x1d4
}
 This is a boolean type for use in hardened contexts. More...
 

Detailed Description

Data Types for use in Hardened Code.

Definition in file hardened.h.

Typedef Documentation

◆ hardened_bool_t

This is a boolean type for use in hardened contexts.

The intention is that this is used instead of <stdbool.h>'s #bool, where a higher hamming distance is required between the truthy and the falsey value.

The values below were chosen at random, with some specific restrictions. They have a Hamming Distance of 8, and they are 11-bit values so they can be materialized with a single instruction on RISC-V. They are also specifically not the complement of each other.

Enumeration Type Documentation

◆ hardened_bool

This is a boolean type for use in hardened contexts.

The intention is that this is used instead of <stdbool.h>'s #bool, where a higher hamming distance is required between the truthy and the falsey value.

The values below were chosen at random, with some specific restrictions. They have a Hamming Distance of 8, and they are 11-bit values so they can be materialized with a single instruction on RISC-V. They are also specifically not the complement of each other.

Enumerator
kHardenedBoolTrue 

The truthy value, expected to be used like #true.

kHardenedBoolFalse 

The falsey value, expected to be used like #false.

kHardenedBoolTrue 

The truthy value, expected to be used like #true.

kHardenedBoolFalse 

The falsey value, expected to be used like #false.

Definition at line 28 of file hardened.h.