2021-01-18 00:00:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-01-18 01:17:06 +00:00
|
|
|
#include "json.hpp"
|
|
|
|
|
2021-01-20 23:24:55 +00:00
|
|
|
#include "time_helpers.h"
|
|
|
|
|
2021-01-18 00:00:45 +00:00
|
|
|
namespace BareMinimumCrypto {
|
|
|
|
using namespace std;
|
2021-01-20 23:24:55 +00:00
|
|
|
using nlohmann::json;
|
2021-01-18 00:00:45 +00:00
|
|
|
|
2021-01-20 01:31:41 +00:00
|
|
|
typedef vector <uint8_t> Bytes;
|
|
|
|
|
2021-01-18 00:00:45 +00:00
|
|
|
struct ExpiringSignature {
|
2021-01-18 22:13:48 +00:00
|
|
|
// Payload is contained in here
|
2021-01-20 01:31:41 +00:00
|
|
|
Bytes cert;
|
|
|
|
Bytes sig;
|
2021-01-21 23:00:10 +00:00
|
|
|
Bytes signer_pubkey;
|
2021-01-18 00:00:45 +00:00
|
|
|
|
|
|
|
bool operator == (const ExpiringSignature & o) const;
|
|
|
|
bool operator != (const ExpiringSignature & o) const;
|
2021-01-21 23:00:10 +00:00
|
|
|
|
|
|
|
Bytes to_msgpack () const;
|
2021-01-18 00:00:45 +00:00
|
|
|
};
|
2021-01-20 23:24:55 +00:00
|
|
|
|
|
|
|
struct KeyCertFile {
|
|
|
|
Bytes sig;
|
|
|
|
|
|
|
|
// The rest of the fields are inside a nested msgpack that gets signed
|
|
|
|
Bytes pubkey;
|
|
|
|
TimeRange valid_time;
|
|
|
|
|
|
|
|
Bytes to_msgpack () const;
|
|
|
|
static optional <KeyCertFile> try_from_msgpack (const json & msg);
|
|
|
|
};
|
2021-01-18 00:00:45 +00:00
|
|
|
}
|