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
52typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
53
54void cert_signable_text(cert const & t,std::string & out);
55cert_status check_cert(app_state & app, cert const & t);
56bool priv_key_exists(app_state & app, rsa_keypair_id const & id);
57void load_priv_key(app_state & app,
58 rsa_keypair_id const & id,
59 base64< arc4<rsa_priv_key> > & priv);
60void calculate_cert(app_state & app, cert & t);
61void make_simple_cert(hexenc<id> const & id,
62 cert_name const & nm,
63 cert_value const & cv,
64 app_state & app,
65 cert & c);
66
67void erase_bogus_certs(std::vector< revision<cert> > & certs,
68 app_state & app);
69
70void erase_bogus_certs(std::vector< manifest<cert> > & certs,
71 app_state & app);
72
73// special certs -- system won't work without them
74
75extern std::string const branch_cert_name;
76
77void
78cert_revision_in_branch(revision_id const & ctx,
79 cert_value const & branchname,
80 app_state & app,
81 packet_consumer & pc);
82
83void
84get_branch_heads(cert_value const & branchname,
85 app_state & app,
86 std::set<revision_id> & heads);
87
88bool
89find_common_ancestor(revision_id const & left,
90 revision_id const & right,
91 revision_id & anc,
92 app_state & app);
93
94
95// we also define some common cert types, to help establish useful
96// conventions. you should use these unless you have a compelling
97// reason not to.
98
99bool
100guess_default_key(rsa_keypair_id & key,
101 app_state & app);
102
103void
104guess_branch(revision_id const & id,
105 app_state & app,
106 cert_value & branchname);
107
108extern std::string const date_cert_name;
109extern std::string const author_cert_name;
110extern std::string const tag_cert_name;
111extern std::string const changelog_cert_name;
112extern std::string const comment_cert_name;
113extern std::string const testresult_cert_name;
114
115void
116cert_revision_date_now(revision_id const & m,
117 app_state & app,
118 packet_consumer & pc);
119
120void
121cert_revision_date_time(revision_id const & m,
122 time_t time,
123 app_state & app,
124 packet_consumer & pc);
125
126void
127cert_revision_author(revision_id const & m,
128 std::string const & author,
129 app_state & app,
130 packet_consumer & pc);
131
132void
133cert_revision_author_default(revision_id const & m,
134 app_state & app,
135 packet_consumer & pc);
136
137void
138cert_revision_tag(revision_id const & m,
139 std::string const & tagname,
140 app_state & app,
141 packet_consumer & pc);
142
143void
144cert_revision_changelog(revision_id const & m,
145 std::string const & changelog,
146 app_state & app,
147 packet_consumer & pc);
148
149void
150cert_revision_comment(revision_id const & m,
151 std::string const & comment,
152 app_state & app,
153 packet_consumer & pc);
154
155void
156cert_revision_testresult(revision_id const & m,
157 std::string const & results,
158 app_state & app,
159 packet_consumer & pc);
160
161
162#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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