Sesame-Device/include/relay/CryptoPrimitives.h
2024-02-10 11:32:16 +01:00

59 lines
1013 B
C

#pragma once
#include <stdint.h>
#pragma pack(push, 1)
/**
* @brief A private key for asymmetric cryptography
*/
struct PrivateKey {
/// @brief The size of a private key
static constexpr int size = 32;
uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
};
/**
* @brief A public key for asymmetric cryptography
*/
struct PublicKey {
/// @brief The size of a public key
static constexpr int size = 32;
uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
};
/**
* @brief A signature of some data using a private key
*/
struct Signature {
/// @brief The size of a message signature
static constexpr int size = 64;
uint8_t bytes[size];
};
#pragma pack(pop)