2021-01-18 02:52:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-18 22:57:33 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "expiring_signature.h"
|
|
|
|
#include "signing_key.h"
|
|
|
|
#include "time_helpers.h"
|
|
|
|
|
2021-01-18 02:52:36 +00:00
|
|
|
namespace BareMinimumCrypto {
|
2021-01-18 22:57:33 +00:00
|
|
|
using namespace std;
|
2021-01-18 02:52:36 +00:00
|
|
|
|
2021-01-18 22:57:33 +00:00
|
|
|
struct Sender {
|
|
|
|
static optional <Sender> create (SigningKey k, ExpiringSignature c);
|
|
|
|
|
|
|
|
// Signs data and attaches our cert from the CA
|
2021-01-20 01:31:41 +00:00
|
|
|
optional <Bytes> sign (const Bytes & data) const;
|
2021-01-18 22:57:33 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SigningKey sender_key;
|
|
|
|
ExpiringSignature cert;
|
|
|
|
|
2021-01-20 01:31:41 +00:00
|
|
|
Bytes try_sign (const Bytes & data, Instant now) const;
|
|
|
|
optional <Bytes> sign (const Bytes & data, Instant now) const;
|
2021-01-18 22:57:33 +00:00
|
|
|
};
|
2021-01-18 02:52:36 +00:00
|
|
|
}
|