monotone

monotone Mtn Source Tree

Root/src/cert.hh

1// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#ifndef __CERT_HH__
11#define __CERT_HH__
12
13#include "vocab.hh"
14
15class database;
16
17// Certs associate an opaque name/value pair with a revision ID, and
18// are accompanied by an RSA public-key signature attesting to the
19// association. Users can write as much extra meta-data as they like
20// about revisions, using certs, without needing anyone's special
21// permission.
22
23struct cert : public origin_aware
24{
25 cert() {}
26
27 cert(revision_id const & ident,
28 cert_name const & name,
29 cert_value const & value,
30 key_id const & key)
31 : ident(ident), name(name), value(value), key(key)
32 {}
33
34 cert(revision_id const & ident,
35 cert_name const & name,
36 cert_value const & value,
37 key_id const & key,
38 rsa_sha1_signature const & sig)
39 : ident(ident), name(name), value(value), key(key), sig(sig)
40 {}
41
42 // These understand the netsync serialization.
43 static bool read_cert(database & db, std::string const & s, cert & c,
44 key_name & keyname);
45 static bool read_cert_v6(database & db, std::string const & s, cert & c,
46 key_name & keyname);
47 cert(database & db, std::string const & s, origin::type m);
48
49 revision_id ident;
50 cert_name name;
51 cert_value value;
52 key_id key;
53 rsa_sha1_signature sig;
54
55 bool operator<(cert const & other) const;
56 bool operator==(cert const & other) const;
57
58 void hash_code(key_name const & keyname, id & out) const;
59 void signable_text(std::string & out) const;
60 void marshal_for_netio(key_name const & keyname, std::string & out) const;
61 void marshal_for_netio_v6(key_name const & keyname, std::string & out) const;
62};
63
64#endif // __CERT_HH__
65
66// Local Variables:
67// mode: C++
68// fill-column: 76
69// c-file-style: "gnu"
70// indent-tabs-mode: nil
71// End:
72// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

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