Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::UUID Class Reference

`#include <uuid.h>`

## Public Member Functions
const std::vector< uint8_t > | binary_value () const
bool | is_valid () const
bool | operator!= (const UUID &other)
bool | operator== (const UUID &other)
std::string | to_string () const
| UUID ()
| UUID (RandomNumberGenerator &rng)
| UUID (const std::vector< uint8_t > &blob)
| UUID (const std::string &uuid_str)

## Detailed Description

Definition at line 18 of file uuid.h.

## Constructor & Destructor Documentation

Botan::UUID::UUID | ( |  | ) |
| inline

Definition at line 22 of file uuid.h.

22 : m_uuid(0) {}

Botan::UUID::UUID | ( | RandomNumberGenerator & | rng | ) |
| inline

Definition at line 24 of file uuid.h.

References Botan::RandomNumberGenerator::randomize().

25 {
26 m_uuid.resize(16);
27 rng.randomize(m_uuid.data(), m_uuid.size());
28
29 // Mark as a random UUID (RFC 4122 sec 4.4)
30 m_uuid[6] = 0x40 | (m_uuid[6] & 0x0F);
31
32 // Set two reserved bits
33 m_uuid[8] = 0xC0 | (m_uuid[8] & 0x3F);
34 }

Botan::UUID::UUID | ( | const std::vector< uint8_t > & | blob | ) |
| inline

Definition at line 36 of file uuid.h.

References Botan::hex_encode().

37 {
38 if(blob.size() != 16)
39 {
40 throw Invalid_Argument("Bad UUID blob " + hex_encode(blob));
41 }
42
43 m_uuid = blob;
44 }
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:14

Botan::UUID::UUID | ( | const std::string & | uuid_str | ) |
| inline

Definition at line 46 of file uuid.h.

References Botan::hex_decode().

47 {
48 if(uuid_str.size() != 36 ||
49 uuid_str[8] != '-' ||
50 uuid_str[14] != '-' ||
51 uuid_str[19] != '-' ||
52 uuid_str[24] != '-')
53 {
54 throw Invalid_Argument("Bad UUID '" + uuid_str + "'");
55 }
56
57 std::string just_hex;
58 for(size_t i = 0; i != uuid_str.size(); ++i)
59 {
60 char c = uuid_str[i];
61
62 if(c == '-')
63 continue;
64
65 just_hex += c;
66 }
67
68 m_uuid = hex_decode(just_hex);
69
70 if(m_uuid.size() != 16)
71 {
72 throw Invalid_Argument("Bad UUID '" + uuid_str + "'");
73 }
74 }
Botan::hex_decode
size_t hex_decode(uint8_t output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
Definition: hex.cpp:49

## Member Function Documentation

const std::vector<uint8_t> Botan::UUID::binary_value | ( |  | ) | const
| inline

Definition at line 89 of file uuid.h.

89 { return m_uuid; }

bool Botan::UUID::is_valid | ( |  | ) | const
| inline

Definition at line 98 of file uuid.h.

Referenced by Botan::TPM_PrivateKey::register_key().

98 { return m_uuid.size() == 16; }

bool Botan::UUID::operator!= | ( | const UUID & | other | ) |
| inline

Definition at line 96 of file uuid.h.

96 { return !(*this == other); }

bool Botan::UUID::operator== | ( | const UUID & | other | ) |
| inline

Definition at line 91 of file uuid.h.

92 {
93 return m_uuid == other.m_uuid;
94 }

std::string Botan::UUID::to_string | ( |  | ) | const
| inline

Definition at line 77 of file uuid.h.

References Botan::hex_encode().

Referenced by Botan::TPM_PrivateKey::register_key().

78 {
79 std::string h = hex_encode(m_uuid);
80
81 h.insert(8, "-");
82 h.insert(14, "-");
83 h.insert(19, "-");
84 h.insert(24, "-");
85
86 return h;
87 }
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:14

The documentation for this class was generated from the following file:

- src/lib/prov/tpm/uuid.h