Sesame-Device/include/relay/CryptoPrimitives.h

59 lines
1013 B
C
Raw Normal View History

2023-12-14 09:42:54 +01:00
#pragma once
#include <stdint.h>
#pragma pack(push, 1)
/**
* @brief A private key for asymmetric cryptography
*/
2024-02-09 20:50:17 +01:00
struct PrivateKey {
2023-12-14 09:42:54 +01:00
/// @brief The size of a private key
2024-02-10 11:32:16 +01:00
static constexpr int size = 32;
2023-12-14 09:42:54 +01:00
uint8_t bytes[size];
2024-02-10 11:32:16 +01:00
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
2024-02-09 20:50:17 +01:00
};
2023-12-14 09:42:54 +01:00
/**
* @brief A public key for asymmetric cryptography
*/
2024-02-09 20:50:17 +01:00
struct PublicKey {
2023-12-14 09:42:54 +01:00
/// @brief The size of a public key
2024-02-10 11:32:16 +01:00
static constexpr int size = 32;
2023-12-14 09:42:54 +01:00
uint8_t bytes[size];
2024-02-10 11:32:16 +01:00
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
2024-02-09 20:50:17 +01:00
};
2023-12-14 09:42:54 +01:00
/**
* @brief A signature of some data using a private key
*/
2024-02-09 20:50:17 +01:00
struct Signature {
2023-12-14 09:42:54 +01:00
/// @brief The size of a message signature
2024-02-10 11:32:16 +01:00
static constexpr int size = 64;
2023-12-14 09:42:54 +01:00
uint8_t bytes[size];
2024-02-09 20:50:17 +01:00
};
2023-12-14 09:42:54 +01:00
#pragma pack(pop)