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 base64<rsa_pub_key> & pub,
22 base64< arc4<rsa_priv_key> > & priv,
23 // Used for unit tests only:
24 std::string const unit_test_passphrase = std::string());
25
26void change_key_passphrase(lua_hooks & lua, // to hook for phrase
27 rsa_keypair_id const & id, // to prompting user for phrase
28 base64< arc4<rsa_priv_key> > & encoded_key);
29
30void make_signature(app_state & app, // to hook for phrase
31 rsa_keypair_id const & id, // to prompting user for phrase
32 base64< arc4<rsa_priv_key> > const & priv,
33 std::string const & tosign,
34 base64<rsa_sha1_signature> & signature);
35
36bool check_signature(app_state & app,
37 rsa_keypair_id const & id,
38 base64<rsa_pub_key> const & pub,
39 std::string const & alleged_text,
40 base64<rsa_sha1_signature> const & signature);
41
42void require_password(rsa_keypair_id const & id,
43 app_state & app);
44
45void encrypt_rsa(lua_hooks & lua,
46 rsa_keypair_id const & id,
47 base64<rsa_pub_key> & pub,
48 std::string const & plaintext,
49 rsa_oaep_sha_data & ciphertext);
50
51void decrypt_rsa(lua_hooks & lua,
52 rsa_keypair_id const & id,
53 base64< arc4<rsa_priv_key> > const & priv,
54 rsa_oaep_sha_data const & ciphertext,
55 std::string & plaintext);
56
57// netsync stuff
58
59void read_pubkey(std::string const & in,
60 rsa_keypair_id & id,
61 base64<rsa_pub_key> & pub);
62
63void write_pubkey(rsa_keypair_id const & id,
64 base64<rsa_pub_key> const & pub,
65 std::string & out);
66
67void key_hash_code(rsa_keypair_id const & id,
68 base64<rsa_pub_key> const & pub,
69 hexenc<id> & out);
70
71void key_hash_code(rsa_keypair_id const & id,
72 base64< arc4<rsa_priv_key> > const & priv,
73 hexenc<id> & out);
74
75bool keys_match(rsa_keypair_id const & id1,
76 base64<rsa_pub_key> const & key1,
77 rsa_keypair_id const & id2,
78 base64<rsa_pub_key> const & key2);
79
80bool keys_match(rsa_keypair_id const & id1,
81 base64< arc4<rsa_priv_key> > const & key1,
82 rsa_keypair_id const & id2,
83 base64< arc4<rsa_priv_key> > const & key2);
84
85
86#endif // __KEYS_HH__

Archive Download this file

Branches

Tags

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