monotone

monotone Mtn Source Tree

Root/keys.hh

1#ifndef __KEYS_HH__
2#define __KEYS_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 "vocab.hh"
14#include "botan/rsa.h"
15#include <boost/shared_ptr.hpp>
16
17using Botan::RSA_PrivateKey;
18using boost::shared_ptr;
19
20class lua_hooks;
21class app_state;
22
23// keys.{hh,cc} does all the "delicate" crypto (meaning: that which needs
24// to read passphrases and manipulate raw, decrypted private keys). it
25// could in theory be in transforms.cc too, but that file's already kinda
26// big and this stuff "feels" different, imho.
27
28class lua_hooks;
29
30void generate_key_pair(lua_hooks & lua, // to hook for phrase
31 rsa_keypair_id const & id, // to prompting user for phrase
32 keypair & kp_out);
33
34void generate_key_pair(keypair & kp_out,
35 utf8 const phrase);
36
37void change_key_passphrase(lua_hooks & lua, // to hook for phrase
38 rsa_keypair_id const & id, // to prompting user for phrase
39 base64< rsa_priv_key > & encoded_key);
40
41void migrate_private_key(app_state & app,
42 rsa_keypair_id const & id,
43 base64< arc4<rsa_priv_key> > const & old_priv,
44 keypair & kp);
45
46void make_signature(app_state & app, // to hook for phrase
47 rsa_keypair_id const & id, // to prompting user for phrase
48 base64< rsa_priv_key > const & priv,
49 std::string const & tosign,
50 base64<rsa_sha1_signature> & signature);
51
52bool check_signature(app_state & app,
53 rsa_keypair_id const & id,
54 base64<rsa_pub_key> const & pub,
55 std::string const & alleged_text,
56 base64<rsa_sha1_signature> const & signature);
57
58void require_password(rsa_keypair_id const & id,
59 app_state & app);
60
61void encrypt_rsa(lua_hooks & lua,
62 rsa_keypair_id const & id,
63 base64<rsa_pub_key> & pub,
64 std::string const & plaintext,
65 rsa_oaep_sha_data & ciphertext);
66
67void decrypt_rsa(lua_hooks & lua,
68 rsa_keypair_id const & id,
69 base64< rsa_priv_key > const & priv,
70 rsa_oaep_sha_data const & ciphertext,
71 std::string & plaintext);
72
73void
74get_passphrase(lua_hooks & lua,
75 rsa_keypair_id const & keyid,
76 utf8 & phrase,
77 bool confirm_phrase = false,
78 bool force_from_user = false,
79 bool generating_key = false);
80
81shared_ptr<RSA_PrivateKey>
82get_private_key(lua_hooks & lua,
83 rsa_keypair_id const & id,
84 base64< rsa_priv_key > const & priv,
85 bool force_from_user = false);
86
87// netsync stuff
88
89void read_pubkey(std::string const & in,
90 rsa_keypair_id & id,
91 base64<rsa_pub_key> & pub);
92
93void write_pubkey(rsa_keypair_id const & id,
94 base64<rsa_pub_key> const & pub,
95 std::string & out);
96
97void key_hash_code(rsa_keypair_id const & ident,
98 base64<rsa_pub_key> const & pub,
99 hexenc<id> & out);
100
101void key_hash_code(rsa_keypair_id const & ident,
102 base64< rsa_priv_key > const & priv,
103 hexenc<id> & out);
104
105bool keys_match(rsa_keypair_id const & id1,
106 base64<rsa_pub_key> const & key1,
107 rsa_keypair_id const & id2,
108 base64<rsa_pub_key> const & key2);
109/* Doesn't work
110bool keys_match(rsa_keypair_id const & id1,
111 base64< rsa_priv_key > const & key1,
112 rsa_keypair_id const & id2,
113 base64< rsa_priv_key > const & key2);
114*/
115
116// Local Variables:
117// mode: C++
118// fill-column: 76
119// c-file-style: "gnu"
120// indent-tabs-mode: nil
121// End:
122// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
123
124#endif // __KEYS_HH__

Archive Download this file

Branches

Tags

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