# # # patch "cmd_agent.cc" # from [de00d7a13f23dabb713bf7d26b8bad524ea262c5] # to [673afc5a55c3e260f4e5dca34ec4bbbf8e17e8b5] # # patch "keys.cc" # from [0f1223f9749dcc1bbd48168900b7eb8136523cef] # to [8841bda1e0f18e79de1b45e2c5aece68b22dc765] # # patch "ssh_agent.cc" # from [caa1fb5946aea8300fb08d821f6a2af0e9c0f1ea] # to [bb06aa3d32515a0780f5e09ff70088c09c31a1c6] # # patch "ssh_agent.hh" # from [208ee27931a03f399210f5b4184fe7ec06bc242d] # to [8448971240ed00e925ff958b2a238af31eab76f5] # # patch "testsuite.lua" # from [ace65535c8e4ff3106a8c3ba96fdb29086848dc8] # to [fdd5659e8fde2cb2682361db7dc66237958728c6] # ============================================================ --- cmd_agent.cc de00d7a13f23dabb713bf7d26b8bad524ea262c5 +++ cmd_agent.cc 673afc5a55c3e260f4e5dca34ec4bbbf8e17e8b5 @@ -39,7 +39,10 @@ agent_export(string const & name, app_st p.start_msg(); if (new_phrase().length()) { - Botan::PKCS8::encrypt_key(*priv, p, new_phrase(), "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"); + Botan::PKCS8::encrypt_key(*priv, + p, + new_phrase(), + "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"); } else { ============================================================ --- keys.cc 0f1223f9749dcc1bbd48168900b7eb8136523cef +++ keys.cc 8841bda1e0f18e79de1b45e2c5aece68b22dc765 @@ -120,8 +120,9 @@ get_passphrase(lua_hooks & lua, if (confirm_phrase) { ui.ensure_clean_line(); - read_password((F("confirm passphrase for key ID [%s]: ") % keyid()).str(), - pass2, constants::maxpasswd); + read_password((F("confirm passphrase for key ID [%s]: ") + % keyid()).str(), + pass2, constants::maxpasswd); cout << endl; if (strcmp(pass1, pass2) == 0) break; @@ -184,8 +185,11 @@ generate_key_pair(keypair & kp_out, Pipe p; p.start_msg(); if (phrase().length()) { - Botan::PKCS8::encrypt_key(priv, p, phrase(), - "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", Botan::RAW_BER); + Botan::PKCS8::encrypt_key(priv, + p, + phrase(), + "PBE-PKCS5v20(SHA-1,TripleDES/CBC)", + Botan::RAW_BER); } else { Botan::PKCS8::encode(priv, p); } ============================================================ --- ssh_agent.cc caa1fb5946aea8300fb08d821f6a2af0e9c0f1ea +++ ssh_agent.cc bb06aa3d32515a0780f5e09ff70088c09c31a1c6 @@ -164,9 +164,14 @@ void } void -ssh_agent::get_string_from_buf(string const & buf, u32 & loc, u32 & len, string & out) +ssh_agent::get_string_from_buf(string const & buf, + u32 & loc, + u32 & len, + string & out) { - L(FL("ssh_agent: get_string_from_buf: buf length: %u, loc: %u" ) % buf.length() % loc); + L(FL("ssh_agent: get_string_from_buf: buf length: %u, loc: %u" ) + % buf.length() + % loc); len = get_long_from_buf(buf, loc); L(FL("ssh_agent: get_string_from_buf: len: %u" ) % len); E(loc + len <= buf.length(), @@ -197,7 +202,9 @@ ssh_agent::put_long_into_buf(u32 l, stri ssh_agent::put_long_into_buf(u32 l, string & buf) { char lb[4]; - L(FL("ssh_agent: put_long_into_buf: long: %u, buf len: %i") % l % buf.length()); + L(FL("ssh_agent: put_long_into_buf: long: %u, buf len: %i") + % l + % buf.length()); put_long(l, lb); buf.append(lb, 4); L(FL("ssh_agent: put_long_into_buf: buf len now %i") % buf.length()); @@ -208,7 +215,9 @@ ssh_agent::put_bigint_into_buf(BigInt co { int bytes = bi.bytes() + 1; Botan::byte bi_buf[bytes]; - L(FL("ssh_agent: put_bigint_into_buf: bigint.bytes(): %u, bigint: %s") % bi.bytes() % bi); + L(FL("ssh_agent: put_bigint_into_buf: bigint.bytes(): %u, bigint: %s") + % bi.bytes() + % bi); bi_buf[0] = 0x00; BigInt::encode(bi_buf + 1, bi); int hasnohigh = (bi_buf[1] & 0x80) ? 0 : 1; @@ -222,7 +231,9 @@ ssh_agent::put_key_into_buf(RSA_PublicKe void ssh_agent::put_key_into_buf(RSA_PublicKey const & key, string & buf) { - L(FL("ssh_agent: put_key_into_buf: key e: %s, n: %s") % key.get_e() % key.get_n()); + L(FL("ssh_agent: put_key_into_buf: key e: %s, n: %s") + % key.get_e() + % key.get_n()); put_string_into_buf("ssh-rsa", buf); put_bigint_into_buf(key.get_e(), buf); put_bigint_into_buf(key.get_n(), buf); @@ -232,7 +243,9 @@ ssh_agent::put_string_into_buf(string co void ssh_agent::put_string_into_buf(string const & str, string & buf) { - L(FL("ssh_agent: put_string_into_buf: str len %i, buf len %i") % str.length() % buf.length()); + L(FL("ssh_agent: put_string_into_buf: str len %i, buf len %i") + % str.length() + % buf.length()); put_long_into_buf(str.length(), buf); buf.append(str.c_str(), str.length()); L(FL("ssh_agent: put_string_into_buf: buf len now %i") % buf.length()); @@ -298,7 +311,8 @@ ssh_agent::get_keys() //first byte is packet type u32 packet_loc = 0; - E(packet.at(0) == 12, F("ssh_agent: packet type (%u) != 12") % (u32)packet.at(0)); + E(packet.at(0) == 12, F("ssh_agent: packet type (%u) != 12") + % (u32)packet.at(0)); packet_loc += 1; u32 num_keys = get_long_from_buf(packet, packet_loc); @@ -323,15 +337,20 @@ ssh_agent::get_keys() L(FL("ssh_agent: RSA")); string e_str; get_string_from_buf(key, key_loc, slen, e_str); - BigInt e = BigInt::decode((unsigned char *)(e_str.c_str()), e_str.length(), BigInt::Binary); + BigInt e = BigInt::decode((unsigned char *)(e_str.c_str()), + e_str.length(), + BigInt::Binary); L(FL("ssh_agent: e: %s, len %u") % e % slen); string n_str; get_string_from_buf(key, key_loc, slen, n_str); - BigInt n = BigInt::decode((unsigned char *)(n_str.c_str()), n_str.length(), BigInt::Binary); + BigInt n = BigInt::decode((unsigned char *)(n_str.c_str()), + n_str.length(), + BigInt::Binary); L(FL("ssh_agent: n: %s, len %u") % n % slen); E(key.length() == key_loc, - F("ssh_agent: get_keys: not all or too many key bytes consumed, location (%u), length(%i)") + F("ssh_agent: get_keys: not all or too many key bytes consumed," + " location (%u), length(%i)") % key_loc % key.length()); @@ -363,7 +382,8 @@ ssh_agent::get_keys() // } else // E(false, F("key type '%s' not recognized by ssh-agent code") % type); - L(FL("ssh_agent: packet length %u, packet loc %u, key length %u, key loc, %u") + L(FL("ssh_agent: packet length %u, packet loc %u, key length %u," + " key loc, %u") % packet.length() % packet_loc % key.length() @@ -375,18 +395,25 @@ ssh_agent::get_keys() L(FL("ssh_agent: comment_len: %u, comment: %s") % comment_len % comment); } E(packet.length() == packet_loc, - F("ssh_agent: get_keys: not all or too many packet bytes consumed, location (%u), length(%i)") + F("ssh_agent: get_keys: not all or too many packet bytes consumed," + " location (%u), length(%i)") % packet_loc % packet.length()); return keys; } void -ssh_agent::sign_data(RSA_PublicKey const & key, string const & data, string & out) +ssh_agent::sign_data(RSA_PublicKey const & key, + string const & data, + string & out) { - E(connected(), F("ssh_agent: get_keys: attempted to sign data when not connected")); + E(connected(), + F("ssh_agent: get_keys: attempted to sign data when not connected")); - L(FL("ssh_agent: sign_data: key e: %s, n: %s, data len: %i") % key.get_e() % key.get_n() % data.length()); + L(FL("ssh_agent: sign_data: key e: %s, n: %s, data len: %i") + % key.get_e() + % key.get_n() + % data.length()); string data_out; string key_buf; string full_sig; @@ -411,12 +438,16 @@ ssh_agent::sign_data(RSA_PublicKey const fetch_packet(packet_in); u32 packet_in_loc = 0; - E(packet_in.at(0) == 14, F("ssh_agent: sign_data: packet_in type (%u) != 14") % (u32)packet_in.at(0)); + E(packet_in.at(0) == 14, + (F("ssh_agent: sign_data: packet_in type (%u) != 14") + % (u32)packet_in.at(0))); packet_in_loc += 1; u32 full_sig_len; get_string_from_buf(packet_in, packet_in_loc, full_sig_len, full_sig); - L(FL("ssh_agent: sign_data: signed data length: %u (%u)") % full_sig_len % full_sig.length()); + L(FL("ssh_agent: sign_data: signed data length: %u (%u)") + % full_sig_len + % full_sig.length()); string type; u32 full_sig_loc = 0, type_len, out_len; @@ -425,14 +456,16 @@ ssh_agent::sign_data(RSA_PublicKey const get_string_from_buf(full_sig, full_sig_loc, out_len, out); L(FL("ssh_agent: sign_data: output length %u") % out_len); E(full_sig.length() == full_sig_loc, - F("ssh_agent: sign_data: not all or too many signature bytes consumed, location (%u), length(%i)") - % full_sig_loc - % full_sig.length()); + (F("ssh_agent: sign_data: not all or too many signature bytes consumed," + " location (%u), length(%i)") + % full_sig_loc + % full_sig.length())); E(packet_in.length() == packet_in_loc, - F("ssh_agent: sign_data: not all or too many packet bytes consumed, location (%u), length(%i)") - % packet_in_loc - % packet_in.length()); + (F("ssh_agent: sign_data: not all or too many packet bytes consumed," + " location (%u), length(%i)") + % packet_in_loc + % packet_in.length())); } // Local Variables: ============================================================ --- ssh_agent.hh 208ee27931a03f399210f5b4184fe7ec06bc242d +++ ssh_agent.hh 8448971240ed00e925ff958b2a238af31eab76f5 @@ -15,7 +15,9 @@ public: ~ssh_agent(); bool connected(); std::vector const get_keys(); - void sign_data(Botan::RSA_PublicKey const & key, std::string const & data, std::string & out); + void sign_data(Botan::RSA_PublicKey const & key, + std::string const & data, + std::string & out); private: boost::shared_ptr stream; @@ -26,7 +28,10 @@ private: void read_num_bytes(u32 const len, std::string & out); u32 get_long(char const * buf); u32 get_long_from_buf(std::string const & buf, u32 & loc); - void get_string_from_buf(std::string const & buf, u32 & loc, u32 & len, std::string & out); + void get_string_from_buf(std::string const & buf, + u32 & loc, + u32 & len, + std::string & out); //helper functions for packing data to send to ssh-agent void put_long(u32 l, char * buf); ============================================================ --- testsuite.lua ace65535c8e4ff3106a8c3ba96fdb29086848dc8 +++ testsuite.lua fdd5659e8fde2cb2682361db7dc66237958728c6 @@ -170,6 +170,10 @@ end return res == 0 end +function ssh_agent_export() + check(mt("ssh_agent_export"), 0, false, false) +end + function addfile(filename, contents, mt) if contents ~= nil then writefile(filename, contents) end if mt == nil then mt = mtn end