monotone

monotone Mtn Source Tree

Root/cert.hh

1#ifndef __CERT_HH__
2#define __CERT_HH__
3
4// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9#include "vocab.hh"
10
11#include <set>
12#include <map>
13#include <vector>
14#include <time.h>
15
16// certs associate an opaque name/value pair with a particular identifier in
17// the system (eg. a manifest or file id) and are accompanied by an RSA
18// public-key signature attesting to the association. users can write as
19// much extra meta-data as they like about files or manifests, using certs,
20// without needing anyone's special permission.
21
22struct app_state;
23struct packet_consumer;
24
25struct cert
26{
27 cert();
28 cert(hexenc<id> const & ident,
29 cert_name const & name,
30 base64<cert_value> const & value,
31 rsa_keypair_id const & key);
32 cert(hexenc<id> const & ident,
33 cert_name const & name,
34 base64<cert_value> const & value,
35 rsa_keypair_id const & key,
36 base64<rsa_sha1_signature> const & sig);
37 hexenc<id> ident;
38 cert_name name;
39 base64<cert_value> value;
40 rsa_keypair_id key;
41 base64<rsa_sha1_signature> sig;
42 bool operator<(cert const & other) const;
43 bool operator==(cert const & other) const;
44};
45
46
47// these 3 are for netio support
48void read_cert(std::string const & in, cert & t);
49void write_cert(cert const & t, std::string & out);
50void cert_hash_code(cert const & t, hexenc<id> & out);
51
52void cert_signable_text(cert const & t,std::string & out);
53bool check_cert(app_state & app, cert const & t);
54void calculate_cert(app_state & app, cert & t);
55void make_simple_cert(hexenc<id> const & id,
56 cert_name const & nm,
57 cert_value const & cv,
58 app_state & app,
59 cert & c);
60
61void erase_bogus_certs(std::vector< manifest<cert> > & certs,
62 app_state & app);
63
64void erase_bogus_certs(std::vector< file<cert> > & certs,
65 app_state & app);
66
67// special certs -- system won't work without them
68
69extern std::string const ancestor_cert_name;
70extern std::string const branch_cert_name;
71
72void cert_manifest_in_branch(manifest_id const & manifest,
73 cert_value const & branchname,
74 app_state & app,
75 packet_consumer & pc);
76
77void get_branch_heads(cert_value const & branchname,
78 app_state & app,
79 std::set<manifest_id> & heads);
80
81void cert_file_ancestor(file_id const & parent,
82file_id const & child,
83app_state & app,
84packet_consumer & pc);
85
86void cert_manifest_ancestor(manifest_id const & parent,
87 manifest_id const & child,
88 app_state & app,
89 packet_consumer & pc);
90
91void write_ancestry_paths(manifest_id const & ancestor,
92 manifest_id const & child,
93 app_state & app,
94 packet_consumer & pc);
95
96bool find_common_ancestor(manifest_id const & left,
97 manifest_id const & right,
98 manifest_id & anc,
99 app_state & app);
100
101
102// stuff for dealing with rename certs / rename maps
103
104typedef std::map<file_path,file_path> rename_set;
105
106struct rename_edge
107{
108 rename_edge() {}
109 rename_edge(rename_edge const & other);
110 manifest_id parent;
111 manifest_id child;
112 rename_set mapping;
113};
114
115void calculate_renames(manifest_id const & ancestor,
116 manifest_id const & child,
117 app_state & app,
118 rename_edge & edge);
119
120
121// we also define some common cert types, to help establish useful
122// conventions. you should use these unless you have a compelling
123// reason not to.
124
125bool guess_default_key(rsa_keypair_id & key,
126 app_state & app);
127
128void guess_branch(manifest_id const & id,
129 app_state & app,
130 cert_value & branchname);
131
132extern std::string const date_cert_name;
133extern std::string const author_cert_name;
134extern std::string const tag_cert_name;
135extern std::string const changelog_cert_name;
136extern std::string const comment_cert_name;
137extern std::string const disapproval_cert_name;
138extern std::string const testresult_cert_name;
139extern std::string const rename_cert_name;
140
141void cert_manifest_date_now(manifest_id const & m,
142 app_state & app,
143 packet_consumer & pc);
144
145void cert_manifest_date_time(manifest_id const & m,
146 time_t time,
147 app_state & app,
148 packet_consumer & pc);
149
150void cert_manifest_author(manifest_id const & m,
151 std::string const & author,
152 app_state & app,
153 packet_consumer & pc);
154
155void cert_manifest_author_default(manifest_id const & m,
156 app_state & app,
157 packet_consumer & pc);
158
159void cert_manifest_tag(manifest_id const & m,
160 std::string const & tagname,
161 app_state & app,
162 packet_consumer & pc);
163
164void cert_manifest_changelog(manifest_id const & m,
165 std::string const & changelog,
166 app_state & app,
167 packet_consumer & pc);
168
169void cert_file_comment(file_id const & m,
170 std::string const & comment,
171 app_state & app,
172 packet_consumer & pc);
173
174void cert_manifest_comment(manifest_id const & m,
175 std::string const & comment,
176 app_state & app,
177 packet_consumer & pc);
178
179void cert_file_approval(file_id const & f1,
180file_id const & f2,
181bool const approval,
182app_state & app,
183packet_consumer & pc);
184
185void cert_manifest_approval(manifest_id const & m1,
186 manifest_id const & m2,
187 bool const approval,
188 app_state & app,
189 packet_consumer & pc);
190
191void cert_manifest_testresult(manifest_id const & m,
192 std::string const & results,
193 app_state & app,
194 packet_consumer & pc);
195
196void cert_manifest_rename(manifest_id const & m,
197 rename_edge const & re,
198 app_state & app,
199 packet_consumer & pc);
200
201void cert_manifest_vcheck(manifest_id const & m,
202 app_state & app,
203 packet_consumer & pc);
204
205void check_manifest_vcheck(manifest_id const & m,
206 app_state & app);
207
208
209#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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