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

Archive Download this file

Branches

Tags

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