ptth/bare_minimum_crypto/cpp/sender.h

28 lines
667 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 <vector <uint8_t>> sign (const vector <uint8_t> & data) const;
private:
SigningKey sender_key;
ExpiringSignature cert;
vector <uint8_t> try_sign (const vector <uint8_t> & data, Instant now) const;
optional <vector <uint8_t>> sign (const vector <uint8_t> & data, Instant now) const;
};
2021-01-18 02:52:36 +00:00
}