# # # patch "key_store.cc" # from [55878f97b03349c66d95398799780f43ae63165b] # to [1c879bc94af0a672b7077245d755f660890ec043] # ============================================================ --- key_store.cc 55878f97b03349c66d95398799780f43ae63165b +++ key_store.cc 1c879bc94af0a672b7077245d755f660890ec043 @@ -438,6 +438,32 @@ key_store::cache_decrypted_key(const rsa key_store::cache_decrypted_key(const rsa_keypair_id & id) { signing_key = id; + + //grab the monotone public key as an RSA_PublicKey + keypair key; + get_key_pair(id, key); + SecureVector pub_block; + pub_block.set(reinterpret_cast((key.pub)().data()), + (key.pub)().size()); + L(FL("make_signature: building %d-byte pub key") % pub_block.size()); + shared_ptr x509_key = + shared_ptr(Botan::X509::load_key(pub_block)); + shared_ptr pub_key = shared_dynamic_cast(x509_key); + + if (!pub_key) + throw informative_failure("Failed to get monotone RSA public key"); + + ssh_agent & agent = s->get_agent(); + vector ssh_keys = agent.get_keys(); + for (vector::const_iterator + si = ssh_keys.begin(); si != ssh_keys.end(); ++si) { + if ((*pub_key).get_e() == (*si).get_e() + && (*pub_key).get_n() == (*si).get_n()) { + L(FL("ssh-agent has key loaded, skipping internal cache")); + return; + } + } + if (s->lua.hook_persist_phrase_ok()) s->decrypt_private_key(id); }