[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.issue-182: 30c022e6012f74f2b
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.issue-182: 30c022e6012f74f2b407b0cba7782fce17a041f4 |
Date: |
Mon, 12 Sep 2011 13:09:11 +0200 (CEST) |
revision: 30c022e6012f74f2b407b0cba7782fce17a041f4
date: 2011-09-08T08:36:44
author: address@hidden
branch: net.venge.monotone.issue-182
changelog:
Detect encoded keys with botan 1.10.x.
Older botan releases used to throw an Invalid_Argument exception in case of
an empty pass phrase, which in turn was derived from Botan::Exception.
Neither is necessarily true now, mostly due to botan commits
2d09d7d0cd4bd0e7155d001dd65a4f29103b158c and
e30a741f6014987e9683842ede22c44b2db03c56. So now we use our own dummy UI to
throw a well-known exception if a passphrase would be required.
At least for key_store, actually doing the user interaction inside a
User_Interface specialization would probably be the better solution in the
long run, but this dirty hack does the job for now.
manifest:
format_version "1"
new_manifest [6508b224ead40bf65b782ecd4a17ec0e6104d613]
old_revision [0567ddefc130f03116a1b8a4e3a9a277a9da87af]
patch "src/key_store.cc"
from [6f2f1e0a60f5ee7d322539ca7a3c0acdc69617d7]
to [1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5]
patch "src/packet.cc"
from [58e2b3070821fb540fc8fe8db92564579a25ce88]
to [6f6739c4756933843a2d865dc6790de9013626b7]
patch "src/packet.hh"
from [0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b]
to [6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b]
============================================================
--- src/packet.cc 58e2b3070821fb540fc8fe8db92564579a25ce88
+++ src/packet.cc 6f6739c4756933843a2d865dc6790de9013626b7
@@ -175,7 +175,9 @@ namespace
Botan::DataSource_Memory ds(decoded);
try
{
-#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+ Botan::PKCS8::load_key(ds, lazy_rng::get(), Dummy_UI());
+#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
Botan::PKCS8::load_key(ds, lazy_rng::get(), string());
#else
Botan::PKCS8::load_key(ds, string());
@@ -189,7 +191,11 @@ namespace
}
// since we do not want to prompt for a password to decode it finally,
// we ignore all other exceptions
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+ catch (Passphrase_Required) {}
+#else
catch (Botan::Invalid_Argument) {}
+#endif
}
void validate_certname(string const & cn) const
{
@@ -460,8 +466,14 @@ read_packets(istream & in, packet_consum
return count;
}
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+std::string Dummy_UI::get_passphrase(const std::string&,
+ const std::string&,
+ Botan::User_Interface::UI_Result&) const {
+ throw Passphrase_Required();
+}
+#endif
-
// Local Variables:
// mode: C++
// fill-column: 76
============================================================
--- src/packet.hh 0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
+++ src/packet.hh 6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b
@@ -84,8 +84,26 @@ size_t read_packets(std::istream & in, p
size_t read_packets(std::istream & in, packet_consumer & cons);
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+// work around botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
+#include <botan/ui.h>
+class Dummy_UI : public Botan::User_Interface
+{
+public:
+ virtual std::string get_passphrase(const std::string&,
+ const std::string&,
+ Botan::User_Interface::UI_Result&) const;
+};
+class Passphrase_Required : public Botan::Exception {
+public:
+ Passphrase_Required(const std::string& m = "Passphrase required") :
+ Botan::Exception(m)
+ {}
+};
#endif
+#endif
+
// Local Variables:
// mode: C++
// fill-column: 76
============================================================
--- src/key_store.cc 6f2f1e0a60f5ee7d322539ca7a3c0acdc69617d7
+++ src/key_store.cc 1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5
@@ -572,13 +572,19 @@ key_store_state::decrypt_private_key(key
try // with empty passphrase
{
Botan::DataSource_Memory ds(kp.priv());
-#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+ pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), Dummy_UI()));
+#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), ""));
#else
pkcs8_key.reset(Botan::PKCS8::load_key(ds, ""));
#endif
}
+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
+ catch (Passphrase_Required & e)
+#else
catch (Botan::Exception & e)
+#endif
{
L(FL("failed to load key with no passphrase: %s") % e.what());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.issue-182: 30c022e6012f74f2b407b0cba7782fce17a041f4,
code <=