monotone

monotone Mtn Source Tree

Root/keys.hh

1#ifndef __KEYS_HH__
2#define __KEYS_HH__
3
4// copyright (C) 2002, 2003, 2004 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9#include "vocab.hh"
10#include <string>
11
12// keys.{hh,cc} does all the "delicate" crypto (meaning: that which needs
13// to read passphrases and manipulate raw, decrypted private keys). it
14// could in theory be in transforms.cc too, but that file's already kinda
15// big and this stuff "feels" different, imho.
16
17struct lua_hooks;
18
19void generate_key_pair(lua_hooks & lua, // to hook for phrase
20 rsa_keypair_id const & id, // to prompting user for phrase
21 keypair & kp,
22 // Used for unit tests only:
23 std::string const unit_test_passphrase = std::string());
24
25void change_key_passphrase(lua_hooks & lua, // to hook for phrase
26 rsa_keypair_id const & id, // to prompting user for phrase
27 base64< rsa_priv_key > & encoded_key);
28
29void migrate_private_key(app_state & app,
30 rsa_keypair_id const & id,
31 base64< arc4<rsa_priv_key> > const & old_priv,
32 keypair & kp);
33
34void make_signature(app_state & app, // to hook for phrase
35 rsa_keypair_id const & id, // to prompting user for phrase
36 base64< rsa_priv_key > const & priv,
37 std::string const & tosign,
38 base64<rsa_sha1_signature> & signature);
39
40bool check_signature(app_state & app,
41 rsa_keypair_id const & id,
42 base64<rsa_pub_key> const & pub,
43 std::string const & alleged_text,
44 base64<rsa_sha1_signature> const & signature);
45
46void require_password(rsa_keypair_id const & id,
47 app_state & app);
48
49void encrypt_rsa(lua_hooks & lua,
50 rsa_keypair_id const & id,
51 base64<rsa_pub_key> & pub,
52 std::string const & plaintext,
53 rsa_oaep_sha_data & ciphertext);
54
55void decrypt_rsa(lua_hooks & lua,
56 rsa_keypair_id const & id,
57 base64< rsa_priv_key > const & priv,
58 rsa_oaep_sha_data const & ciphertext,
59 std::string & plaintext);
60
61// netsync stuff
62
63void read_pubkey(std::string const & in,
64 rsa_keypair_id & id,
65 base64<rsa_pub_key> & pub);
66
67void write_pubkey(rsa_keypair_id const & id,
68 base64<rsa_pub_key> const & pub,
69 std::string & out);
70
71void key_hash_code(rsa_keypair_id const & id,
72 base64<rsa_pub_key> const & pub,
73 hexenc<id> & out);
74
75void key_hash_code(rsa_keypair_id const & id,
76 base64< rsa_priv_key > const & priv,
77 hexenc<id> & out);
78
79bool keys_match(rsa_keypair_id const & id1,
80 base64<rsa_pub_key> const & key1,
81 rsa_keypair_id const & id2,
82 base64<rsa_pub_key> const & key2);
83/* Doesn't work
84bool keys_match(rsa_keypair_id const & id1,
85 base64< rsa_priv_key > const & key1,
86 rsa_keypair_id const & id2,
87 base64< rsa_priv_key > const & key2);
88*/
89
90#endif // __KEYS_HH__

Archive Download this file

Branches

Tags

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