ptth/bare_minimum_crypto/cpp/sender.h

28 lines
601 B
C
Raw Normal View History

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
optional <Bytes> sign (const Bytes & data) const;
2021-01-18 22:57:33 +00:00
private:
SigningKey sender_key;
ExpiringSignature cert;
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
}