monotone

monotone Mtn Source Tree

Root/key_store.hh

1#ifndef __KEY_STORE_H__
2#define __KEY_STORE_H__
3
4#include <boost/scoped_ptr.hpp>
5#include "botan/rng.h"
6#include "vector.hh"
7#include "vocab.hh"
8#include "paths.hh"
9
10class app_state;
11struct globish;
12class database;
13
14struct keypair
15{
16 rsa_pub_key pub;
17 rsa_priv_key priv;
18 keypair()
19 {}
20 keypair(rsa_pub_key const & a,
21 rsa_priv_key const & b)
22 : pub(a), priv(b)
23 {}
24};
25
26struct key_store_state;
27
28class key_store
29{
30private:
31 boost::scoped_ptr<key_store_state> s;
32
33public:
34 rsa_keypair_id signing_key;
35
36 explicit key_store(app_state & a);
37 ~key_store();
38
39 Botan::RandomNumberGenerator & get_rng();
40 system_path const & get_key_dir();
41
42 // Basic key I/O
43
44 void get_key_ids(std::vector<rsa_keypair_id> & priv);
45 void get_key_ids(globish const & pattern,
46 std::vector<rsa_keypair_id> & priv);
47
48 bool key_pair_exists(rsa_keypair_id const & ident);
49
50 void get_key_pair(rsa_keypair_id const & ident,
51 keypair & kp);
52 bool maybe_get_key_pair(rsa_keypair_id const & ident,
53 keypair & kp);
54 bool maybe_get_key_pair(id const & hash,
55 rsa_keypair_id & ident,
56 keypair & kp);
57
58 bool put_key_pair(rsa_keypair_id const & ident,
59 keypair const & kp);
60
61 void delete_key(rsa_keypair_id const & ident);
62
63 // Crypto operations
64
65 void cache_decrypted_key(rsa_keypair_id const & id);
66
67 void create_key_pair(database & db, rsa_keypair_id const & id,
68 utf8 const * maybe_passphrase = NULL,
69 id * maybe_pubhash = NULL,
70 id * maybe_privhash = NULL);
71
72 void change_key_passphrase(rsa_keypair_id const & id);
73
74 void decrypt_rsa(rsa_keypair_id const & id,
75 rsa_oaep_sha_data const & ciphertext,
76 std::string & plaintext);
77
78 void make_signature(database & db, rsa_keypair_id const & id,
79 std::string const & tosign,
80 rsa_sha1_signature & signature);
81
82 // Interoperation with ssh-agent
83
84 void add_key_to_agent(rsa_keypair_id const & id);
85 void export_key_for_agent(rsa_keypair_id const & id,
86 std::ostream & os);
87
88 // Migration from old databases
89
90 void migrate_old_key_pair(rsa_keypair_id const & id,
91 old_arc4_rsa_priv_key const & old_priv,
92 rsa_pub_key const & pub);
93};
94
95// Local Variables:
96// mode: C++
97// fill-column: 76
98// c-file-style: "gnu"
99// indent-tabs-mode: nil
100// End:
101// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
102
103#endif

Archive Download this file

Branches

Tags

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