48 lines
1005 B
C++
48 lines
1005 B
C++
#include "expiring_signature.h"
|
|
|
|
namespace BareMinimumCrypto {
|
|
// C++ nonsense
|
|
bool ExpiringSignature::operator == (const ExpiringSignature & o) const {
|
|
return
|
|
cert == o.cert &&
|
|
sig == o.sig
|
|
;
|
|
}
|
|
|
|
bool ExpiringSignature::operator != (const ExpiringSignature & o) const {
|
|
return ! (*this == o);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
|
|
return ExpiringSignature {
|
|
cert,
|
|
sig,
|
|
}.to_msgpack ();
|
|
}
|
|
|
|
optional <KeyCertFile> KeyCertFile::try_from_msgpack (const json & msg)
|
|
{
|
|
return nullopt;
|
|
}
|
|
}
|