2021-01-18 00:00:45 +00:00
|
|
|
#include "expiring_signature.h"
|
|
|
|
|
|
|
|
namespace BareMinimumCrypto {
|
|
|
|
// C++ nonsense
|
|
|
|
bool ExpiringSignature::operator == (const ExpiringSignature & o) const {
|
|
|
|
return
|
2021-01-18 22:13:48 +00:00
|
|
|
cert == o.cert &&
|
2021-01-18 00:00:45 +00:00
|
|
|
sig == o.sig
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ExpiringSignature::operator != (const ExpiringSignature & o) const {
|
|
|
|
return ! (*this == o);
|
|
|
|
}
|
2021-01-20 23:24:55 +00:00
|
|
|
|
2021-01-21 23:00:10 +00:00
|
|
|
Bytes ExpiringSignature::to_msgpack () const {
|
|
|
|
const json j {
|
|
|
|
{"app", "4B27CL32"},
|
|
|
|
{"schema", "MSYZGDBI"},
|
|
|
|
{"sig", json::binary (sig)},
|
|
|
|
{"cert", json::binary (cert)},
|
|
|
|
{"signer_pubkey", json::binary (signer_pubkey)},
|
|
|
|
};
|
|
|
|
|
|
|
|
return json::to_msgpack (j);
|
|
|
|
}
|
|
|
|
|
2021-01-20 23:24:55 +00:00
|
|
|
Bytes KeyCertFile::to_msgpack () const {
|
|
|
|
const json cert_j {
|
|
|
|
{"pubkey", json::binary (pubkey)},
|
|
|
|
{"not_before", valid_time.not_before},
|
|
|
|
{"not_after", valid_time.not_after},
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto cert = json::to_msgpack (cert_j);
|
|
|
|
|
2021-01-21 23:00:10 +00:00
|
|
|
return ExpiringSignature {
|
|
|
|
cert,
|
|
|
|
sig,
|
|
|
|
}.to_msgpack ();
|
2021-01-20 23:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
optional <KeyCertFile> KeyCertFile::try_from_msgpack (const json & msg)
|
|
|
|
{
|
|
|
|
return nullopt;
|
|
|
|
}
|
2021-01-18 00:00:45 +00:00
|
|
|
}
|