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

Archive Download this file

Branches

Tags

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