# # # patch "keys.cc" # from [c9d2de3828c0145389e16a5cf425accf62aea7f3] # to [f49293c5c9f37fb3f009a5add813e2ec83692676] # ============================================================ --- keys.cc c9d2de3828c0145389e16a5cf425accf62aea7f3 +++ keys.cc f49293c5c9f37fb3f009a5add813e2ec83692676 @@ -371,10 +371,8 @@ make_signature(app_state & app, || app.opts.ssh_sign == "only", F("--ssh-sign must be set to 'yes', 'no', 'only', or 'check'")); - /* comment out to get unit tests to work keypair key; app.keys.get_key_pair(id, key); - */ string sig_string; //sign with ssh-agent (if connected) @@ -385,8 +383,6 @@ make_signature(app_state & app, || app.opts.ssh_sign == "check" || app.opts.ssh_sign == "only") { - keypair key; - app.keys.get_key_pair(id, key); vector ssh_keys = app.agent.get_keys(); if (ssh_keys.size() <= 0) L(FL("make_signature: no rsa keys received from ssh-agent")); @@ -487,10 +483,8 @@ make_signature(app_state & app, L(FL("make_signature: produced %d-byte signature") % sig_string.size()); encode_base64(rsa_sha1_signature(sig_string), signature); - /* comment out to get unit tests to work E(check_signature(app, id, key.pub, tosign, signature), F("make_signature: signature is not valid")); - */ } bool @@ -717,17 +711,20 @@ UNIT_TEST(key, signature_round_trip) BOOST_CHECKPOINT("generating key pairs"); keypair kp; utf8 passphrase("address@hidden"); - generate_key_pair(kp, passphrase); + rsa_keypair_id key("address@hidden"); + try { + L(FL("trying to get key")); + app.keys.get_key_pair(key, kp); + } catch (std::exception e) { + generate_key_pair(kp, passphrase); + L(FL("key not in store, putting")); + app.keys.put_key_pair(key, kp); + } BOOST_CHECKPOINT("signing plaintext"); - rsa_keypair_id key("address@hidden"); string plaintext("test string to sign"); base64 sig; - //force ssh_sign = "no" to stop monotone from trying to find the key in the key store - string ssh_sign_orig = app.opts.ssh_sign; - app.opts.ssh_sign = "no"; make_signature(app, key, kp.priv, plaintext, sig); - app.opts.ssh_sign = ssh_sign_orig; BOOST_CHECKPOINT("checking signature"); BOOST_CHECK(check_signature(app, key, kp.pub, plaintext, sig));