monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 083dfa48871b21905f81ab22822


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 083dfa48871b21905f81ab22822709e0db97635b
Date: Wed, 20 Mar 2013 14:52:13 +0100 (CET)

revision:            083dfa48871b21905f81ab22822709e0db97635b
date:                2013-03-20T13:50:39
author:              address@hidden
branch:              net.venge.monotone
changelog:
explicit merge of '5934509c86e975ce771c66a1511671620eceb6d0'
              and '7282e7ba458b5e92f9c3850486c7b1c0df13c951'



manifest:
format_version "1"

new_manifest [70b832d064e14930e527fc1bd154e82808c78cd9]

old_revision [5934509c86e975ce771c66a1511671620eceb6d0]

patch "src/cmd_conflicts.cc"
 from [28995825acadb97eaa4b5cda378c66e548e9ad16]
   to [0b6a73cd90560803944c26a4e633ef3b6af5aa64]

patch "src/cmd_merging.cc"
 from [0a6aa03896408c4acdb7a1a9cd1682cb98c6f02a]
   to [e6fee865163eebdc0e2ec8564e5ad30af07ff640]

patch "src/merge_conflict.cc"
 from [b47a70720f836809f06347360ee91ddf587b5721]
   to [6e6a25ae8b577b495ab851d208cee324144ac8e2]

patch "src/merge_content.cc"
 from [b3aeba9d9a98bf032c7771ae7426e9209085f070]
   to [6e5fe3365b60c66b5ef14e6775d6a7bd49ec3312]

patch "src/merge_content.hh"
 from [f9a3388e5d2bd6d873d352dabf896df32827e983]
   to [b6545d8397108a002d119659773b3dea1eff4951]

old_revision [7282e7ba458b5e92f9c3850486c7b1c0df13c951]

patch "src/database.cc"
 from [39ab2644b936e09a536b99ebd28b93f6e0d7c162]
   to [a2f65339e0beb0740c9338b149b47e70c9ae0bfd]

patch "src/key_store.cc"
 from [1ca13b7ee527bc2872d9fc325cf5ef327ca053c2]
   to [974edefb0c48a3cdb903cac5c03859563c1e6971]
============================================================
--- src/cmd_conflicts.cc	28995825acadb97eaa4b5cda378c66e548e9ad16
+++ src/cmd_conflicts.cc	0b6a73cd90560803944c26a4e633ef3b6af5aa64
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 - 2010, 2012 Stephen Leake <address@hidden>
+// Copyright (C) 2008 - 2010, 2012, 2013 Stephen Leake <address@hidden>
 //
 // This program is made available under the GNU GPL version 2.0 or
 // greater. See the accompanying file COPYING for details.
@@ -313,7 +313,8 @@ show_conflicts(database & db, conflicts_
                  count) % count);
 
             content_merge_database_adaptor adaptor
-              (db, conflicts.left_rid, conflicts.right_rid, conflicts.left_marking, conflicts.right_marking);
+              (db, conflicts.left_rid, conflicts.right_rid, conflicts.left_marking, conflicts.right_marking,
+               std::set<revision_id> (), std::set<revision_id> ()); // uncommon_ancestors only used in automate
 
             conflicts.result.report_missing_root_conflicts
               (*conflicts.left_roster, *conflicts.right_roster, adaptor, false, std::cout);
============================================================
--- src/cmd_merging.cc	0a6aa03896408c4acdb7a1a9cd1682cb98c6f02a
+++ src/cmd_merging.cc	e6fee865163eebdc0e2ec8564e5ad30af07ff640
@@ -1,5 +1,5 @@
 // Copyright (C) 2002 Graydon Hoare <address@hidden>
-//               2008, 2010, 2012 Stephen Leake <address@hidden>
+//               2008, 2010, 2012, 2013 Stephen Leake <address@hidden>
 //
 // This program is made available under the GNU GPL version 2.0 or
 // greater. See the accompanying file COPYING for details.
@@ -721,7 +721,8 @@ void perform_merge_into_dir(app_state & 
 
         temp_node_id_source nis;
         content_merge_database_adaptor
-          dba(db, left_rid, right_rid, left_marking_map, right_marking_map);
+          dba(db, left_rid, right_rid, left_marking_map, right_marking_map,
+              left_uncommon_ancestors, right_uncommon_ancestors);
 
         bool resolutions_given;
 
@@ -1045,8 +1046,8 @@ show_conflicts_core (database & db,
     }
   else
     {
-      content_merge_database_adaptor adaptor(db, l_id, r_id,
-                                             l_marking, r_marking);
+      content_merge_database_adaptor adaptor(db, l_id, r_id, l_marking, r_marking,
+                                             l_uncommon_ancestors, r_uncommon_ancestors);
 
       if (basic_io)
         {
@@ -1244,7 +1245,9 @@ CMD_AUTOMATE(file_merge, N_("LEFT_REVID 
   db.get_roster(right_rid, right_roster, right_marking);
 
   content_merge_database_adaptor adaptor(db, left_rid, right_rid,
-                                         left_marking, right_marking);
+                                         left_marking, right_marking,
+                                         set<revision_id> (), set<revision_id> ());
+  // uncommon_ancestors only needed for dropped_modified conflicts
 
   const_file_t left_n = downcast_to_file_t(left_roster.get_node(left_path));
   const_file_t right_n = downcast_to_file_t(right_roster.get_node(right_path));
============================================================
--- src/merge_conflict.cc	b47a70720f836809f06347360ee91ddf587b5721
+++ src/merge_conflict.cc	6e6a25ae8b577b495ab851d208cee324144ac8e2
@@ -1066,14 +1066,15 @@ push_dropped_details(content_merge_datab
                      symbol                           rev_sym,
                      symbol                           name_sym,
                      symbol                           file_id_sym,
-                     revision_id                      rev_id,
+                     std::set<revision_id> const &    uncommon_ancestors,
+                     revision_id const &              lca,
                      node_id                          nid,
                      basic_io::stanza &               st)
 {
   revision_id dropped_rev_id;
   file_path   dropped_name;
   file_id     dropped_file_id;
-  db_adaptor.get_dropped_details(rev_id, nid, dropped_rev_id, dropped_name, dropped_file_id);
+  db_adaptor.get_dropped_details(uncommon_ancestors, lca, nid, dropped_rev_id, dropped_name, dropped_file_id);
 
   st.push_binary_pair(rev_sym, dropped_rev_id.inner());
   st.push_str_pair(name_sym, dropped_name.as_external());
@@ -1141,7 +1142,7 @@ roster_merge_result::report_dropped_modi
                 {
                    st.push_str_pair(syms::left_type, "orphaned file");
                    push_dropped_details(db_adaptor, syms::left_rev, syms::left_name, syms::left_file_id,
-                                        db_adaptor.left_rid, nid, st);
+                                        db_adaptor.left_uncommon_ancestors, db_adaptor.lca, nid, st);
                 }
               else
                 {
@@ -1149,7 +1150,7 @@ roster_merge_result::report_dropped_modi
                     {
                       st.push_str_pair(syms::left_type, "dropped file");
                       push_dropped_details(db_adaptor, syms::left_rev, syms::left_name, syms::left_file_id,
-                                           db_adaptor.left_rid, nid, st);
+                                           db_adaptor.left_uncommon_ancestors, db_adaptor.lca, nid, st);
                     }
                   else
                     {
@@ -1176,7 +1177,7 @@ roster_merge_result::report_dropped_modi
                 {
                   st.push_str_pair(syms::right_type, "orphaned file");
                   push_dropped_details(db_adaptor, syms::right_rev, syms::right_name, syms::right_file_id,
-                                       db_adaptor.right_rid, nid, st);
+                                       db_adaptor.right_uncommon_ancestors, db_adaptor.lca, nid, st);
                 }
               else
                 {
@@ -1184,7 +1185,7 @@ roster_merge_result::report_dropped_modi
                     {
                       st.push_str_pair(syms::right_type, "dropped file");
                       push_dropped_details(db_adaptor, syms::right_rev, syms::right_name, syms::right_file_id,
-                                           db_adaptor.right_rid, nid, st);
+                                           db_adaptor.right_uncommon_ancestors, db_adaptor.lca, nid, st);
                     }
                   else
                     {
@@ -2664,8 +2665,13 @@ roster_merge_result::write_conflict_file
 {
   std::ostringstream output;
 
+  std::set<revision_id> left_uncommon_ancestors;
+  std::set<revision_id> right_uncommon_ancestors;
+  db.get_uncommon_ancestors(left_rid, right_rid, left_uncommon_ancestors, right_uncommon_ancestors);
+
   content_merge_database_adaptor adaptor(db, left_rid, right_rid,
-                                         left_marking, right_marking);
+                                         left_marking, right_marking,
+                                         left_uncommon_ancestors, right_uncommon_ancestors);
 
   adaptor.cache_roster (left_rid, left_roster);
   adaptor.cache_roster (right_rid, right_roster);
@@ -3092,7 +3098,8 @@ roster_merge_result::resolve_dropped_mod
                 {
                   // attr mtn::resolve_conflict drop does not set rid; find it now
                   adaptor.get_dropped_details
-                    (adaptor.left_rid, conflict.left_nid, conflict.left_rid, left_name, left_fid);
+                    (adaptor.left_uncommon_ancestors, adaptor.lca,
+                     conflict.left_nid, conflict.left_rid, left_name, left_fid);
                 }
               else
                 {
@@ -3114,7 +3121,8 @@ roster_merge_result::resolve_dropped_mod
               if (null_id(conflict.left_rid))
                 {
                   adaptor.get_dropped_details
-                    (adaptor.right_rid, conflict.right_nid, conflict.right_rid, right_name, right_fid);
+                    (adaptor.right_uncommon_ancestors, adaptor.lca,
+                     conflict.right_nid, conflict.right_rid, right_name, right_fid);
                 }
               else
                 {
============================================================
--- src/merge_content.cc	b3aeba9d9a98bf032c7771ae7426e9209085f070
+++ src/merge_content.cc	6e5fe3365b60c66b5ef14e6775d6a7bd49ec3312
@@ -42,8 +42,11 @@ content_merge_database_adaptor::content_
                                                                revision_id const & left,
                                                                revision_id const & right,
                                                                marking_map const & left_mm,
-                                                               marking_map const & right_mm)
-  : db(db), left_rid (left), right_rid (right), left_mm(left_mm), right_mm(right_mm)
+                                                               marking_map const & right_mm,
+                                                               set<revision_id> left_uncommon_ancestors,
+                                                               set<revision_id> right_uncommon_ancestors)
+  : db(db), left_rid (left), right_rid (right), left_mm(left_mm), right_mm(right_mm),
+  left_uncommon_ancestors (left_uncommon_ancestors), right_uncommon_ancestors (right_uncommon_ancestors)
 {
   // FIXME: possibly refactor to run this lazily, as we don't
   // need to find common ancestors if we're never actually
@@ -180,21 +183,20 @@ void
 }
 
 void
-content_merge_database_adaptor::get_dropped_details(revision_id & rev_id,
-                                                    node_id       nid,
-                                                    revision_id & dropped_rev_id,
-                                                    file_path   & dropped_name,
-                                                    file_id     & dropped_file_id)
+content_merge_database_adaptor::get_dropped_details(set<revision_id> const & uncommon_ancestors,
+                                                    revision_id const &      least_common_ancestor,
+                                                    node_id const            nid,
+                                                    revision_id &            dropped_rev_id,
+                                                    file_path   &            dropped_name,
+                                                    file_id     &            dropped_file_id)
 {
-  set<revision_id> parents;
-  db.get_revision_parents(rev_id, parents);
+  roster_t roster;
+  marking_map marking_map;
 
-  while (parents.begin() != parents.end())
+  // graph.cc ensures that uncommon_ancestors is in topological order, leaf-most first.
+  for (set<revision_id>::const_iterator i = uncommon_ancestors.begin();
+       i != uncommon_ancestors.end(); ++i)
     {
-      set<revision_id>::iterator i = parents.begin();
-      roster_t roster;
-      marking_map marking_map;
-
       db.get_roster(*i, roster, marking_map);
       if (roster.has_node(nid))
         {
@@ -202,14 +204,16 @@ content_merge_database_adaptor::get_drop
           roster.get_file_details(nid, dropped_file_id, dropped_name);
           return;
         }
-      else
-        {
-          set<revision_id> more_parents;
-          db.get_revision_parents(*i, more_parents);
-          parents.erase (i);
-          parents.insert(more_parents.begin(), more_parents.end());
-        }
     }
+
+  db.get_roster(least_common_ancestor, roster, marking_map);
+  if (roster.has_node(nid))
+    {
+      dropped_rev_id = least_common_ancestor;
+      roster.get_file_details(nid, dropped_file_id, dropped_name);
+      return;
+    }
+  I(false);
 }
 
 void
@@ -837,7 +841,8 @@ interactive_merge_and_store(lua_hooks & 
   bool resolutions_given;
   temp_node_id_source nis;
   content_merge_database_adaptor dba(db, left_rid, right_rid,
-                                     left_marking_map, right_marking_map);
+                                     left_marking_map, right_marking_map,
+                                     left_uncommon_ancestors, right_uncommon_ancestors);
 
   parse_resolve_conflicts_opts (opts, left_rid, left_roster, right_rid, right_roster, result, resolutions_given);
 
============================================================
--- src/merge_content.hh	f9a3388e5d2bd6d873d352dabf896df32827e983
+++ src/merge_content.hh	b6545d8397108a002d119659773b3dea1eff4951
@@ -1,5 +1,5 @@
 // Copyright (C) 2005 Nathaniel Smith <address@hidden>
-//               2008, 2010, 2012 Stephen Leake <address@hidden>
+//               2008, 2010, 2012, 2013 Stephen Leake <address@hidden>
 //
 // This program is made available under the GNU GPL version 2.0 or
 // greater. See the accompanying file COPYING for details.
@@ -60,12 +60,15 @@ content_merge_database_adaptor
   revision_id right_rid;
   marking_map const & left_mm;
   marking_map const & right_mm;
+  std::set<revision_id> left_uncommon_ancestors, right_uncommon_ancestors;
   std::map<revision_id, boost::shared_ptr<roster_t const> > rosters;
   content_merge_database_adaptor(database & db,
                                  revision_id const & left,
                                  revision_id const & right,
                                  marking_map const & left_mm,
-                                 marking_map const & right_mm);
+                                 marking_map const & right_mm,
+                                 std::set<revision_id> left_uncommon_ancestors,
+                                 std::set<revision_id> right_uncommon_ancestors);
   void record_merge(file_id const & left_ident,
                     file_id const & right_ident,
                     file_id const & merged_ident,
@@ -88,13 +91,15 @@ content_merge_database_adaptor
                             revision_id & rid,
                             boost::shared_ptr<roster_t const> & anc);
 
-  // Search parents of rev_id (which must be left_rid or right_rid); return
-  // rev, file_path, and file_id for nid just before it was dropped.
-  void get_dropped_details(revision_id & rev_id,
-                           node_id       nid,
-                           revision_id & dropped_rev_id,
-                           file_path   & dropped_name,
-                           file_id     & dropped_file_id);
+  // Search uncommon_ancestors (which must be left_uncommon_ancestors or
+  // right_uncommon_ancestors); return rev, file_path, and file_id for nid
+  // just before it was dropped.
+  void get_dropped_details(std::set<revision_id> const & uncommon_ancestors,
+                           revision_id const &           least_common_ancestor,
+                           node_id                       nid,
+                           revision_id &                 dropped_rev_id,
+                           file_path   &                 dropped_name,
+                           file_id     &                 dropped_file_id);
 
   void get_version(file_id const & ident,
                    file_data & dat) const;
============================================================
--- src/database.cc	39ab2644b936e09a536b99ebd28b93f6e0d7c162
+++ src/database.cc	a2f65339e0beb0740c9338b149b47e70c9ae0bfd
@@ -98,12 +98,15 @@ using boost::lexical_cast;
 using boost::tuple;
 using boost::lexical_cast;
 
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
+using Botan::PK_Encryptor_EME;
+#else
 using Botan::PK_Encryptor;
+#endif
 using Botan::PK_Verifier;
 using Botan::SecureVector;
 using Botan::X509_PublicKey;
 using Botan::RSA_PublicKey;
-using Botan::get_pk_encryptor;
 
 int const 
 int const 
@@ -3435,23 +3438,25 @@ database::encrypt_rsa(key_id const & pub
     throw recoverable_failure(origin::system,
                               "Failed to get RSA encrypting key");
 
-  shared_ptr<PK_Encryptor>
-    encryptor(get_pk_encryptor(*pub_key, "EME1(SHA-1)"));
-
   SecureVector<Botan::byte> ct;
 
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
-  ct = encryptor->encrypt(
+  PK_Encryptor_EME encryptor(*pub_key, "EME1(SHA-1)");
+  ct = encryptor.encrypt(
           reinterpret_cast<Botan::byte const *>(plaintext.data()),
           plaintext.size(), lazy_rng::get());
 #else
+  shared_ptr<PK_Encryptor>
+    encryptor(Botan::get_pk_encryptor(*pub_key, "EME1(SHA-1)"));
+
   ct = encryptor->encrypt(
           reinterpret_cast<Botan::byte const *>(plaintext.data()),
           plaintext.size());
 #endif
-  ciphertext = rsa_oaep_sha_data(string(reinterpret_cast<char const *>(ct.begin()),
-                                        ct.size()),
-                                 origin::database);
+
+  ciphertext = rsa_oaep_sha_data(
+    string(reinterpret_cast<char const *>(ct.begin()), ct.size()),
+    origin::database);
 }
 
 cert_status
@@ -3486,7 +3491,11 @@ database::check_signature(key_id const &
       E(pub_key, id.inner().made_from,
         F("failed to get RSA verifying key for %s") % id);
 
-      verifier.reset(get_pk_verifier(*pub_key, "EMSA3(SHA-1)"));
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+      verifier.reset(new Botan::PK_Verifier(*pub_key, "EMSA3(SHA1)"));
+#else
+      verifier.reset(Botan::get_pk_verifier(*pub_key, "EMSA3(SHA-1)"));
+#endif
 
       /* XXX This is ugly. We need to keep the key around
        * as long as the verifier is around, but the shared_ptr will go
============================================================
--- src/key_store.cc	1ca13b7ee527bc2872d9fc325cf5ef327ca053c2
+++ src/key_store.cc	974edefb0c48a3cdb903cac5c03859563c1e6971
@@ -55,6 +55,7 @@ using Botan::get_cipher;
 using Botan::Pipe;
 using Botan::get_pk_decryptor;
 using Botan::get_cipher;
+using Botan::byte;
 
 
 typedef pair<key_name, keypair> key_info;
@@ -710,10 +711,19 @@ key_store::create_key_pair(database & db
 
   // serialize and maybe encrypt the private key
   keypair kp;
-  SecureVector<Botan::byte> pubkey, privkey;
+  SecureVector<byte> pubkey, privkey;
 
   unfiltered_pipe->start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
   if ((*maybe_passphrase)().length())
+    unfiltered_pipe->write(
+      Botan::PKCS8::BER_encode(priv, lazy_rng::get(),
+                               (*maybe_passphrase)(),
+                               "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"));
+  else
+    unfiltered_pipe->write(Botan::PKCS8::PEM_encode(priv));
+#else
+  if ((*maybe_passphrase)().length())
     Botan::PKCS8::encrypt_key(priv, *unfiltered_pipe,
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
                               lazy_rng::get(),
@@ -723,13 +733,20 @@ key_store::create_key_pair(database & db
                               Botan::RAW_BER);
   else
     Botan::PKCS8::encode(priv, *unfiltered_pipe);
+#endif
   unfiltered_pipe->end_msg();
-  kp.priv = rsa_priv_key(unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
-                         origin::internal);
 
+  kp.priv = rsa_priv_key(
+    unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
+    origin::internal);
+
   // serialize the public key
   unfiltered_pipe->start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+  unfiltered_pipe->write(Botan::X509::BER_encode(priv));
+#else
   Botan::X509::encode(priv, *unfiltered_pipe, Botan::RAW_BER);
+#endif
   unfiltered_pipe->end_msg();
   kp.pub = rsa_pub_key(unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
                        origin::internal);
@@ -796,7 +813,16 @@ key_store::change_key_passphrase(key_id 
   get_passphrase(new_phrase, name, id, true, false);
 
   unfiltered_pipe->start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
   if (new_phrase().length())
+    unfiltered_pipe->write(
+      Botan::PKCS8::BER_encode(*priv, lazy_rng::get(),
+                               new_phrase(),
+                               "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"));
+  else
+    unfiltered_pipe->write(Botan::PKCS8::PEM_encode(*priv));
+#else
+  if (new_phrase().length())
     Botan::PKCS8::encrypt_key(*priv, *unfiltered_pipe,
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
                               lazy_rng::get(),
@@ -806,6 +832,7 @@ key_store::change_key_passphrase(key_id 
                               Botan::RAW_BER);
   else
     Botan::PKCS8::encode(*priv, *unfiltered_pipe);
+#endif
 
   unfiltered_pipe->end_msg();
   kp.priv = rsa_priv_key(unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
@@ -826,14 +853,23 @@ key_store::decrypt_rsa(key_id const & id
       load_key_pair(*this, id, kp);
       shared_ptr<RSA_PrivateKey> priv_key = s->decrypt_private_key(id);
 
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+      Botan::PK_Decryptor_EME decryptor(*priv_key, "EME1(SHA-1)");
+
+      SecureVector<byte> plain =
+        decryptor.decrypt(reinterpret_cast<byte const *>(ciphertext().data()),
+                          ciphertext().size());
+      plaintext = string(plain.begin(), plain.end());
+#else
       shared_ptr<PK_Decryptor>
-        decryptor(get_pk_decryptor(*priv_key, "EME1(SHA-1)"));
+        decryptor(Botan::get_pk_decryptor(*priv_key, "EME1(SHA-1)"));
 
-      SecureVector<Botan::byte> plain =
-        decryptor->decrypt(reinterpret_cast<Botan::byte const *>(ciphertext().data()),
+      SecureVector<byte> plain =
+        decryptor->decrypt(reinterpret_cast<byte const *>(ciphertext().data()),
                            ciphertext().size());
       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
                          plain.size());
+#endif
     }
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
   catch (std::exception & e)
@@ -873,8 +909,8 @@ key_store::make_signature(database & db,
     {
       if (agent.connected()) {
         //grab the monotone public key as an RSA_PublicKey
-        SecureVector<Botan::byte> pub_block
-          (reinterpret_cast<Botan::byte const *>(key.pub().data()),
+        SecureVector<byte> pub_block
+          (reinterpret_cast<byte const *>(key.pub().data()),
            key.pub().size());
         L(FL("make_signature: building %d-byte pub key") % pub_block.size());
         shared_ptr<X509_PublicKey> x509_key =
@@ -902,7 +938,7 @@ key_store::make_signature(database & db,
       || s->ssh_sign_mode == "check"
       || s->ssh_sign_mode == "no")
     {
-      SecureVector<Botan::byte> sig;
+      SecureVector<byte> sig;
 
       // we permit the user to relax security here, by caching a decrypted key
       // (if they permit it) through the life of a program run. this helps when
@@ -926,7 +962,13 @@ key_store::make_signature(database & db,
             L(FL("make_signature: adding private key (%s) to ssh-agent") % id);
             agent.add_identity(*priv_key, name());
           }
-          signer = shared_ptr<PK_Signer>(get_pk_signer(*priv_key, "EMSA3(SHA-1)"));
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+          signer = shared_ptr<PK_Signer>(
+                     new PK_Signer(*priv_key, "EMSA3(SHA-1)"));
+#else
+          signer = shared_ptr<PK_Signer>(
+                     get_pk_signer(*priv_key, "EMSA3(SHA-1)"));
+#endif
 
           /* If persist_phrase is true, the RSA_PrivateKey object is
              cached in s->active_keys and will survive as long as the
@@ -937,11 +979,11 @@ key_store::make_signature(database & db,
 
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
       sig = signer->sign_message(
-        reinterpret_cast<Botan::byte const *>(tosign.data()),
+        reinterpret_cast<byte const *>(tosign.data()),
         tosign.size(), lazy_rng::get());
 #else
       sig = signer->sign_message(
-        reinterpret_cast<Botan::byte const *>(tosign.data()),
+        reinterpret_cast<byte const *>(tosign.data()),
         tosign.size());
 #endif
       sig_string = string(reinterpret_cast<char const*>(sig.begin()), sig.size());
@@ -1006,7 +1048,16 @@ key_store::export_key_for_agent(key_id c
   // This pipe cannot sensibly be recycled.
   Pipe p(new Botan::DataSink_Stream(os));
   p.start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
   if (new_phrase().length())
+    p.write(Botan::PKCS8::PEM_encode(*priv,
+                                     lazy_rng::get(),
+                                     new_phrase(),
+                                     "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"));
+  else
+    p.write(Botan::PKCS8::PEM_encode(*priv));
+#else
+  if (new_phrase().length())
     Botan::PKCS8::encrypt_key(*priv,
                               p,
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
@@ -1016,6 +1067,7 @@ key_store::export_key_for_agent(key_id c
                               "PBE-PKCS5v20(SHA-1,TripleDES/CBC)");
   else
     Botan::PKCS8::encode(*priv, p);
+#endif
   p.end_msg();
 }
 
@@ -1031,7 +1083,7 @@ key_store_state::migrate_old_key_pair
      rsa_pub_key const & pub)
 {
   keypair kp;
-  SecureVector<Botan::byte> arc4_key;
+  SecureVector<byte> arc4_key;
   utf8 phrase;
   shared_ptr<PKCS8_PrivateKey> pkcs8_key;
   shared_ptr<RSA_PrivateKey> priv_key;
@@ -1051,10 +1103,10 @@ key_store_state::migrate_old_key_pair
       {
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
         arc4_key.resize(phrase().size());
-        arc4_key.copy(reinterpret_cast<Botan::byte const *>(phrase().data()),
+        arc4_key.copy(reinterpret_cast<byte const *>(phrase().data()),
                       phrase().size());
 #else
-        arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
+        arc4_key.set(reinterpret_cast<byte const *>(phrase().data()),
                      phrase().size());
 #endif
 
@@ -1065,7 +1117,7 @@ key_store_state::migrate_old_key_pair
         // This is necessary because PKCS8::load_key() cannot currently
         // recognize an unencrypted, raw-BER blob as such, but gets it
         // right if it's PEM-coded.
-        SecureVector<Botan::byte> arc4_decrypt(arc4_decryptor.read_all());
+        SecureVector<byte> arc4_decrypt(arc4_decryptor.read_all());
         Botan::DataSource_Memory ds(Botan::PEM_Code::encode(arc4_decrypt,
                                                             "PRIVATE KEY"));
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
@@ -1098,6 +1150,11 @@ key_store_state::migrate_old_key_pair
 
   // now we can write out the new key
   unfiltered_pipe->start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+  unfiltered_pipe->write(Botan::PKCS8::BER_encode(
+    *priv_key, lazy_rng::get(), phrase(),
+    "PBE-PKCS5v20(SHA-1,TripleDES/CBC)"));
+#else
   Botan::PKCS8::encrypt_key(*priv_key, *unfiltered_pipe,
 #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
                             lazy_rng::get(),
@@ -1105,6 +1162,7 @@ key_store_state::migrate_old_key_pair
                             phrase(),
                             "PBE-PKCS5v20(SHA-1,TripleDES/CBC)",
                             Botan::RAW_BER);
+#endif
   unfiltered_pipe->end_msg();
   kp.priv = rsa_priv_key(unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
                          origin::internal);
@@ -1113,7 +1171,11 @@ key_store_state::migrate_old_key_pair
   // Botan for the X.509 encoding of the private key implies that we want
   // it to derive and produce the public key)
   unfiltered_pipe->start_msg();
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,10,0)
+  unfiltered_pipe->write(Botan::X509::BER_encode(*priv_key));
+#else
   Botan::X509::encode(*priv_key, *unfiltered_pipe, Botan::RAW_BER);
+#endif
   unfiltered_pipe->end_msg();
   kp.pub = rsa_pub_key(unfiltered_pipe->read_all_as_string(Pipe::LAST_MESSAGE),
                        origin::internal);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]