1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#ifndef __CERT_HH__
#define __CERT_HH__
// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
//
// This program is made available under the GNU GPL version 2.0 or
// greater. See the accompanying file COPYING for details.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.
#include <map>
#include <set>
#include <vector>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <time.h>
#include "vocab.hh"
// Certs associate an opaque name/value pair with a revision ID, and
// are accompanied by an RSA public-key signature attesting to the
// association. Users can write as much extra meta-data as they like
// about revisions, using certs, without needing anyone's special
// permission.
class app_state;
struct packet_consumer;
struct cert
{
cert();
cert(hexenc<id> const & ident,
cert_name const & name,
base64<cert_value> const & value,
rsa_keypair_id const & key);
cert(hexenc<id> const & ident,
cert_name const & name,
base64<cert_value> const & value,
rsa_keypair_id const & key,
base64<rsa_sha1_signature> const & sig);
hexenc<id> ident;
cert_name name;
base64<cert_value> value;
rsa_keypair_id key;
base64<rsa_sha1_signature> sig;
bool operator<(cert const & other) const;
bool operator==(cert const & other) const;
};
EXTERN template class revision<cert>;
EXTERN template class manifest<cert>;
// These 3 are for netio support.
void read_cert(std::string const & in, cert & t);
void write_cert(cert const & t, std::string & out);
void cert_hash_code(cert const & t, hexenc<id> & out);
typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
void cert_signable_text(cert const & t,std::string & out);
cert_status check_cert(app_state & app, cert const & t);
bool priv_key_exists(app_state & app, rsa_keypair_id const & id);
void load_key_pair(app_state & app,
rsa_keypair_id const & id,
keypair & kp);
void calculate_cert(app_state & app, cert & t);
void make_simple_cert(hexenc<id> const & id,
cert_name const & nm,
cert_value const & cv,
app_state & app,
cert & c);
void erase_bogus_certs(std::vector< revision<cert> > & certs,
app_state & app);
void erase_bogus_certs(std::vector< manifest<cert> > & certs,
app_state & app);
// Special certs -- system won't work without them.
extern std::string const branch_cert_name;
void
cert_revision_in_branch(revision_id const & ctx,
cert_value const & branchname,
app_state & app,
packet_consumer & pc);
void
get_branch_heads(cert_value const & branchname,
app_state & app,
std::set<revision_id> & heads);
// We also define some common cert types, to help establish useful
// conventions. you should use these unless you have a compelling
// reason not to.
// N()'s out if there is no unique key for us to use
void
get_user_key(rsa_keypair_id & key, app_state & app);
void
guess_branch(revision_id const & id,
app_state & app,
cert_value & branchname);
extern std::string const date_cert_name;
extern std::string const author_cert_name;
extern std::string const tag_cert_name;
extern std::string const changelog_cert_name;
extern std::string const comment_cert_name;
extern std::string const testresult_cert_name;
void
cert_revision_date_now(revision_id const & m,
app_state & app,
packet_consumer & pc);
void
cert_revision_date_time(revision_id const & m,
boost::posix_time::ptime t,
app_state & app,
packet_consumer & pc);
void
cert_revision_date_time(revision_id const & m,
time_t time,
app_state & app,
packet_consumer & pc);
void
cert_revision_author(revision_id const & m,
std::string const & author,
app_state & app,
packet_consumer & pc);
void
cert_revision_author_default(revision_id const & m,
app_state & app,
packet_consumer & pc);
void
cert_revision_tag(revision_id const & m,
std::string const & tagname,
app_state & app,
packet_consumer & pc);
void
cert_revision_changelog(revision_id const & m,
utf8 const & changelog,
app_state & app,
packet_consumer & pc);
void
cert_revision_comment(revision_id const & m,
utf8 const & comment,
app_state & app,
packet_consumer & pc);
void
cert_revision_testresult(revision_id const & m,
std::string const & results,
app_state & app,
packet_consumer & pc);
// Local Variables:
// mode: C++
// fill-column: 76
// c-file-style: "gnu"
// indent-tabs-mode: nil
// End:
// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
#endif // __CERT_HH__
|