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#include <boost/date_time/posix_time/posix_time.hpp>
16
17// certs associate an opaque name/value pair with a particular identifier in
18// the system (eg. a manifest or file id) and are accompanied by an RSA
19// public-key signature attesting to the association. users can write as
20// much extra meta-data as they like about files or manifests, using certs,
21// without needing anyone's special permission.
22
23struct app_state;
24struct packet_consumer;
25
26struct cert
27{
28 cert();
29 cert(hexenc<id> const & ident,
30 cert_name const & name,
31 base64<cert_value> const & value,
32 rsa_keypair_id const & key);
33 cert(hexenc<id> const & ident,
34 cert_name const & name,
35 base64<cert_value> const & value,
36 rsa_keypair_id const & key,
37 base64<rsa_sha1_signature> const & sig);
38 hexenc<id> ident;
39 cert_name name;
40 base64<cert_value> value;
41 rsa_keypair_id key;
42 base64<rsa_sha1_signature> sig;
43 bool operator<(cert const & other) const;
44 bool operator==(cert const & other) const;
45};
46
47
48// these 3 are for netio support
49void read_cert(std::string const & in, cert & t);
50void write_cert(cert const & t, std::string & out);
51void cert_hash_code(cert const & t, hexenc<id> & out);
52
53typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
54
55void cert_signable_text(cert const & t,std::string & out);
56cert_status check_cert(app_state & app, cert const & t);
57bool priv_key_exists(app_state & app, rsa_keypair_id const & id);
58void load_priv_key(app_state & app,
59 rsa_keypair_id const & id,
60 base64< arc4<rsa_priv_key> > & priv);
61void calculate_cert(app_state & app, cert & t);
62void make_simple_cert(hexenc<id> const & id,
63 cert_name const & nm,
64 cert_value const & cv,
65 app_state & app,
66 cert & c);
67void put_simple_revision_cert(revision_id const & id,
68 cert_name const & nm,
69 cert_value const & val,
70 app_state & app,
71 packet_consumer & pc);
72
73void erase_bogus_certs(std::vector< revision<cert> > & certs,
74 app_state & app);
75
76void erase_bogus_certs(std::vector< manifest<cert> > & certs,
77 app_state & app);
78
79// special certs -- system won't work without them
80
81extern std::string const branch_cert_name;
82
83void
84cert_revision_in_branch(revision_id const & ctx,
85 cert_value const & branchname,
86 app_state & app,
87 packet_consumer & pc);
88
89void
90get_branch_heads(cert_value const & branchname,
91 app_state & app,
92 std::set<revision_id> & heads);
93
94bool
95find_common_ancestor(revision_id const & left,
96 revision_id const & right,
97 revision_id & anc,
98 app_state & app);
99
100
101// we also define some common cert types, to help establish useful
102// conventions. you should use these unless you have a compelling
103// reason not to.
104
105bool
106guess_default_key(rsa_keypair_id & key,
107 app_state & app);
108
109void
110guess_branch(revision_id const & id,
111 app_state & app,
112 cert_value & branchname);
113
114extern std::string const date_cert_name;
115extern std::string const author_cert_name;
116extern std::string const tag_cert_name;
117extern std::string const changelog_cert_name;
118extern std::string const comment_cert_name;
119extern std::string const testresult_cert_name;
120
121void
122cert_revision_date_now(revision_id const & m,
123 app_state & app,
124 packet_consumer & pc);
125
126void
127cert_revision_date_time(revision_id const & m,
128 boost::posix_time::ptime t,
129 app_state & app,
130 packet_consumer & pc);
131
132void
133cert_revision_date_time(revision_id const & m,
134 time_t time,
135 app_state & app,
136 packet_consumer & pc);
137
138void
139cert_revision_author(revision_id const & m,
140 std::string const & author,
141 app_state & app,
142 packet_consumer & pc);
143
144void
145cert_revision_author_default(revision_id const & m,
146 app_state & app,
147 packet_consumer & pc);
148
149void
150cert_revision_tag(revision_id const & m,
151 std::string const & tagname,
152 app_state & app,
153 packet_consumer & pc);
154
155void
156cert_revision_changelog(revision_id const & m,
157 std::string const & changelog,
158 app_state & app,
159 packet_consumer & pc);
160
161void
162cert_revision_comment(revision_id const & m,
163 std::string const & comment,
164 app_state & app,
165 packet_consumer & pc);
166
167void
168cert_revision_testresult(revision_id const & m,
169 std::string const & results,
170 app_state & app,
171 packet_consumer & pc);
172
173
174#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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