20 Letter::Letter(
const string &fqrn,
25 signature_manager_(signature_manager)
31 unsigned char *cert_buf = NULL;
32 unsigned cert_buf_size;
36 string cert_base64 =
Base64(
string(reinterpret_cast<char *>(cert_buf),
40 string output =
text_;
41 output += string(
"\n##\n") +
45 "X" + cert_base64 +
"\n";
47 shash::HashMem(reinterpret_cast<const unsigned char *>(output.data()),
48 output.length(), &output_hash);
49 output +=
"--\n" + output_hash.
ToString() +
"\n";
54 reinterpret_cast<const unsigned char *>(output_hash.
ToString().data()),
57 output.append(reinterpret_cast<char *>(sig), sig_size);
80 const unsigned char *data_ptr =
81 reinterpret_cast<const unsigned char *
>(dec.data());
83 data_ptr, dec.length(),
'#', &msg_len, &env_pos);
84 if (env_pos >= dec.length())
89 *msg = dec.substr(0, msg_len-1);
91 data_ptr+env_pos, dec.length()-env_pos,
'-', &env_len, &sig_pos);
92 if (sig_pos >= dec.length())
95 map<char, string> env;
97 map<char, string>::const_iterator iter;
98 if ((iter = env.find(
'T')) == env.end())
102 if (timestamp + max_age < static_cast<uint64_t>(time(NULL)))
105 if ((iter = env.find(
'N')) == env.end())
107 if (iter->second !=
fqrn_)
109 if ((iter = env.find(
'X')) == env.end())
111 string cert_b64 = iter->second;
116 reinterpret_cast<const unsigned char *>(cert->data()), cert->length());
121 data_ptr, dec.length(),
false);
std::string ToString(const bool with_suffix=false) const
Failures Verify(uint64_t max_age, std::string *msg, std::string *cert)
bool LoadCertificateMem(const unsigned char *buffer, const unsigned buffer_size)
assert((mem||(size==0))&&"Out Of Memory")
static void CutLetter(const unsigned char *buffer, const unsigned buffer_size, const char separator, unsigned *letter_length, unsigned *pos_after_mark)
bool Debase64(const string &data, string *decoded)
bool Sign(const unsigned char *buffer, const unsigned buffer_size, unsigned char **signature, unsigned *signature_size)
std::string Sign(const shash::Algorithms hash_algorithm)
string StringifyInt(const int64_t value)
bool WriteCertificateMem(unsigned char **buffer, unsigned *buffer_size)
void HashMem(const unsigned char *buffer, const unsigned buffer_size, Any *any_digest)
string Base64(const string &data)
uint64_t String2Uint64(const string &value)
unsigned GetHexSize() const
signature::SignatureManager * signature_manager_
void ParseKeyvalMem(const unsigned char *buffer, const unsigned buffer_size, map< char, string > *content)
bool VerifyLetter(const unsigned char *buffer, const unsigned buffer_size, const bool by_rsa)