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

Archive Download this file

Branches

Tags

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