# # # patch "cmd_key_cert.cc" # from [94ec51ced8680fd359478be5be38ac1813636881] # to [674911e6cc5aa00ef03a3552240deb787c6aaab3] # # patch "key_store.cc" # from [b061169c0ab5dfb2e3eb88f525883d8ea70009b4] # to [88eb6652bb10578e5ef3f6ed28166c85f0bfd2b7] # # patch "key_store.hh" # from [6711a8d0a768cf22b124daf00511b8d656f2cb71] # to [533b4f6d4954a6c1575bc1caacdf6879a4273267] # # patch "keys.cc" # from [91c80e8e4bbc58a60638b01474724ac3b9ea07f2] # to [19386cf9af1196c244e09555f81b7e06b3616b96] # # patch "keys.hh" # from [3c50c4270dfa507b114173189075bf9af2423f59] # to [784b404e0e233bcf92b96aac0ebdde82b60fc3b3] # ============================================================ --- cmd_key_cert.cc 94ec51ced8680fd359478be5be38ac1813636881 +++ cmd_key_cert.cc 674911e6cc5aa00ef03a3552240deb787c6aaab3 @@ -100,12 +100,7 @@ CMD(passphrase, "passphrase", "", CMD_RE rsa_keypair_id ident; internalize_rsa_keypair_id(idx(args, 0), ident); - keypair key; - load_key_pair(app.keys, ident, key); - - change_key_passphrase(app.keys, ident, key.priv); - app.keys.delete_key(ident); - app.keys.put_key_pair(ident, key); + app.keys.change_key_passphrase(ident); P(F("passphrase changed")); } ============================================================ --- key_store.cc b061169c0ab5dfb2e3eb88f525883d8ea70009b4 +++ key_store.cc 88eb6652bb10578e5ef3f6ed28166c85f0bfd2b7 @@ -402,6 +402,31 @@ void } void +key_store::change_key_passphrase(rsa_keypair_id const & id) +{ + keypair kp; + load_key_pair(*this, id, kp); + + shared_ptr priv = get_private_key(*this, id, kp.priv, true); + + utf8 new_phrase; + get_passphrase(new_phrase, id, true, false); + + Pipe p; + p.start_msg(); + Botan::PKCS8::encrypt_key(*priv, p, new_phrase(), + "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", + Botan::RAW_BER); + rsa_priv_key decoded_key = rsa_priv_key(p.read_all_as_string()); + + encode_base64(decoded_key, kp.priv); + delete_key(id); + put_key_pair(id, kp); +} + + + +void key_store::make_signature(database & db, rsa_keypair_id const & id, string const & tosign, ============================================================ --- key_store.hh 6711a8d0a768cf22b124daf00511b8d656f2cb71 +++ key_store.hh 533b4f6d4954a6c1575bc1caacdf6879a4273267 @@ -58,6 +58,8 @@ public: hexenc * maybe_pubhash = NULL, hexenc * maybe_privhash = NULL); + void change_key_passphrase(rsa_keypair_id const & id); + void make_signature(database & db, rsa_keypair_id const & id, std::string const & tosign, base64 & signature); ============================================================ --- keys.cc 91c80e8e4bbc58a60638b01474724ac3b9ea07f2 +++ keys.cc 19386cf9af1196c244e09555f81b7e06b3616b96 @@ -318,26 +318,6 @@ get_private_key(key_store & keys, I(false); } -void -change_key_passphrase(key_store & keys, - rsa_keypair_id const & id, - base64< rsa_priv_key > & encoded_key) -{ - shared_ptr priv - = get_private_key(keys, id, encoded_key, true); - - utf8 new_phrase; - get_passphrase(new_phrase, id, true, false); - - Pipe p; - p.start_msg(); - Botan::PKCS8::encrypt_key(*priv, p, new_phrase(), - "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", Botan::RAW_BER); - rsa_priv_key decoded_key = rsa_priv_key(p.read_all_as_string()); - - encode_base64(decoded_key, encoded_key); -} - void encrypt_rsa(key_store & keys, rsa_keypair_id const & id, base64 & pub_encoded, ============================================================ --- keys.hh 3c50c4270dfa507b114173189075bf9af2423f59 +++ keys.hh 784b404e0e233bcf92b96aac0ebdde82b60fc3b3 @@ -44,16 +44,6 @@ void load_key_pair(key_store & keys, rsa_keypair_id const & id, keypair & kp); -void change_key_passphrase(key_store & keys, // to hook for phrase - rsa_keypair_id const & id, // to prompting user for phrase - base64< rsa_priv_key > & encoded_key); - -bool check_signature(key_store & keys, - rsa_keypair_id const & id, - base64 const & pub, - std::string const & alleged_text, - base64 const & signature); - void encrypt_rsa(key_store & keys, rsa_keypair_id const & id, base64 & pub,