monotone

monotone Mtn Source Tree

Root/cert.hh

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

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status