monotone

View botan-1.10.patch

1#
2#
3# patch "src/database.cc"
4# from [4c259f963c440fc95564dfec99b2f832f0bad643]
5# to [87efeeff2d3263ba98af684a4022f1897434ed2d]
6#
7# patch "src/gzip.cc"
8# from [e7c19bee910e3d421fd073933810ec52092b1d9b]
9# to [bab290412cff6031b2d3bf9d1439a08499d39640]
10#
11# patch "src/gzip.hh"
12# from [649dfc0b250954f39c0f73870f8bec3f32f7fa43]
13# to [f462dfc1df71ae1e9a8203606fd29d9e0eda9b2a]
14#
15# patch "src/key_packet.cc"
16# from [d1306df89dd684badac02c03744cd446381c07d3]
17# to [c97262d161b23c9640972188979669b3e95afe7b]
18#
19# patch "src/key_store.cc"
20# from [64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e]
21# to [1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5]
22#
23# patch "src/monotone.cc"
24# from [a25ecdd170a601db798b63a60add7681609a34c4]
25# to [2c5f57762bc687a90f75e732f39d2181fc50bd6d]
26#
27# patch "src/packet.cc"
28# from [f61360ed2524fdf53411bd24d022a2a3c9e6e9c7]
29# to [6f6739c4756933843a2d865dc6790de9013626b7]
30#
31# patch "src/packet.hh"
32# from [0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b]
33# to [6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b]
34#
35# patch "src/sha1.cc"
36# from [5e1aa972d7c7d66e06320b039989652b830dcd75]
37# to [42e48b22fd88b25e0d38d4f91e1f13f8a83c7120]
38#
39# patch "src/ssh_agent.cc"
40# from [6d188e7012a0b82f782563b09bbd7adf3f70cf75]
41# to [4a0dcab873559e934e41c5f220b5434d35600d9b]
42#
43# patch "src/transforms.cc"
44# from [cdfb6854ef4992faba21074145f3c8269b845b11]
45# to [789e01bbff42020d04d8dba8f6b97588fbe4ca3d]
46#
47============================================================
48--- src/database.cc4c259f963c440fc95564dfec99b2f832f0bad643
49+++ src/database.cc87efeeff2d3263ba98af684a4022f1897434ed2d
50@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
51 rsa_pub_key pub;
52 get_key(pub_id, pub);
53
54- SecureVector<Botan::byte> pub_block;
55- pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
56- pub().size());
57+ SecureVector<Botan::byte> pub_block
58+ (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
59
60 shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
61 shared_ptr<RSA_PublicKey> pub_key
62@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
63 else
64 {
65 rsa_pub_key pub;
66- SecureVector<Botan::byte> pub_block;
67
68 if (!public_key_exists(id))
69 return cert_unknown;
70
71 get_key(id, pub);
72- pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
73- pub().size());
74+ SecureVector<Botan::byte> pub_block
75+ (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
76
77 L(FL("building verifier for %d-byte pub key") % pub_block.size());
78 shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
79============================================================
80--- src/gzip.cce7c19bee910e3d421fd073933810ec52092b1d9b
81+++ src/gzip.ccbab290412cff6031b2d3bf9d1439a08499d39640
82@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
83 /*************************************************
84 * Compress Input with Gzip *
85 *************************************************/
86-void Gzip_Compression::write(const byte input[], u32bit length)
87+void Gzip_Compression::write(const byte input[], filter_length_t length)
88 {
89
90 count += length;
91@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
92 /*************************************************
93 * Decompress Input with Gzip *
94 *************************************************/
95-void Gzip_Decompression::write(const byte input[], u32bit length)
96+void Gzip_Decompression::write(const byte input[], filter_length_t length)
97 {
98 if(length) no_writes = false;
99
100@@ -284,8 +284,8 @@ void Gzip_Decompression::write(const byt
101 // Check the gzip header
102 if (pos < sizeof(GZIP::GZIP_HEADER))
103 {
104- u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
105- u32bit cmplen = len;
106+ filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
107+ filter_length_t cmplen = len;
108 // The last byte is the OS flag - we don't care about that
109 if (pos + len - 1 >= GZIP::HEADER_POS_OS)
110 cmplen--;
111@@ -346,8 +346,14 @@ u32bit Gzip_Decompression::eat_footer(co
112 if (footer.size() >= GZIP::FOOTER_LENGTH)
113 throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
114
115+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
116+ size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
117+ static_cast<size_t>(length));
118+ footer += std::make_pair(input, eat_len);
119+#else
120 u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
121 footer.append(input, eat_len);
122+#endif
123
124 if (footer.size() == GZIP::FOOTER_LENGTH)
125 {
126@@ -377,7 +383,12 @@ void Gzip_Decompression::check_footer()
127 for (int i = 0; i < 4; i++)
128 buf[3-i] = tmpbuf[i];
129
130+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
131+ tmpbuf.resize(4);
132+ tmpbuf.copy(footer.begin(), 4);
133+#else
134 tmpbuf.set(footer.begin(), 4);
135+#endif
136 if (buf != tmpbuf)
137 throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
138
139@@ -412,7 +423,11 @@ void Gzip_Decompression::clear()
140 no_writes = true;
141 inflateReset(&(zlib->stream));
142
143+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
144+ footer.clear();
145+#else
146 footer.destroy();
147+#endif
148 pos = 0;
149 datacount = 0;
150 }
151============================================================
152--- src/gzip.hh649dfc0b250954f39c0f73870f8bec3f32f7fa43
153+++ src/gzip.hhf462dfc1df71ae1e9a8203606fd29d9e0eda9b2a
154@@ -7,6 +7,7 @@
155 #ifndef BOTAN_EXT_GZIP_H__
156 #define BOTAN_EXT_GZIP_H__
157
158+#include <botan/version.h>
159 #include <botan/filter.h>
160 #include <botan/pipe.h>
161
162@@ -30,13 +31,19 @@ namespace GZIP {
163
164 }
165
166+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
167+ typedef size_t filter_length_t;
168+#else
169+ typedef u32bit filter_length_t;
170+#endif
171+
172 /*************************************************
173 * Gzip Compression Filter *
174 *************************************************/
175 class Gzip_Compression : public Filter
176 {
177 public:
178- void write(const byte input[], u32bit length);
179+ void write(const byte input[], filter_length_t length);
180 void start_msg();
181 void end_msg();
182 std::string name() const { return "Gzip_Compression"; }
183@@ -60,7 +67,7 @@ class Gzip_Decompression : public Filter
184 class Gzip_Decompression : public Filter
185 {
186 public:
187- void write(const byte input[], u32bit length);
188+ void write(const byte input[], filter_length_t length);
189 void start_msg();
190 void end_msg();
191 std::string name() const { return "Gzip_Decompression"; }
192============================================================
193--- src/key_packet.ccd1306df89dd684badac02c03744cd446381c07d3
194+++ src/key_packet.ccc97262d161b23c9640972188979669b3e95afe7b
195@@ -106,8 +106,8 @@ namespace
196 void validate_public_key_data(string const & name, string const & keydata) const
197 {
198 string decoded = decode_base64_as<string>(keydata, origin::user);
199- Botan::SecureVector<Botan::byte> key_block;
200- key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
201+ Botan::SecureVector<Botan::byte> key_block
202+ (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
203 try
204 {
205 Botan::X509::load_key(key_block);
206============================================================
207--- src/key_store.cc64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
208+++ src/key_store.cc1b1f1a989c21ee0dc69c540783ffb1fe4bceabf5
209@@ -572,13 +572,19 @@ key_store_state::decrypt_private_key(key
210 try // with empty passphrase
211 {
212 Botan::DataSource_Memory ds(kp.priv());
213-#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
214+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
215+ pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), Dummy_UI()));
216+#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
217 pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), ""));
218 #else
219 pkcs8_key.reset(Botan::PKCS8::load_key(ds, ""));
220 #endif
221 }
222+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
223+ catch (Passphrase_Required & e)
224+#else
225 catch (Botan::Exception & e)
226+#endif
227 {
228 L(FL("failed to load key with no passphrase: %s") % e.what());
229
230@@ -856,9 +862,9 @@ key_store::make_signature(database & db,
231 {
232 if (agent.connected()) {
233 //grab the monotone public key as an RSA_PublicKey
234- SecureVector<Botan::byte> pub_block;
235- pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
236- key.pub().size());
237+ SecureVector<Botan::byte> pub_block
238+ (reinterpret_cast<Botan::byte const *>(key.pub().data()),
239+ key.pub().size());
240 L(FL("make_signature: building %d-byte pub key") % pub_block.size());
241 shared_ptr<X509_PublicKey> x509_key =
242 shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
243@@ -1031,8 +1037,14 @@ key_store_state::migrate_old_key_pair
244 for (;;)
245 try
246 {
247+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
248+ arc4_key.resize(phrase().size());
249+ arc4_key.copy(reinterpret_cast<Botan::byte const *>(phrase().data()),
250+ phrase().size());
251+#else
252 arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
253 phrase().size());
254+#endif
255
256 Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
257
258============================================================
259--- src/monotone.cca25ecdd170a601db798b63a60add7681609a34c4
260+++ src/monotone.cc2c5f57762bc687a90f75e732f39d2181fc50bd6d
261@@ -170,11 +170,16 @@ cpp_main(int argc, char ** argv)
262 // versions, including all of the stable branch 1.8.x.
263 E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
264 F("this monotone binary does not work with Botan 1.9.x"));
265-#else
266+#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
267 E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
268 F("this monotone binary requires Botan 1.7.22 or newer"));
269 E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
270 F("this monotone binary does not work with Botan 1.9.x"));
271+#else
272+ E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
273+ F("this monotone binary requires Botan 1.9.11 or newer"));
274+ E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,11,0), origin::system,
275+ F("this monotone binary does not work with Botan 1.11.x"));
276 #endif
277
278 app_state app;
279============================================================
280--- src/packet.ccf61360ed2524fdf53411bd24d022a2a3c9e6e9c7
281+++ src/packet.cc6f6739c4756933843a2d865dc6790de9013626b7
282@@ -156,8 +156,8 @@ namespace
283 void validate_public_key_data(string const & name, string const & keydata) const
284 {
285 string decoded = decode_base64_as<string>(keydata, origin::user);
286- Botan::SecureVector<Botan::byte> key_block;
287- key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
288+ Botan::SecureVector<Botan::byte> key_block
289+ (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
290 try
291 {
292 Botan::X509::load_key(key_block);
293@@ -175,7 +175,9 @@ namespace
294 Botan::DataSource_Memory ds(decoded);
295 try
296 {
297-#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
298+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
299+ Botan::PKCS8::load_key(ds, lazy_rng::get(), Dummy_UI());
300+#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
301 Botan::PKCS8::load_key(ds, lazy_rng::get(), string());
302 #else
303 Botan::PKCS8::load_key(ds, string());
304@@ -189,7 +191,11 @@ namespace
305 }
306 // since we do not want to prompt for a password to decode it finally,
307 // we ignore all other exceptions
308+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
309+ catch (Passphrase_Required) {}
310+#else
311 catch (Botan::Invalid_Argument) {}
312+#endif
313 }
314 void validate_certname(string const & cn) const
315 {
316@@ -460,8 +466,14 @@ read_packets(istream & in, packet_consum
317 return count;
318 }
319
320+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
321+std::string Dummy_UI::get_passphrase(const std::string&,
322+ const std::string&,
323+ Botan::User_Interface::UI_Result&) const {
324+ throw Passphrase_Required();
325+}
326+#endif
327
328-
329 // Local Variables:
330 // mode: C++
331 // fill-column: 76
332============================================================
333--- src/packet.hh0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
334+++ src/packet.hh6c7d90e0bd9abe1e2e97da8ed40808fe438ea34b
335@@ -84,8 +84,26 @@ size_t read_packets(std::istream & in, p
336
337 size_t read_packets(std::istream & in, packet_consumer & cons);
338
339+#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
340+// work around botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
341+#include <botan/ui.h>
342+class Dummy_UI : public Botan::User_Interface
343+{
344+public:
345+ virtual std::string get_passphrase(const std::string&,
346+ const std::string&,
347+ Botan::User_Interface::UI_Result&) const;
348+};
349+class Passphrase_Required : public Botan::Exception {
350+public:
351+ Passphrase_Required(const std::string& m = "Passphrase required") :
352+ Botan::Exception(m)
353+ {}
354+};
355 #endif
356
357+#endif
358+
359 // Local Variables:
360 // mode: C++
361 // fill-column: 76
362============================================================
363--- src/sha1.cc5e1aa972d7c7d66e06320b039989652b830dcd75
364+++ src/sha1.cc42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
365@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
366 Botan::Default_Benchmark_Timer timer;
367 std::map<std::string, double> results =
368 Botan::algorithm_benchmark("SHA-1", milliseconds, timer, rng, af);
369+#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
370+ std::map<std::string, double> results =
371+ Botan::algorithm_benchmark("SHA-1", milliseconds, rng, af);
372 #else
373 std::map<std::string, double> results =
374- Botan::algorithm_benchmark("SHA-1", milliseconds, rng, af);
375+ Botan::algorithm_benchmark("SHA-1", af, rng, milliseconds, 16);
376 #endif
377
378 for(std::map<std::string, double>::const_iterator i = results.begin();
379============================================================
380--- src/ssh_agent.cc6d188e7012a0b82f782563b09bbd7adf3f70cf75
381+++ src/ssh_agent.cc4a0dcab873559e934e41c5f220b5434d35600d9b
382@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
383 ssh_agent::has_key(const keypair & key)
384 {
385 //grab the monotone public key as an RSA_PublicKey
386- SecureVector<Botan::byte> pub_block;
387- pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
388- (key.pub)().size());
389+ SecureVector<Botan::byte> pub_block
390+ (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
391+ (key.pub)().size());
392 L(FL("has_key: building %d-byte pub key") % pub_block.size());
393 shared_ptr<X509_PublicKey> x509_key =
394 shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
395============================================================
396--- src/transforms.cccdfb6854ef4992faba21074145f3c8269b845b11
397+++ src/transforms.cc789e01bbff42020d04d8dba8f6b97588fbe4ca3d
398@@ -53,10 +53,10 @@ using Botan::Hash_Filter;
399 // paradigm "must" be used. this program is intended for source code
400 // control and I make no bones about it.
401
402-NORETURN(static inline void error_in_transform(Botan::Exception & e));
403+NORETURN(static inline void error_in_transform(std::exception & e));
404
405 static inline void
406-error_in_transform(Botan::Exception & e, origin::type caused_by)
407+error_in_transform(std::exception & e, origin::type caused_by)
408 {
409 // these classes can all indicate data corruption
410 if (typeid(e) == typeid(Botan::Encoding_Error)
411@@ -107,7 +107,7 @@ error_in_transform(Botan::Exception & e,
412 pipe->process_msg(in); \
413 out = pipe->read_all_as_string(Pipe::LAST_MESSAGE); \
414 } \
415- catch (Botan::Exception & e) \
416+ catch (std::exception & e) \
417 { \
418 pipe.reset(new Pipe(new T(carg))); \
419 error_in_transform(e, made_from); \
420@@ -173,7 +173,7 @@ template<> string xform<Botan::Hex_Decod
421 {
422 throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
423 }
424- catch(Botan::Exception & e)
425+ catch(std::exception & e)
426 {
427 error_in_transform(e, made_from);
428 }
429@@ -219,7 +219,7 @@ void pack(T const & in, base64< gzip<T>
430 tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
431 out = base64< gzip<T> >(tmp, in.made_from);
432 }
433- catch (Botan::Exception & e)
434+ catch (std::exception & e)
435 {
436 pipe.reset(new Pipe(new Gzip_Compression,
437 new Base64_Encoder));
438@@ -237,7 +237,7 @@ void unpack(base64< gzip<T> > const & in
439 pipe->process_msg(in());
440 out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
441 }
442- catch (Botan::Exception & e)
443+ catch (std::exception & e)
444 {
445 pipe.reset(new Pipe(new Base64_Decoder,
446 new Gzip_Decompression));
447@@ -264,7 +264,7 @@ calculate_ident(data const & dat,
448 p->process_msg(dat());
449 ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
450 }
451- catch (Botan::Exception & e)
452+ catch (std::exception & e)
453 {
454 p.reset(new Pipe(new Hash_Filter("SHA-160")));
455 error_in_transform(e, dat.made_from);

Archive Download this file

Attachment to issue 182

Created: 12 years 7 months ago by Martin von Gagern

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status