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