From lapo@lapo.it  Fri May  3 08:22:42 2013
Return-Path: <lapo@lapo.it>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 89B90AFB
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  3 May 2013 08:22:42 +0000 (UTC)
	(envelope-from lapo@lapo.it)
Received: from relay.andxor.it (relay.andxor.it [195.223.2.3])
	by mx1.freebsd.org (Postfix) with ESMTP id 209E81DBD
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  3 May 2013 08:22:40 +0000 (UTC)
Received: (qmail 1440 invoked from network); 3 May 2013 08:22:32 -0000
Received: from lapo.andxor.it (192.168.2.22)
  by relay.andxor.it with ESMTPS; 3 May 2013 08:22:32 -0000
Received: from lapo.andxor.it (localhost.andxor.it [127.0.0.1])
	by lapo.andxor.it (8.14.5/8.14.5) with ESMTP id r438MWiE023847;
	Fri, 3 May 2013 10:22:32 +0200 (CEST)
	(envelope-from lapo@lapo.andxor.it)
Received: (from lapo@localhost)
	by lapo.andxor.it (8.14.5/8.14.5/Submit) id r438MWSp023846;
	Fri, 3 May 2013 10:22:32 +0200 (CEST)
	(envelope-from lapo)
Message-Id: <201305030822.r438MWSp023846@lapo.andxor.it>
Date: Fri, 3 May 2013 10:22:32 +0200 (CEST)
From: Lapo Luchini <lapo@lapo.it>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Lapo Luchini <lapo@lapo.it>
Subject: [MAINTAINER] devel/monotone: prepare for botan 1.10.x
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         178316
>Category:       ports
>Synopsis:       [MAINTAINER] devel/monotone: prepare for botan 1.10.x
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    madpilot
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 03 08:30:00 UTC 2013
>Closed-Date:    Wed May 22 18:09:44 UTC 2013
>Last-Modified:  Wed May 22 18:10:01 UTC 2013
>Originator:     Lapo Luchini
>Release:        FreeBSD 8.3-RELEASE-p3 amd64
>Organization:
>Environment:
System: FreeBSD lapo.andxor.it 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #0: Tue Jun 12 00:39:29 UTC 2012
>Description:
Apply a patch (taken from upstream) that makes monotone 1.0 compatible with botan 1.10.x, in preparation for botan upgrade.
Update Makefile format.

Generated with FreeBSD Port Tools 0.99_7 (mode: change, diff: ports)
>How-To-Repeat:
>Fix:

--- monotone-1.0_3.patch begins here ---
diff -ruN /usr/ports/devel/monotone/Makefile ./Makefile
--- /usr/ports/devel/monotone/Makefile	2013-04-27 10:50:46.000000000 +0200
+++ ./Makefile	2013-05-02 15:12:53.825731342 +0200
@@ -1,9 +1,9 @@
 # Created by: Mark A. Wicks <mwicks@kettering.edu>
-# $FreeBSD: devel/monotone/Makefile 316654 2013-04-27 08:50:46Z mva $
+# $FreeBSD: ports/devel/monotone/Makefile,v 1.54 2012/02/14 12:45:17 mm Exp $
 
 PORTNAME=	monotone
 PORTVERSION=	1.0
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	devel
 MASTER_SITES=	http://www.monotone.ca/downloads/${PORTVERSION}/
 
@@ -14,15 +14,15 @@
 LICENSE_FILE=	${WRKSRC}/COPYING
 
 BUILD_DEPENDS=	${LOCALBASE}/include/boost/shared_ptr.hpp:${PORTSDIR}/devel/boost-libs
-LIB_DEPENDS=	pcre.3:${PORTSDIR}/devel/pcre \
-		idn.17:${PORTSDIR}/dns/libidn \
-		sqlite3.8:${PORTSDIR}/databases/sqlite3 \
-		botan.0:${PORTSDIR}/security/botan
+LIB_DEPENDS=	pcre:${PORTSDIR}/devel/pcre \
+		idn:${PORTSDIR}/dns/libidn \
+		sqlite3:${PORTSDIR}/databases/sqlite3 \
+		botan:${PORTSDIR}/security/botan
 
 SUB_FILES=	pkg-message
 USE_BZIP2=	yes
 USE_PERL5_BUILD=yes
-USES=		iconv
+USE_ICONV=	yes
 USE_GMAKE=	yes
 USE_LUA=	5.1+
 
@@ -57,28 +57,28 @@
 .endif
 PORTDOCS=	*
 
-.include <bsd.port.options.mk>
+.include <bsd.port.pre.mk>
 
 .if ${ARCH} == amd64
 USE_GCC=	4.2+
 .endif
 
-.if ${PORT_OPTIONS:MNLS}
-USES+=	gettext
+.if defined(WITHOUT_NLS)
+CONFIGURE_ARGS+=	--disable-nls
+.else
+USE_GETTEXT=	yes
 PLIST_FILES+=	share/locale/de/LC_MESSAGES/monotone.mo \
 		share/locale/fr/LC_MESSAGES/monotone.mo \
 		share/locale/it/LC_MESSAGES/monotone.mo \
 		share/locale/pt/LC_MESSAGES/monotone.mo \
 		share/locale/sv/LC_MESSAGES/monotone.mo
-.else
-CONFIGURE_ARGS+=	--disable-nls
 .endif
 
 post-extract:
 	@${RM} -f ${WRKSRC}/monotone.info*
 
 post-patch:
-.if ! ${PORT_OPTIONS:MDOCS}
+.if defined(NOPORTDOCS)
 	${REINPLACE_CMD} -Ee '/^install-(contrib|examples)-data:/{' -e 'n' -e 'd' -e '}' ${WRKSRC}/Makefile.in
 .endif
 .if defined(NO_INSTALL_MANPAGES)
@@ -89,16 +89,16 @@
 	${REINPLACE_CMD} -e "s/\"lua/\"lua-${LUA_VER}/g" \
 		-e "s/\"idn/\"libidn/g" \
 		-e "s/\"pcre/\"libpcre/g" \
-		-e "s/\"botan/\"botan-1.8/g" \
+		-e "s/\"botan/\"libbotan/g" \
 		${WRKSRC}/configure
 
 post-install:
 	${MKDIR} ${PREFIX}/share/zsh/site-functions
 	${INSTALL_DATA} ${WRKSRC}/contrib/monotone.zsh_completion ${PREFIX}/share/zsh/site-functions/_mtn
-.if ${PORT_OPTIONS:MDOCS}
+.if !defined(NOPORTDOCS)
 	${MKDIR} ${DOCSDIR}
 	cd ${WRKSRC} && ${INSTALL_DATA} NEWS UPGRADE ${DOCSDIR}
 .endif
 	@${CAT} ${PKGMESSAGE}
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -ruN /usr/ports/devel/monotone/files/patch-botan.diff ./files/patch-botan.diff
--- /usr/ports/devel/monotone/files/patch-botan.diff	1970-01-01 01:00:00.000000000 +0100
+++ ./files/patch-botan.diff	2012-07-27 12:28:30.682016153 +0200
@@ -0,0 +1,679 @@
+# patch to allow compatibility with Botan 1.10.x
+# obtained from upstream repository with the following command:
+# mtn diff -r 7cbb20501714be7f25f30734da82d41c7ac427ca -r 555bc063aee165fc7500cc68df5d818dcaf30913
+#
+# patch "src/database.cc"
+#  from [4c259f963c440fc95564dfec99b2f832f0bad643]
+#    to [87efeeff2d3263ba98af684a4022f1897434ed2d]
+# 
+# patch "src/gzip.cc"
+#  from [e7c19bee910e3d421fd073933810ec52092b1d9b]
+#    to [9da41f6820cdf39707b22c716e3682e0fa0fd745]
+# 
+# patch "src/gzip.hh"
+#  from [649dfc0b250954f39c0f73870f8bec3f32f7fa43]
+#    to [aff9da63bb22366bccf69c2d75ee7790406d2455]
+# 
+# patch "src/key_packet.cc"
+#  from [d1306df89dd684badac02c03744cd446381c07d3]
+#    to [c97262d161b23c9640972188979669b3e95afe7b]
+# 
+# patch "src/key_store.cc"
+#  from [64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e]
+#    to [b7859345f7c665914d16357409bdff24a48b7996]
+# 
+# patch "src/monotone.cc"
+#  from [a25ecdd170a601db798b63a60add7681609a34c4]
+#    to [764bc9ca406b41d21efd552a0d810bc2849e0588]
+# 
+# patch "src/packet.cc"
+#  from [f61360ed2524fdf53411bd24d022a2a3c9e6e9c7]
+#    to [571ff6eae1d269a146da74f2730b70376957d3bb]
+# 
+# patch "src/packet.hh"
+#  from [0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b]
+#    to [9c43d30145f0292d6ceda5e717e366fdead5a4d6]
+# 
+# patch "src/sha1.cc"
+#  from [5e1aa972d7c7d66e06320b039989652b830dcd75]
+#    to [42e48b22fd88b25e0d38d4f91e1f13f8a83c7120]
+# 
+# patch "src/ssh_agent.cc"
+#  from [6d188e7012a0b82f782563b09bbd7adf3f70cf75]
+#    to [4a0dcab873559e934e41c5f220b5434d35600d9b]
+# 
+# patch "src/transforms.cc"
+#  from [cdfb6854ef4992faba21074145f3c8269b845b11]
+#    to [b99278ffe95c0081bf4986bc74d3699c37a52948]
+#
+============================================================
+--- src/database.cc	4c259f963c440fc95564dfec99b2f832f0bad643
++++ src/database.cc	87efeeff2d3263ba98af684a4022f1897434ed2d
+@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
+   rsa_pub_key pub;
+   get_key(pub_id, pub);
+ 
+-  SecureVector<Botan::byte> pub_block;
+-  pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
+-                pub().size());
++  SecureVector<Botan::byte> pub_block
++    (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
+ 
+   shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
+   shared_ptr<RSA_PublicKey> pub_key
+@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
+   else
+     {
+       rsa_pub_key pub;
+-      SecureVector<Botan::byte> pub_block;
+ 
+       if (!public_key_exists(id))
+         return cert_unknown;
+ 
+       get_key(id, pub);
+-      pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
+-                    pub().size());
++      SecureVector<Botan::byte> pub_block
++        (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
+ 
+       L(FL("building verifier for %d-byte pub key") % pub_block.size());
+       shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
+============================================================
+--- src/gzip.cc	e7c19bee910e3d421fd073933810ec52092b1d9b
++++ src/gzip.cc	9da41f6820cdf39707b22c716e3682e0fa0fd745
+@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
+    if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
+       {
+       delete zlib; zlib = 0;
+-      throw Exception("Gzip_Compression: Memory allocation error");
++      throw Memory_Exhaustion();
+       }
+    }
+ 
+@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
+ /*************************************************
+ * Compress Input with Gzip                       *
+ *************************************************/
+-void Gzip_Compression::write(const byte input[], u32bit length)
++void Gzip_Compression::write(const byte input[], filter_length_t length)
+    {
+ 
+    count += length;
+@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte 
+       zlib->stream.avail_out = buffer.size();
+       int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
+       if (rc != Z_OK && rc != Z_STREAM_END)
+-         throw Exception("Internal error in Gzip_Compression deflate.");
++         throw Invalid_State("Internal error in Gzip_Compression deflate.");
+       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
+       }
+    }
+@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
+       zlib->stream.avail_out = buffer.size();
+       rc = deflate(&(zlib->stream), Z_FINISH);
+       if (rc != Z_OK && rc != Z_STREAM_END)
+-         throw Exception("Internal error in Gzip_Compression finishing deflate.");
++         throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
+       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
+       }
+ 
+@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
+    no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
+    {
+    if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
+-      throw Exception("DEFAULT_BUFFERSIZE is too small");
++      throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
+ 
+    zlib = new Zlib_Stream;
+ 
+@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
+    if(inflateInit2(&(zlib->stream), -15) != Z_OK)
+       {
+       delete zlib; zlib = 0;
+-      throw Exception("Gzip_Decompression: Memory allocation error");
++      throw Memory_Exhaustion();
+       }
+    }
+ 
+@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
+ void Gzip_Decompression::start_msg()
+    {
+    if (!no_writes)
+-      throw Exception("Gzip_Decompression: start_msg after already writing");
++      throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
+ 
+    pipe.start_msg();
+    datacount = 0;
+@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
+ /*************************************************
+ * Decompress Input with Gzip                     *
+ *************************************************/
+-void Gzip_Decompression::write(const byte input[], u32bit length)
++void Gzip_Decompression::write(const byte input[], filter_length_t length)
+    {
+    if(length) no_writes = false;
+ 
+@@ -277,15 +277,16 @@ void Gzip_Decompression::write(const byt
+          u32bit eat_len = eat_footer(input, length);
+          input += eat_len;
+          length -= eat_len;
+-         if (length == 0)
+-            return;
+       }
+ 
++   if (length == 0)
++     return;
++
+    // Check the gzip header
+    if (pos < sizeof(GZIP::GZIP_HEADER))
+       {
+-      u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
+-      u32bit cmplen = len;
++      filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
++      filter_length_t cmplen = len;
+       // The last byte is the OS flag - we don't care about that
+       if (pos + len - 1 >= GZIP::HEADER_POS_OS)
+          cmplen--;
+@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
+          if(rc == Z_NEED_DICT)
+             throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
+          if(rc == Z_MEM_ERROR)
+-            throw Exception("Gzip_Decompression: Memory allocation error");
+-         throw Exception("Gzip_Decompression: Unknown decompress error");
++            throw Memory_Exhaustion();
++         throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
+          }
+       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
+       pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
+@@ -346,8 +347,14 @@ u32bit Gzip_Decompression::eat_footer(co
+       if (footer.size() >= GZIP::FOOTER_LENGTH)
+          throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
+ 
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
++      size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
++                                static_cast<size_t>(length));
++      footer += std::make_pair(input, eat_len);
++#else
+       u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
+       footer.append(input, eat_len);
++#endif
+ 
+       if (footer.size() == GZIP::FOOTER_LENGTH)
+          {
+@@ -364,7 +371,7 @@ void Gzip_Decompression::check_footer()
+ void Gzip_Decompression::check_footer()
+    {
+    if (footer.size() != GZIP::FOOTER_LENGTH)
+-      throw Exception("Gzip_Decompression: Error finalizing decompression");
++      throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
+ 
+    pipe.end_msg();
+ 
+@@ -377,7 +384,12 @@ void Gzip_Decompression::check_footer()
+   for (int i = 0; i < 4; i++)
+      buf[3-i] = tmpbuf[i];
+ 
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
++  tmpbuf.resize(4);
++  tmpbuf.copy(footer.begin(), 4);
++#else
+   tmpbuf.set(footer.begin(), 4);
++#endif
+   if (buf != tmpbuf)
+       throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
+ 
+@@ -400,7 +412,7 @@ void Gzip_Decompression::end_msg()
+    // read, clear() will reset no_writes
+    if(no_writes) return;
+ 
+-   throw Exception("Gzip_Decompression: didn't find footer");
++   throw Decoding_Error("Gzip_Decompression: didn't find footer");
+ 
+    }
+ 
+@@ -412,7 +424,11 @@ void Gzip_Decompression::clear()
+    no_writes = true;
+    inflateReset(&(zlib->stream));
+ 
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
++   footer.clear();
++#else
+    footer.destroy();
++#endif
+    pos = 0;
+    datacount = 0;
+    }
+============================================================
+--- src/gzip.hh	649dfc0b250954f39c0f73870f8bec3f32f7fa43
++++ src/gzip.hh	aff9da63bb22366bccf69c2d75ee7790406d2455
+@@ -7,11 +7,18 @@
+ #ifndef BOTAN_EXT_GZIP_H__
+ #define BOTAN_EXT_GZIP_H__
+ 
++#include <botan/version.h>
+ #include <botan/filter.h>
+ #include <botan/pipe.h>
+ 
+ namespace Botan {
+ 
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
++// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
++// implementation something compatible to work with.
++typedef std::bad_alloc Memory_Exhaustion;
++#endif
++
+ namespace GZIP {
+ 
+    /* A basic header - we only need to set the IDs and compression method */
+@@ -30,13 +37,19 @@ namespace GZIP {
+ 
+ }
+ 
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
++typedef size_t filter_length_t;
++#else
++typedef u32bit filter_length_t;
++#endif
++
+ /*************************************************
+ * Gzip Compression Filter                        *
+ *************************************************/
+ class Gzip_Compression : public Filter
+    {
+    public:
+-      void write(const byte input[], u32bit length);
++      void write(const byte input[], filter_length_t length);
+       void start_msg();
+       void end_msg();
+       std::string name() const { return "Gzip_Compression"; }
+@@ -60,7 +73,7 @@ class Gzip_Decompression : public Filter
+ class Gzip_Decompression : public Filter
+    {
+    public:
+-      void write(const byte input[], u32bit length);
++      void write(const byte input[], filter_length_t length);
+       void start_msg();
+       void end_msg();
+       std::string name() const { return "Gzip_Decompression"; }
+============================================================
+--- src/key_packet.cc	d1306df89dd684badac02c03744cd446381c07d3
++++ src/key_packet.cc	c97262d161b23c9640972188979669b3e95afe7b
+@@ -106,8 +106,8 @@ namespace
+     void validate_public_key_data(string const & name, string const & keydata) const
+     {
+       string decoded = decode_base64_as<string>(keydata, origin::user);
+-      Botan::SecureVector<Botan::byte> key_block;
+-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
++      Botan::SecureVector<Botan::byte> key_block
++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
+       try
+         {
+           Botan::X509::load_key(key_block);
+============================================================
+--- src/key_store.cc	64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
++++ src/key_store.cc	b7859345f7c665914d16357409bdff24a48b7996
+@@ -572,13 +572,21 @@ 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)
++#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
++  catch (Botan::Invalid_Argument & e)
++#else
+   catch (Botan::Exception & e)
++#endif
+     {
+       L(FL("failed to load key with no passphrase: %s") % e.what());
+ 
+@@ -605,13 +613,18 @@ key_store_state::decrypt_private_key(key
+           {
+             Botan::DataSource_Memory ds(kp.priv());
+ #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
+-            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
++            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
++                                                   phrase()));
+ #else
+             pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
+ #endif
+             break;
+           }
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
++        catch (Botan::Invalid_Argument)
++#else
+         catch (Botan::Exception & e)
++#endif
+           {
+             cycles++;
+             L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
+@@ -822,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
+       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
+                          plain.size());
+     }
+-  catch (Botan::Exception & ex)
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
++  catch (std::exception & e)
++#else
++  catch (Botan::Exception & e)
++#endif
+     {
+       E(false, ciphertext.made_from,
+-        F("Botan error decrypting data: '%s'") % ex.what());
++        F("Botan error decrypting data: '%s'") % e.what());
+     }
+ }
+ 
+@@ -856,9 +873,9 @@ key_store::make_signature(database & db,
+     {
+       if (agent.connected()) {
+         //grab the monotone public key as an RSA_PublicKey
+-        SecureVector<Botan::byte> pub_block;
+-        pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
+-                      key.pub().size());
++        SecureVector<Botan::byte> pub_block
++          (reinterpret_cast<Botan::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 =
+           shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
+@@ -1031,8 +1048,14 @@ key_store_state::migrate_old_key_pair
+   for (;;)
+     try
+       {
++#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()),
++                      phrase().size());
++#else
+         arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
+                      phrase().size());
++#endif
+ 
+         Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
+ 
+@@ -1051,7 +1074,11 @@ key_store_state::migrate_old_key_pair
+ #endif
+         break;
+       }
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
++    catch (Botan::Invalid_Argument & e)
++#else
+     catch (Botan::Exception & e)
++#endif
+       {
+         L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
+           % cycles % e.what());
+============================================================
+--- src/monotone.cc	a25ecdd170a601db798b63a60add7681609a34c4
++++ src/monotone.cc	764bc9ca406b41d21efd552a0d810bc2849e0588
+@@ -156,27 +156,53 @@ cpp_main(int argc, char ** argv)
+       E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
+         F("monotone does not support Botan 1.7.14"));
+ 
+-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
++      // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
++      // se. As 1.10.1 is already out, let's simply disable support for
++      // that specific (testing) version of botan.
++      E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
++        F("monotone does not support Botan 1.9.9"));
++
++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
++      // motonote binary compiled against botan younger than 1.7.7
+       E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
+         F("this monotone binary requires Botan 1.6.3 or newer"));
+-      E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
+-        F("this monotone binary does not work with Botan newer than 1.7.6"));
+-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
+-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
++        F("this monotone binary does not work with Botan 1.7.7 or newer"));
++
++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
++      // motonote binary compiled against botan 1.7.7 - 1.7.21
++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
+         F("this monotone binary requires Botan 1.7.7 or newer"));
+-      // While compiling against 1.7.22 or newer is recommended, because
+-      // it enables new features of Botan, the monotone binary compiled
+-      // against Botan 1.7.21 and before should still work with newer Botan
+-      // versions, including all of the stable branch 1.8.x.
+-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
+-        F("this monotone binary does not work with Botan 1.9.x"));
+-#else
+-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
++      // While compiling against 1.7.22 or newer is recommended, because it
++      // enables new features of Botan, the monotone binary compiled against
++      // Botan 1.7.21 and before should still work with newer Botan version,
++      // including all of the stable branch 1.8.x, up to and including
++      // 1.9.3.
++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
++
++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
++      // motonote binary compiled against botan 1.7.22 - 1.9.3
++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
+         F("this monotone binary requires Botan 1.7.22 or newer"));
+-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
+-        F("this monotone binary does not work with Botan 1.9.x"));
++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
++
++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
++      // motonote binary compiled against botan 1.9.4 - 1.9.10
++#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
++        F("this monotone binary requires Botan 1.9.4 or newer"));
++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
++        F("this monotone binary does not work with Botan 1.9.11 or newer"));
++
++#else
++      // motonote binary compiled against botan 1.9.11 and newer
++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
++        F("this monotone binary requires Botan 1.9.11 or newer"));
+ #endif
+ 
++
+       app_state app;
+       try
+         {
+============================================================
+--- src/packet.cc	f61360ed2524fdf53411bd24d022a2a3c9e6e9c7
++++ src/packet.cc	571ff6eae1d269a146da74f2730b70376957d3bb
+@@ -156,8 +156,8 @@ namespace
+     void validate_public_key_data(string const & name, string const & keydata) const
+     {
+       string decoded = decode_base64_as<string>(keydata, origin::user);
+-      Botan::SecureVector<Botan::byte> key_block;
+-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
++      Botan::SecureVector<Botan::byte> key_block
++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
+       try
+         {
+           Botan::X509::load_key(key_block);
+@@ -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,16 @@ read_packets(istream & in, packet_consum
+   return count;
+ }
+ 
++// Dummy User_Interface implementation for Botan
++#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("Passphrase required");
++}
++#endif
+ 
+-
+ // Local Variables:
+ // mode: C++
+ // fill-column: 76
+============================================================
+--- src/packet.hh	0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
++++ src/packet.hh	9c43d30145f0292d6ceda5e717e366fdead5a4d6
+@@ -10,6 +10,10 @@
+ #ifndef __PACKET_HH__
+ #define __PACKET_HH__
+ 
++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
++#include <botan/ui.h>
++#endif
++
+ #include "vocab.hh"
+ 
+ struct cert;
+@@ -84,8 +88,23 @@ 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)
++// A helper class implementing Botan::User_Interface - which doesn't really
++// interface with the user, but provides the necessary plumbing for Botan.
++//
++// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
++typedef std::runtime_error Passphrase_Required;
++
++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;
++};
+ #endif
+ 
++#endif
++
+ // Local Variables:
+ // mode: C++
+ // fill-column: 76
+============================================================
+--- src/sha1.cc	5e1aa972d7c7d66e06320b039989652b830dcd75
++++ src/sha1.cc	42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
+@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
+   Botan::Default_Benchmark_Timer timer;
+   std::map<std::string, double> results =
+     Botan::algorithm_benchmark("SHA-1",  milliseconds, timer, rng, af);
++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
++  std::map<std::string, double> results =
++    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
+ #else
+   std::map<std::string, double> results =
+-    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
++    Botan::algorithm_benchmark("SHA-1",  af, rng, milliseconds, 16);
+ #endif
+ 
+   for(std::map<std::string, double>::const_iterator i = results.begin();
+============================================================
+--- src/ssh_agent.cc	6d188e7012a0b82f782563b09bbd7adf3f70cf75
++++ src/ssh_agent.cc	4a0dcab873559e934e41c5f220b5434d35600d9b
+@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
+ ssh_agent::has_key(const keypair & key)
+ {
+   //grab the monotone public key as an RSA_PublicKey
+-  SecureVector<Botan::byte> pub_block;
+-  pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
+-                (key.pub)().size());
++  SecureVector<Botan::byte> pub_block
++    (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
++     (key.pub)().size());
+   L(FL("has_key: building %d-byte pub key") % pub_block.size());
+   shared_ptr<X509_PublicKey> x509_key =
+     shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
+============================================================
+--- src/transforms.cc	cdfb6854ef4992faba21074145f3c8269b845b11
++++ src/transforms.cc	b99278ffe95c0081bf4986bc74d3699c37a52948
+@@ -53,15 +53,16 @@ using Botan::Hash_Filter;
+ // paradigm "must" be used. this program is intended for source code
+ // control and I make no bones about it.
+ 
+-NORETURN(static inline void error_in_transform(Botan::Exception & e));
++NORETURN(static inline void error_in_transform(std::exception & e));
+ 
+ static inline void
+-error_in_transform(Botan::Exception & e, origin::type caused_by)
++error_in_transform(std::exception & e, origin::type caused_by)
+ {
+   // these classes can all indicate data corruption
+   if (typeid(e) == typeid(Botan::Encoding_Error)
+       || typeid(e) == typeid(Botan::Decoding_Error)
+       || typeid(e) == typeid(Botan::Stream_IO_Error)
++      || typeid(e) == typeid(Botan::Invalid_Argument)
+       || typeid(e) == typeid(Botan::Integrity_Failure))
+     {
+       // clean up the what() string a little: throw away the
+@@ -107,7 +108,7 @@ error_in_transform(Botan::Exception & e,
+         pipe->process_msg(in);                                  \
+         out = pipe->read_all_as_string(Pipe::LAST_MESSAGE);     \
+       }                                                         \
+-    catch (Botan::Exception & e)                                \
++    catch (std::exception & e)                                   \
+       {                                                         \
+         pipe.reset(new Pipe(new T(carg)));                      \
+         error_in_transform(e, made_from);                       \
+@@ -173,7 +174,7 @@ template<> string xform<Botan::Hex_Decod
+             {
+               throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
+             }
+-          catch(Botan::Exception & e)
++          catch(std::exception & e)
+             {
+               error_in_transform(e, made_from);
+             }
+@@ -219,7 +220,7 @@ void pack(T const & in, base64< gzip<T> 
+       tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
+       out = base64< gzip<T> >(tmp, in.made_from);
+     }
+-  catch (Botan::Exception & e)
++  catch (std::exception & e)
+     {
+       pipe.reset(new Pipe(new Gzip_Compression,
+                           new Base64_Encoder));
+@@ -237,7 +238,7 @@ void unpack(base64< gzip<T> > const & in
+       pipe->process_msg(in());
+       out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
+     }
+-  catch (Botan::Exception & e)
++  catch (std::exception & e)
+     {
+       pipe.reset(new Pipe(new Base64_Decoder,
+                           new Gzip_Decompression));
+@@ -264,7 +265,7 @@ calculate_ident(data const & dat,
+       p->process_msg(dat());
+       ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
+     }
+-  catch (Botan::Exception & e)
++  catch (std::exception & e)
+     {
+       p.reset(new Pipe(new Hash_Filter("SHA-160")));
+       error_in_transform(e, dat.made_from);
--- monotone-1.0_3.patch ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->madpilot 
Responsible-Changed-By: madpilot 
Responsible-Changed-When: Mon May 20 14:16:50 UTC 2013 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178316 

From: Lapo Luchini <lapo@lapo.it>
To: bug-followup@FreeBSD.org
Cc: Lapo Luchini <lapo@lapo.it>, Guido Falsi <madpilot@FreeBSD.org>
Subject: Re: ports/178316: [MAINTAINER] devel/monotone: prepare for botan 1.10.x
Date: Tue, 21 May 2013 16:33:38 +0200 (CEST)

 >Submitter-Id:	current-users
 >Originator:	Lapo Luchini
 >Organization:	
 >Confidential:	no 
 >Synopsis:	Re: ports/178316: [MAINTAINER] devel/monotone: prepare for botan 1.10.x
 >Severity:	non-critical
 >Priority:	low
 >Category:	ports 
 >Class:		maintainer-update
 >Release:	FreeBSD 8.3-RELEASE-p3 amd64
 >Environment:
 System: FreeBSD lapo.andxor.it 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #0: Tue Jun 12 00:39:29 UTC 2012
 >Description:
 
 Patch updated to fix a few errors and use the new security/botan110 port.
 (the files.* patch is unchanged, as that makes monotone compatible with both botan-1.8 and botan-1.10)
 
 This patch also available (and tested) on RedPorts:
 https://redports.org/browser/lapo/devel/monotone?rev=12349
 
 Generated with FreeBSD Port Tools 0.99_7 (mode: change, diff: ports)
 >How-To-Repeat:
 >Fix:
 
 --- monotone-1.0_3.patch begins here ---
 diff -ruN /usr/ports/devel/monotone/Makefile ./Makefile
 --- /usr/ports/devel/monotone/Makefile	2013-04-27 10:50:46.000000000 +0200
 +++ ./Makefile	2013-05-21 11:25:17.046323817 +0200
 @@ -1,9 +1,9 @@
  # Created by: Mark A. Wicks <mwicks@kettering.edu>
 -# $FreeBSD: devel/monotone/Makefile 316654 2013-04-27 08:50:46Z mva $
 +# $FreeBSD: ports/devel/monotone/Makefile,v 1.54 2012/02/14 12:45:17 mm Exp $
  
  PORTNAME=	monotone
  PORTVERSION=	1.0
 -PORTREVISION=	2
 +PORTREVISION=	3
  CATEGORIES=	devel
  MASTER_SITES=	http://www.monotone.ca/downloads/${PORTVERSION}/
  
 @@ -14,10 +14,10 @@
  LICENSE_FILE=	${WRKSRC}/COPYING
  
  BUILD_DEPENDS=	${LOCALBASE}/include/boost/shared_ptr.hpp:${PORTSDIR}/devel/boost-libs
 -LIB_DEPENDS=	pcre.3:${PORTSDIR}/devel/pcre \
 -		idn.17:${PORTSDIR}/dns/libidn \
 -		sqlite3.8:${PORTSDIR}/databases/sqlite3 \
 -		botan.0:${PORTSDIR}/security/botan
 +LIB_DEPENDS=	pcre:${PORTSDIR}/devel/pcre \
 +		idn:${PORTSDIR}/dns/libidn \
 +		sqlite3:${PORTSDIR}/databases/sqlite3 \
 +		botan:${PORTSDIR}/security/botan110
  
  SUB_FILES=	pkg-message
  USE_BZIP2=	yes
 @@ -57,28 +57,24 @@
  .endif
  PORTDOCS=	*
  
 -.include <bsd.port.options.mk>
 +.include <bsd.port.pre.mk>
  
 -.if ${ARCH} == amd64
 -USE_GCC=	4.2+
 -.endif
 -
 -.if ${PORT_OPTIONS:MNLS}
 -USES+=	gettext
 +.if defined(WITHOUT_NLS)
 +CONFIGURE_ARGS+=	--disable-nls
 +.else
 +USES+=		gettext
  PLIST_FILES+=	share/locale/de/LC_MESSAGES/monotone.mo \
  		share/locale/fr/LC_MESSAGES/monotone.mo \
  		share/locale/it/LC_MESSAGES/monotone.mo \
  		share/locale/pt/LC_MESSAGES/monotone.mo \
  		share/locale/sv/LC_MESSAGES/monotone.mo
 -.else
 -CONFIGURE_ARGS+=	--disable-nls
  .endif
  
  post-extract:
  	@${RM} -f ${WRKSRC}/monotone.info*
  
  post-patch:
 -.if ! ${PORT_OPTIONS:MDOCS}
 +.if defined(NOPORTDOCS)
  	${REINPLACE_CMD} -Ee '/^install-(contrib|examples)-data:/{' -e 'n' -e 'd' -e '}' ${WRKSRC}/Makefile.in
  .endif
  .if defined(NO_INSTALL_MANPAGES)
 @@ -89,16 +85,16 @@
  	${REINPLACE_CMD} -e "s/\"lua/\"lua-${LUA_VER}/g" \
  		-e "s/\"idn/\"libidn/g" \
  		-e "s/\"pcre/\"libpcre/g" \
 -		-e "s/\"botan/\"botan-1.8/g" \
 +		-e "s/\"botan/\"botan-1.10/g" \
  		${WRKSRC}/configure
  
  post-install:
  	${MKDIR} ${PREFIX}/share/zsh/site-functions
  	${INSTALL_DATA} ${WRKSRC}/contrib/monotone.zsh_completion ${PREFIX}/share/zsh/site-functions/_mtn
 -.if ${PORT_OPTIONS:MDOCS}
 +.if !defined(NOPORTDOCS)
  	${MKDIR} ${DOCSDIR}
  	cd ${WRKSRC} && ${INSTALL_DATA} NEWS UPGRADE ${DOCSDIR}
  .endif
  	@${CAT} ${PKGMESSAGE}
  
 -.include <bsd.port.mk>
 +.include <bsd.port.post.mk>
 diff -ruN /usr/ports/devel/monotone/files/patch-botan.diff ./files/patch-botan.diff
 --- /usr/ports/devel/monotone/files/patch-botan.diff	1970-01-01 01:00:00.000000000 +0100
 +++ ./files/patch-botan.diff	2013-05-21 10:03:53.258171493 +0200
 @@ -0,0 +1,679 @@
 +# patch to allow compatibility with Botan 1.10.x
 +# obtained from upstream repository with the following command:
 +# mtn diff -r 7cbb20501714be7f25f30734da82d41c7ac427ca -r 555bc063aee165fc7500cc68df5d818dcaf30913
 +#
 +# patch "src/database.cc"
 +#  from [4c259f963c440fc95564dfec99b2f832f0bad643]
 +#    to [87efeeff2d3263ba98af684a4022f1897434ed2d]
 +# 
 +# patch "src/gzip.cc"
 +#  from [e7c19bee910e3d421fd073933810ec52092b1d9b]
 +#    to [9da41f6820cdf39707b22c716e3682e0fa0fd745]
 +# 
 +# patch "src/gzip.hh"
 +#  from [649dfc0b250954f39c0f73870f8bec3f32f7fa43]
 +#    to [aff9da63bb22366bccf69c2d75ee7790406d2455]
 +# 
 +# patch "src/key_packet.cc"
 +#  from [d1306df89dd684badac02c03744cd446381c07d3]
 +#    to [c97262d161b23c9640972188979669b3e95afe7b]
 +# 
 +# patch "src/key_store.cc"
 +#  from [64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e]
 +#    to [b7859345f7c665914d16357409bdff24a48b7996]
 +# 
 +# patch "src/monotone.cc"
 +#  from [a25ecdd170a601db798b63a60add7681609a34c4]
 +#    to [764bc9ca406b41d21efd552a0d810bc2849e0588]
 +# 
 +# patch "src/packet.cc"
 +#  from [f61360ed2524fdf53411bd24d022a2a3c9e6e9c7]
 +#    to [571ff6eae1d269a146da74f2730b70376957d3bb]
 +# 
 +# patch "src/packet.hh"
 +#  from [0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b]
 +#    to [9c43d30145f0292d6ceda5e717e366fdead5a4d6]
 +# 
 +# patch "src/sha1.cc"
 +#  from [5e1aa972d7c7d66e06320b039989652b830dcd75]
 +#    to [42e48b22fd88b25e0d38d4f91e1f13f8a83c7120]
 +# 
 +# patch "src/ssh_agent.cc"
 +#  from [6d188e7012a0b82f782563b09bbd7adf3f70cf75]
 +#    to [4a0dcab873559e934e41c5f220b5434d35600d9b]
 +# 
 +# patch "src/transforms.cc"
 +#  from [cdfb6854ef4992faba21074145f3c8269b845b11]
 +#    to [b99278ffe95c0081bf4986bc74d3699c37a52948]
 +#
 +============================================================
 +--- src/database.cc	4c259f963c440fc95564dfec99b2f832f0bad643
 ++++ src/database.cc	87efeeff2d3263ba98af684a4022f1897434ed2d
 +@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
 +   rsa_pub_key pub;
 +   get_key(pub_id, pub);
 + 
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                pub().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +   shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +   shared_ptr<RSA_PublicKey> pub_key
 +@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
 +   else
 +     {
 +       rsa_pub_key pub;
 +-      SecureVector<Botan::byte> pub_block;
 + 
 +       if (!public_key_exists(id))
 +         return cert_unknown;
 + 
 +       get_key(id, pub);
 +-      pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                    pub().size());
 ++      SecureVector<Botan::byte> pub_block
 ++        (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +       L(FL("building verifier for %d-byte pub key") % pub_block.size());
 +       shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/gzip.cc	e7c19bee910e3d421fd073933810ec52092b1d9b
 ++++ src/gzip.cc	9da41f6820cdf39707b22c716e3682e0fa0fd745
 +@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
 +    if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Compression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
 + /*************************************************
 + * Compress Input with Gzip                       *
 + *************************************************/
 +-void Gzip_Compression::write(const byte input[], u32bit length)
 ++void Gzip_Compression::write(const byte input[], filter_length_t length)
 +    {
 + 
 +    count += length;
 +@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte 
 +       zlib->stream.avail_out = buffer.size();
 +       int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 +    }
 +@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
 +       zlib->stream.avail_out = buffer.size();
 +       rc = deflate(&(zlib->stream), Z_FINISH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression finishing deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 + 
 +@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
 +    {
 +    if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
 +-      throw Exception("DEFAULT_BUFFERSIZE is too small");
 ++      throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
 + 
 +    zlib = new Zlib_Stream;
 + 
 +@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    if(inflateInit2(&(zlib->stream), -15) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Decompression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
 + void Gzip_Decompression::start_msg()
 +    {
 +    if (!no_writes)
 +-      throw Exception("Gzip_Decompression: start_msg after already writing");
 ++      throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
 + 
 +    pipe.start_msg();
 +    datacount = 0;
 +@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
 + /*************************************************
 + * Decompress Input with Gzip                     *
 + *************************************************/
 +-void Gzip_Decompression::write(const byte input[], u32bit length)
 ++void Gzip_Decompression::write(const byte input[], filter_length_t length)
 +    {
 +    if(length) no_writes = false;
 + 
 +@@ -277,15 +277,16 @@ void Gzip_Decompression::write(const byt
 +          u32bit eat_len = eat_footer(input, length);
 +          input += eat_len;
 +          length -= eat_len;
 +-         if (length == 0)
 +-            return;
 +       }
 + 
 ++   if (length == 0)
 ++     return;
 ++
 +    // Check the gzip header
 +    if (pos < sizeof(GZIP::GZIP_HEADER))
 +       {
 +-      u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
 +-      u32bit cmplen = len;
 ++      filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
 ++      filter_length_t cmplen = len;
 +       // The last byte is the OS flag - we don't care about that
 +       if (pos + len - 1 >= GZIP::HEADER_POS_OS)
 +          cmplen--;
 +@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
 +          if(rc == Z_NEED_DICT)
 +             throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
 +          if(rc == Z_MEM_ERROR)
 +-            throw Exception("Gzip_Decompression: Memory allocation error");
 +-         throw Exception("Gzip_Decompression: Unknown decompress error");
 ++            throw Memory_Exhaustion();
 ++         throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
 +          }
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +@@ -346,8 +347,14 @@ u32bit Gzip_Decompression::eat_footer(co
 +       if (footer.size() >= GZIP::FOOTER_LENGTH)
 +          throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
 ++                                static_cast<size_t>(length));
 ++      footer += std::make_pair(input, eat_len);
 ++#else
 +       u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
 +       footer.append(input, eat_len);
 ++#endif
 + 
 +       if (footer.size() == GZIP::FOOTER_LENGTH)
 +          {
 +@@ -364,7 +371,7 @@ void Gzip_Decompression::check_footer()
 + void Gzip_Decompression::check_footer()
 +    {
 +    if (footer.size() != GZIP::FOOTER_LENGTH)
 +-      throw Exception("Gzip_Decompression: Error finalizing decompression");
 ++      throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
 + 
 +    pipe.end_msg();
 + 
 +@@ -377,7 +384,12 @@ void Gzip_Decompression::check_footer()
 +   for (int i = 0; i < 4; i++)
 +      buf[3-i] = tmpbuf[i];
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  tmpbuf.resize(4);
 ++  tmpbuf.copy(footer.begin(), 4);
 ++#else
 +   tmpbuf.set(footer.begin(), 4);
 ++#endif
 +   if (buf != tmpbuf)
 +       throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
 + 
 +@@ -400,7 +412,7 @@ void Gzip_Decompression::end_msg()
 +    // read, clear() will reset no_writes
 +    if(no_writes) return;
 + 
 +-   throw Exception("Gzip_Decompression: didn't find footer");
 ++   throw Decoding_Error("Gzip_Decompression: didn't find footer");
 + 
 +    }
 + 
 +@@ -412,7 +424,11 @@ void Gzip_Decompression::clear()
 +    no_writes = true;
 +    inflateReset(&(zlib->stream));
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++   footer.clear();
 ++#else
 +    footer.destroy();
 ++#endif
 +    pos = 0;
 +    datacount = 0;
 +    }
 +============================================================
 +--- src/gzip.hh	649dfc0b250954f39c0f73870f8bec3f32f7fa43
 ++++ src/gzip.hh	aff9da63bb22366bccf69c2d75ee7790406d2455
 +@@ -7,11 +7,18 @@
 + #ifndef BOTAN_EXT_GZIP_H__
 + #define BOTAN_EXT_GZIP_H__
 + 
 ++#include <botan/version.h>
 + #include <botan/filter.h>
 + #include <botan/pipe.h>
 + 
 + namespace Botan {
 + 
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
 ++// implementation something compatible to work with.
 ++typedef std::bad_alloc Memory_Exhaustion;
 ++#endif
 ++
 + namespace GZIP {
 + 
 +    /* A basic header - we only need to set the IDs and compression method */
 +@@ -30,13 +37,19 @@ namespace GZIP {
 + 
 + }
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++typedef size_t filter_length_t;
 ++#else
 ++typedef u32bit filter_length_t;
 ++#endif
 ++
 + /*************************************************
 + * Gzip Compression Filter                        *
 + *************************************************/
 + class Gzip_Compression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Compression"; }
 +@@ -60,7 +73,7 @@ class Gzip_Decompression : public Filter
 + class Gzip_Decompression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Decompression"; }
 +============================================================
 +--- src/key_packet.cc	d1306df89dd684badac02c03744cd446381c07d3
 ++++ src/key_packet.cc	c97262d161b23c9640972188979669b3e95afe7b
 +@@ -106,8 +106,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +============================================================
 +--- src/key_store.cc	64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
 ++++ src/key_store.cc	b7859345f7c665914d16357409bdff24a48b7996
 +@@ -572,13 +572,21 @@ 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)
 ++#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (Botan::Invalid_Argument & e)
 ++#else
 +   catch (Botan::Exception & e)
 ++#endif
 +     {
 +       L(FL("failed to load key with no passphrase: %s") % e.what());
 + 
 +@@ -605,13 +613,18 @@ key_store_state::decrypt_private_key(key
 +           {
 +             Botan::DataSource_Memory ds(kp.priv());
 + #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
 +-            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
 ++            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
 ++                                                   phrase()));
 + #else
 +             pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
 + #endif
 +             break;
 +           }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++        catch (Botan::Invalid_Argument)
 ++#else
 +         catch (Botan::Exception & e)
 ++#endif
 +           {
 +             cycles++;
 +             L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
 +@@ -822,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
 +       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
 +                          plain.size());
 +     }
 +-  catch (Botan::Exception & ex)
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (std::exception & e)
 ++#else
 ++  catch (Botan::Exception & e)
 ++#endif
 +     {
 +       E(false, ciphertext.made_from,
 +-        F("Botan error decrypting data: '%s'") % ex.what());
 ++        F("Botan error decrypting data: '%s'") % e.what());
 +     }
 + }
 + 
 +@@ -856,9 +873,9 @@ key_store::make_signature(database & db,
 +     {
 +       if (agent.connected()) {
 +         //grab the monotone public key as an RSA_PublicKey
 +-        SecureVector<Botan::byte> pub_block;
 +-        pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
 +-                      key.pub().size());
 ++        SecureVector<Botan::byte> pub_block
 ++          (reinterpret_cast<Botan::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 =
 +           shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +@@ -1031,8 +1048,14 @@ key_store_state::migrate_old_key_pair
 +   for (;;)
 +     try
 +       {
 ++#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()),
 ++                      phrase().size());
 ++#else
 +         arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
 +                      phrase().size());
 ++#endif
 + 
 +         Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
 + 
 +@@ -1051,7 +1074,11 @@ key_store_state::migrate_old_key_pair
 + #endif
 +         break;
 +       }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++    catch (Botan::Invalid_Argument & e)
 ++#else
 +     catch (Botan::Exception & e)
 ++#endif
 +       {
 +         L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
 +           % cycles % e.what());
 +============================================================
 +--- src/monotone.cc	a25ecdd170a601db798b63a60add7681609a34c4
 ++++ src/monotone.cc	764bc9ca406b41d21efd552a0d810bc2849e0588
 +@@ -156,27 +156,53 @@ cpp_main(int argc, char ** argv)
 +       E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
 +         F("monotone does not support Botan 1.7.14"));
 + 
 +-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
 ++      // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
 ++      // se. As 1.10.1 is already out, let's simply disable support for
 ++      // that specific (testing) version of botan.
 ++      E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
 ++        F("monotone does not support Botan 1.9.9"));
 ++
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
 ++      // motonote binary compiled against botan younger than 1.7.7
 +       E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
 +         F("this monotone binary requires Botan 1.6.3 or newer"));
 +-      E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 +-        F("this monotone binary does not work with Botan newer than 1.7.6"));
 +-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 ++        F("this monotone binary does not work with Botan 1.7.7 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
 ++      // motonote binary compiled against botan 1.7.7 - 1.7.21
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 +         F("this monotone binary requires Botan 1.7.7 or newer"));
 +-      // While compiling against 1.7.22 or newer is recommended, because
 +-      // it enables new features of Botan, the monotone binary compiled
 +-      // against Botan 1.7.21 and before should still work with newer Botan
 +-      // versions, including all of the stable branch 1.8.x.
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 +-#else
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 ++      // While compiling against 1.7.22 or newer is recommended, because it
 ++      // enables new features of Botan, the monotone binary compiled against
 ++      // Botan 1.7.21 and before should still work with newer Botan version,
 ++      // including all of the stable branch 1.8.x, up to and including
 ++      // 1.9.3.
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++      // motonote binary compiled against botan 1.7.22 - 1.9.3
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 +         F("this monotone binary requires Botan 1.7.22 or newer"));
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      // motonote binary compiled against botan 1.9.4 - 1.9.10
 ++#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary requires Botan 1.9.4 or newer"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.11 or newer"));
 ++
 ++#else
 ++      // motonote binary compiled against botan 1.9.11 and newer
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary requires Botan 1.9.11 or newer"));
 + #endif
 + 
 ++
 +       app_state app;
 +       try
 +         {
 +============================================================
 +--- src/packet.cc	f61360ed2524fdf53411bd24d022a2a3c9e6e9c7
 ++++ src/packet.cc	571ff6eae1d269a146da74f2730b70376957d3bb
 +@@ -156,8 +156,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +@@ -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,16 @@ read_packets(istream & in, packet_consum
 +   return count;
 + }
 + 
 ++// Dummy User_Interface implementation for Botan
 ++#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("Passphrase required");
 ++}
 ++#endif
 + 
 +-
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/packet.hh	0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
 ++++ src/packet.hh	9c43d30145f0292d6ceda5e717e366fdead5a4d6
 +@@ -10,6 +10,10 @@
 + #ifndef __PACKET_HH__
 + #define __PACKET_HH__
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++#include <botan/ui.h>
 ++#endif
 ++
 + #include "vocab.hh"
 + 
 + struct cert;
 +@@ -84,8 +88,23 @@ 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)
 ++// A helper class implementing Botan::User_Interface - which doesn't really
 ++// interface with the user, but provides the necessary plumbing for Botan.
 ++//
 ++// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
 ++typedef std::runtime_error Passphrase_Required;
 ++
 ++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;
 ++};
 + #endif
 + 
 ++#endif
 ++
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/sha1.cc	5e1aa972d7c7d66e06320b039989652b830dcd75
 ++++ src/sha1.cc	42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
 +@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
 +   Botan::Default_Benchmark_Timer timer;
 +   std::map<std::string, double> results =
 +     Botan::algorithm_benchmark("SHA-1",  milliseconds, timer, rng, af);
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  std::map<std::string, double> results =
 ++    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 + #else
 +   std::map<std::string, double> results =
 +-    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 ++    Botan::algorithm_benchmark("SHA-1",  af, rng, milliseconds, 16);
 + #endif
 + 
 +   for(std::map<std::string, double>::const_iterator i = results.begin();
 +============================================================
 +--- src/ssh_agent.cc	6d188e7012a0b82f782563b09bbd7adf3f70cf75
 ++++ src/ssh_agent.cc	4a0dcab873559e934e41c5f220b5434d35600d9b
 +@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
 + ssh_agent::has_key(const keypair & key)
 + {
 +   //grab the monotone public key as an RSA_PublicKey
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 +-                (key.pub)().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 ++     (key.pub)().size());
 +   L(FL("has_key: building %d-byte pub key") % pub_block.size());
 +   shared_ptr<X509_PublicKey> x509_key =
 +     shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/transforms.cc	cdfb6854ef4992faba21074145f3c8269b845b11
 ++++ src/transforms.cc	b99278ffe95c0081bf4986bc74d3699c37a52948
 +@@ -53,15 +53,16 @@ using Botan::Hash_Filter;
 + // paradigm "must" be used. this program is intended for source code
 + // control and I make no bones about it.
 + 
 +-NORETURN(static inline void error_in_transform(Botan::Exception & e));
 ++NORETURN(static inline void error_in_transform(std::exception & e));
 + 
 + static inline void
 +-error_in_transform(Botan::Exception & e, origin::type caused_by)
 ++error_in_transform(std::exception & e, origin::type caused_by)
 + {
 +   // these classes can all indicate data corruption
 +   if (typeid(e) == typeid(Botan::Encoding_Error)
 +       || typeid(e) == typeid(Botan::Decoding_Error)
 +       || typeid(e) == typeid(Botan::Stream_IO_Error)
 ++      || typeid(e) == typeid(Botan::Invalid_Argument)
 +       || typeid(e) == typeid(Botan::Integrity_Failure))
 +     {
 +       // clean up the what() string a little: throw away the
 +@@ -107,7 +108,7 @@ error_in_transform(Botan::Exception & e,
 +         pipe->process_msg(in);                                  \
 +         out = pipe->read_all_as_string(Pipe::LAST_MESSAGE);     \
 +       }                                                         \
 +-    catch (Botan::Exception & e)                                \
 ++    catch (std::exception & e)                                   \
 +       {                                                         \
 +         pipe.reset(new Pipe(new T(carg)));                      \
 +         error_in_transform(e, made_from);                       \
 +@@ -173,7 +174,7 @@ template<> string xform<Botan::Hex_Decod
 +             {
 +               throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
 +             }
 +-          catch(Botan::Exception & e)
 ++          catch(std::exception & e)
 +             {
 +               error_in_transform(e, made_from);
 +             }
 +@@ -219,7 +220,7 @@ void pack(T const & in, base64< gzip<T> 
 +       tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
 +       out = base64< gzip<T> >(tmp, in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Gzip_Compression,
 +                           new Base64_Encoder));
 +@@ -237,7 +238,7 @@ void unpack(base64< gzip<T> > const & in
 +       pipe->process_msg(in());
 +       out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Base64_Decoder,
 +                           new Gzip_Decompression));
 +@@ -264,7 +265,7 @@ calculate_ident(data const & dat,
 +       p->process_msg(dat());
 +       ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       p.reset(new Pipe(new Hash_Filter("SHA-160")));
 +       error_in_transform(e, dat.made_from);
 --- monotone-1.0_3.patch ends here ---
 

From: Guido Falsi <mad@madpilot.net>
To: bug-followup@FreeBSD.org, lapo@lapo.it
Cc:  
Subject: Re: ports/178316: [MAINTAINER] devel/monotone: prepare for botan
 1.10.x
Date: Wed, 22 May 2013 00:59:48 +0200

 This is a multi-part message in MIME format.
 --------------000601070404060303050602
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hi,
 
 I fixed a pair of things in the patch.
 
 I made sure the order of -I to the cmpileer command line is correct to 
 make it use the new botan port mainly.
 
 The other changes we already discussed via IM.
 
 Can you approve this patch?
 
 Thanks.
 
 
 -- 
 Guido Falsi <mad@madpilot.net>
 
 --------------000601070404060303050602
 Content-Type: text/x-patch;
  name="monotone.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="monotone.diff"
 
 Index: Makefile
 ===================================================================
 --- Makefile	(revision 318654)
 +++ Makefile	(working copy)
 @@ -3,7 +3,7 @@
  
  PORTNAME=	monotone
  PORTVERSION=	1.0
 -PORTREVISION=	2
 +PORTREVISION=	3
  CATEGORIES=	devel
  MASTER_SITES=	http://www.monotone.ca/downloads/${PORTVERSION}/
  
 @@ -14,10 +14,10 @@
  LICENSE_FILE=	${WRKSRC}/COPYING
  
  BUILD_DEPENDS=	${LOCALBASE}/include/boost/shared_ptr.hpp:${PORTSDIR}/devel/boost-libs
 -LIB_DEPENDS=	pcre.3:${PORTSDIR}/devel/pcre \
 -		idn.17:${PORTSDIR}/dns/libidn \
 -		sqlite3.8:${PORTSDIR}/databases/sqlite3 \
 -		botan.0:${PORTSDIR}/security/botan
 +LIB_DEPENDS=	pcre:${PORTSDIR}/devel/pcre \
 +		idn:${PORTSDIR}/dns/libidn \
 +		sqlite3:${PORTSDIR}/databases/sqlite3 \
 +		botan-1.10:${PORTSDIR}/security/botan110
  
  SUB_FILES=	pkg-message
  USE_BZIP2=	yes
 @@ -25,11 +25,10 @@
  USES=		iconv
  USE_GMAKE=	yes
  USE_LUA=	5.1+
 +MAKE_JOBS_SAFE=	yes
  
  GNU_CONFIGURE=	yes
  CONFIGURE_ENV=	MAKEINFO="makeinfo --no-split"
 -CPPFLAGS+=	-I${LOCALBASE}/include
 -LDFLAGS+=	-L${LOCALBASE}/lib
  
  PLIST_FILES=	bin/mtn bin/mtn-cleanup bin/mtnopt \
  		share/monotone/hooks/authorize_remote_automate.lua \
 @@ -59,10 +58,6 @@
  
  .include <bsd.port.options.mk>
  
 -.if ${ARCH} == amd64
 -USE_GCC=	4.2+
 -.endif
 -
  .if ${PORT_OPTIONS:MNLS}
  USES+=	gettext
  PLIST_FILES+=	share/locale/de/LC_MESSAGES/monotone.mo \
 @@ -89,7 +84,7 @@
  	${REINPLACE_CMD} -e "s/\"lua/\"lua-${LUA_VER}/g" \
  		-e "s/\"idn/\"libidn/g" \
  		-e "s/\"pcre/\"libpcre/g" \
 -		-e "s/\"botan/\"botan-1.8/g" \
 +		-e "s/\"botan/\"botan-1.10/g" \
  		${WRKSRC}/configure
  
  post-install:
 Index: files/patch-Makefile.in
 ===================================================================
 --- files/patch-Makefile.in	(revision 0)
 +++ files/patch-Makefile.in	(working copy)
 @@ -0,0 +1,11 @@
 +--- Makefile.in.orig	2011-03-26 10:43:10.000000000 +0100
 ++++ Makefile.in	2013-05-22 00:42:41.059149227 +0200
 +@@ -976,7 +976,7 @@
 + @BUILD_PCH_TRUE@PCH_FILE = $(PCH_BUILD).gch
 + AM_CXXFLAGS = $(PCH_FLAGS)
 + SUFFIXES = .gch .merged.po .gmo
 +-AM_CPPFLAGS = $(intl_CFLAGS) $(pcre_CFLAGS) $(botan_CFLAGS) \
 ++AM_CPPFLAGS = $(botan_CFLAGS) $(intl_CFLAGS) $(pcre_CFLAGS) \
 + 	$(lua_CFLAGS) $(sqlite3_CFLAGS) $(idn_CFLAGS) $(am__append_4) \
 + 	$(am__append_10) $(am__append_12) $(am__append_15)
 + LDADD = src/libplatform.a src/lib3rdparty.a $(intl_LIBS) $(pcre_LIBS) \
 
 Property changes on: files/patch-Makefile.in
 ___________________________________________________________________
 Added: svn:mime-type
 ## -0,0 +1 ##
 +text/plain
 \ No newline at end of property
 Added: fbsd:nokeywords
 ## -0,0 +1 ##
 +yes
 \ No newline at end of property
 Added: svn:eol-style
 ## -0,0 +1 ##
 +native
 \ No newline at end of property
 Index: files/patch-botan.diff
 ===================================================================
 --- files/patch-botan.diff	(revision 0)
 +++ files/patch-botan.diff	(working copy)
 @@ -0,0 +1,631 @@
 +============================================================
 +--- src/database.cc	4c259f963c440fc95564dfec99b2f832f0bad643
 ++++ src/database.cc	87efeeff2d3263ba98af684a4022f1897434ed2d
 +@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
 +   rsa_pub_key pub;
 +   get_key(pub_id, pub);
 + 
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                pub().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +   shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +   shared_ptr<RSA_PublicKey> pub_key
 +@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
 +   else
 +     {
 +       rsa_pub_key pub;
 +-      SecureVector<Botan::byte> pub_block;
 + 
 +       if (!public_key_exists(id))
 +         return cert_unknown;
 + 
 +       get_key(id, pub);
 +-      pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                    pub().size());
 ++      SecureVector<Botan::byte> pub_block
 ++        (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +       L(FL("building verifier for %d-byte pub key") % pub_block.size());
 +       shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/gzip.cc	e7c19bee910e3d421fd073933810ec52092b1d9b
 ++++ src/gzip.cc	9da41f6820cdf39707b22c716e3682e0fa0fd745
 +@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
 +    if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Compression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
 + /*************************************************
 + * Compress Input with Gzip                       *
 + *************************************************/
 +-void Gzip_Compression::write(const byte input[], u32bit length)
 ++void Gzip_Compression::write(const byte input[], filter_length_t length)
 +    {
 + 
 +    count += length;
 +@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte 
 +       zlib->stream.avail_out = buffer.size();
 +       int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 +    }
 +@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
 +       zlib->stream.avail_out = buffer.size();
 +       rc = deflate(&(zlib->stream), Z_FINISH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression finishing deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 + 
 +@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
 +    {
 +    if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
 +-      throw Exception("DEFAULT_BUFFERSIZE is too small");
 ++      throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
 + 
 +    zlib = new Zlib_Stream;
 + 
 +@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    if(inflateInit2(&(zlib->stream), -15) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Decompression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
 + void Gzip_Decompression::start_msg()
 +    {
 +    if (!no_writes)
 +-      throw Exception("Gzip_Decompression: start_msg after already writing");
 ++      throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
 + 
 +    pipe.start_msg();
 +    datacount = 0;
 +@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
 + /*************************************************
 + * Decompress Input with Gzip                     *
 + *************************************************/
 +-void Gzip_Decompression::write(const byte input[], u32bit length)
 ++void Gzip_Decompression::write(const byte input[], filter_length_t length)
 +    {
 +    if(length) no_writes = false;
 + 
 +@@ -277,15 +277,16 @@ void Gzip_Decompression::write(const byt
 +          u32bit eat_len = eat_footer(input, length);
 +          input += eat_len;
 +          length -= eat_len;
 +-         if (length == 0)
 +-            return;
 +       }
 + 
 ++   if (length == 0)
 ++     return;
 ++
 +    // Check the gzip header
 +    if (pos < sizeof(GZIP::GZIP_HEADER))
 +       {
 +-      u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
 +-      u32bit cmplen = len;
 ++      filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
 ++      filter_length_t cmplen = len;
 +       // The last byte is the OS flag - we don't care about that
 +       if (pos + len - 1 >= GZIP::HEADER_POS_OS)
 +          cmplen--;
 +@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
 +          if(rc == Z_NEED_DICT)
 +             throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
 +          if(rc == Z_MEM_ERROR)
 +-            throw Exception("Gzip_Decompression: Memory allocation error");
 +-         throw Exception("Gzip_Decompression: Unknown decompress error");
 ++            throw Memory_Exhaustion();
 ++         throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
 +          }
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +@@ -346,8 +347,14 @@ u32bit Gzip_Decompression::eat_footer(co
 +       if (footer.size() >= GZIP::FOOTER_LENGTH)
 +          throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
 ++                                static_cast<size_t>(length));
 ++      footer += std::make_pair(input, eat_len);
 ++#else
 +       u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
 +       footer.append(input, eat_len);
 ++#endif
 + 
 +       if (footer.size() == GZIP::FOOTER_LENGTH)
 +          {
 +@@ -364,7 +371,7 @@ void Gzip_Decompression::check_footer()
 + void Gzip_Decompression::check_footer()
 +    {
 +    if (footer.size() != GZIP::FOOTER_LENGTH)
 +-      throw Exception("Gzip_Decompression: Error finalizing decompression");
 ++      throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
 + 
 +    pipe.end_msg();
 + 
 +@@ -377,7 +384,12 @@ void Gzip_Decompression::check_footer()
 +   for (int i = 0; i < 4; i++)
 +      buf[3-i] = tmpbuf[i];
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  tmpbuf.resize(4);
 ++  tmpbuf.copy(footer.begin(), 4);
 ++#else
 +   tmpbuf.set(footer.begin(), 4);
 ++#endif
 +   if (buf != tmpbuf)
 +       throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
 + 
 +@@ -400,7 +412,7 @@ void Gzip_Decompression::end_msg()
 +    // read, clear() will reset no_writes
 +    if(no_writes) return;
 + 
 +-   throw Exception("Gzip_Decompression: didn't find footer");
 ++   throw Decoding_Error("Gzip_Decompression: didn't find footer");
 + 
 +    }
 + 
 +@@ -412,7 +424,11 @@ void Gzip_Decompression::clear()
 +    no_writes = true;
 +    inflateReset(&(zlib->stream));
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++   footer.clear();
 ++#else
 +    footer.destroy();
 ++#endif
 +    pos = 0;
 +    datacount = 0;
 +    }
 +============================================================
 +--- src/gzip.hh	649dfc0b250954f39c0f73870f8bec3f32f7fa43
 ++++ src/gzip.hh	aff9da63bb22366bccf69c2d75ee7790406d2455
 +@@ -7,11 +7,18 @@
 + #ifndef BOTAN_EXT_GZIP_H__
 + #define BOTAN_EXT_GZIP_H__
 + 
 ++#include <botan/version.h>
 + #include <botan/filter.h>
 + #include <botan/pipe.h>
 + 
 + namespace Botan {
 + 
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
 ++// implementation something compatible to work with.
 ++typedef std::bad_alloc Memory_Exhaustion;
 ++#endif
 ++
 + namespace GZIP {
 + 
 +    /* A basic header - we only need to set the IDs and compression method */
 +@@ -30,13 +37,19 @@ namespace GZIP {
 + 
 + }
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++typedef size_t filter_length_t;
 ++#else
 ++typedef u32bit filter_length_t;
 ++#endif
 ++
 + /*************************************************
 + * Gzip Compression Filter                        *
 + *************************************************/
 + class Gzip_Compression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Compression"; }
 +@@ -60,7 +73,7 @@ class Gzip_Decompression : public Filter
 + class Gzip_Decompression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Decompression"; }
 +============================================================
 +--- src/key_packet.cc	d1306df89dd684badac02c03744cd446381c07d3
 ++++ src/key_packet.cc	c97262d161b23c9640972188979669b3e95afe7b
 +@@ -106,8 +106,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +============================================================
 +--- src/key_store.cc	64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
 ++++ src/key_store.cc	b7859345f7c665914d16357409bdff24a48b7996
 +@@ -572,13 +572,21 @@ 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)
 ++#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (Botan::Invalid_Argument & e)
 ++#else
 +   catch (Botan::Exception & e)
 ++#endif
 +     {
 +       L(FL("failed to load key with no passphrase: %s") % e.what());
 + 
 +@@ -605,13 +613,18 @@ key_store_state::decrypt_private_key(key
 +           {
 +             Botan::DataSource_Memory ds(kp.priv());
 + #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
 +-            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
 ++            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
 ++                                                   phrase()));
 + #else
 +             pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
 + #endif
 +             break;
 +           }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++        catch (Botan::Invalid_Argument)
 ++#else
 +         catch (Botan::Exception & e)
 ++#endif
 +           {
 +             cycles++;
 +             L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
 +@@ -822,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
 +       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
 +                          plain.size());
 +     }
 +-  catch (Botan::Exception & ex)
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (std::exception & e)
 ++#else
 ++  catch (Botan::Exception & e)
 ++#endif
 +     {
 +       E(false, ciphertext.made_from,
 +-        F("Botan error decrypting data: '%s'") % ex.what());
 ++        F("Botan error decrypting data: '%s'") % e.what());
 +     }
 + }
 + 
 +@@ -856,9 +873,9 @@ key_store::make_signature(database & db,
 +     {
 +       if (agent.connected()) {
 +         //grab the monotone public key as an RSA_PublicKey
 +-        SecureVector<Botan::byte> pub_block;
 +-        pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
 +-                      key.pub().size());
 ++        SecureVector<Botan::byte> pub_block
 ++          (reinterpret_cast<Botan::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 =
 +           shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +@@ -1031,8 +1048,14 @@ key_store_state::migrate_old_key_pair
 +   for (;;)
 +     try
 +       {
 ++#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()),
 ++                      phrase().size());
 ++#else
 +         arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
 +                      phrase().size());
 ++#endif
 + 
 +         Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
 + 
 +@@ -1051,7 +1074,11 @@ key_store_state::migrate_old_key_pair
 + #endif
 +         break;
 +       }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++    catch (Botan::Invalid_Argument & e)
 ++#else
 +     catch (Botan::Exception & e)
 ++#endif
 +       {
 +         L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
 +           % cycles % e.what());
 +============================================================
 +--- src/monotone.cc	a25ecdd170a601db798b63a60add7681609a34c4
 ++++ src/monotone.cc	764bc9ca406b41d21efd552a0d810bc2849e0588
 +@@ -156,27 +156,53 @@ cpp_main(int argc, char ** argv)
 +       E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
 +         F("monotone does not support Botan 1.7.14"));
 + 
 +-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
 ++      // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
 ++      // se. As 1.10.1 is already out, let's simply disable support for
 ++      // that specific (testing) version of botan.
 ++      E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
 ++        F("monotone does not support Botan 1.9.9"));
 ++
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
 ++      // motonote binary compiled against botan younger than 1.7.7
 +       E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
 +         F("this monotone binary requires Botan 1.6.3 or newer"));
 +-      E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 +-        F("this monotone binary does not work with Botan newer than 1.7.6"));
 +-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 ++        F("this monotone binary does not work with Botan 1.7.7 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
 ++      // motonote binary compiled against botan 1.7.7 - 1.7.21
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 +         F("this monotone binary requires Botan 1.7.7 or newer"));
 +-      // While compiling against 1.7.22 or newer is recommended, because
 +-      // it enables new features of Botan, the monotone binary compiled
 +-      // against Botan 1.7.21 and before should still work with newer Botan
 +-      // versions, including all of the stable branch 1.8.x.
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 +-#else
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 ++      // While compiling against 1.7.22 or newer is recommended, because it
 ++      // enables new features of Botan, the monotone binary compiled against
 ++      // Botan 1.7.21 and before should still work with newer Botan version,
 ++      // including all of the stable branch 1.8.x, up to and including
 ++      // 1.9.3.
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++      // motonote binary compiled against botan 1.7.22 - 1.9.3
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 +         F("this monotone binary requires Botan 1.7.22 or newer"));
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      // motonote binary compiled against botan 1.9.4 - 1.9.10
 ++#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary requires Botan 1.9.4 or newer"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.11 or newer"));
 ++
 ++#else
 ++      // motonote binary compiled against botan 1.9.11 and newer
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary requires Botan 1.9.11 or newer"));
 + #endif
 + 
 ++
 +       app_state app;
 +       try
 +         {
 +============================================================
 +--- src/packet.cc	f61360ed2524fdf53411bd24d022a2a3c9e6e9c7
 ++++ src/packet.cc	571ff6eae1d269a146da74f2730b70376957d3bb
 +@@ -156,8 +156,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +@@ -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,16 @@ read_packets(istream & in, packet_consum
 +   return count;
 + }
 + 
 ++// Dummy User_Interface implementation for Botan
 ++#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("Passphrase required");
 ++}
 ++#endif
 + 
 +-
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/packet.hh	0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
 ++++ src/packet.hh	9c43d30145f0292d6ceda5e717e366fdead5a4d6
 +@@ -10,6 +10,10 @@
 + #ifndef __PACKET_HH__
 + #define __PACKET_HH__
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++#include <botan/ui.h>
 ++#endif
 ++
 + #include "vocab.hh"
 + 
 + struct cert;
 +@@ -84,8 +88,23 @@ 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)
 ++// A helper class implementing Botan::User_Interface - which doesn't really
 ++// interface with the user, but provides the necessary plumbing for Botan.
 ++//
 ++// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
 ++typedef std::runtime_error Passphrase_Required;
 ++
 ++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;
 ++};
 + #endif
 + 
 ++#endif
 ++
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/sha1.cc	5e1aa972d7c7d66e06320b039989652b830dcd75
 ++++ src/sha1.cc	42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
 +@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
 +   Botan::Default_Benchmark_Timer timer;
 +   std::map<std::string, double> results =
 +     Botan::algorithm_benchmark("SHA-1",  milliseconds, timer, rng, af);
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  std::map<std::string, double> results =
 ++    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 + #else
 +   std::map<std::string, double> results =
 +-    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 ++    Botan::algorithm_benchmark("SHA-1",  af, rng, milliseconds, 16);
 + #endif
 + 
 +   for(std::map<std::string, double>::const_iterator i = results.begin();
 +============================================================
 +--- src/ssh_agent.cc	6d188e7012a0b82f782563b09bbd7adf3f70cf75
 ++++ src/ssh_agent.cc	4a0dcab873559e934e41c5f220b5434d35600d9b
 +@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
 + ssh_agent::has_key(const keypair & key)
 + {
 +   //grab the monotone public key as an RSA_PublicKey
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 +-                (key.pub)().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 ++     (key.pub)().size());
 +   L(FL("has_key: building %d-byte pub key") % pub_block.size());
 +   shared_ptr<X509_PublicKey> x509_key =
 +     shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/transforms.cc	cdfb6854ef4992faba21074145f3c8269b845b11
 ++++ src/transforms.cc	b99278ffe95c0081bf4986bc74d3699c37a52948
 +@@ -53,15 +53,16 @@ using Botan::Hash_Filter;
 + // paradigm "must" be used. this program is intended for source code
 + // control and I make no bones about it.
 + 
 +-NORETURN(static inline void error_in_transform(Botan::Exception & e));
 ++NORETURN(static inline void error_in_transform(std::exception & e));
 + 
 + static inline void
 +-error_in_transform(Botan::Exception & e, origin::type caused_by)
 ++error_in_transform(std::exception & e, origin::type caused_by)
 + {
 +   // these classes can all indicate data corruption
 +   if (typeid(e) == typeid(Botan::Encoding_Error)
 +       || typeid(e) == typeid(Botan::Decoding_Error)
 +       || typeid(e) == typeid(Botan::Stream_IO_Error)
 ++      || typeid(e) == typeid(Botan::Invalid_Argument)
 +       || typeid(e) == typeid(Botan::Integrity_Failure))
 +     {
 +       // clean up the what() string a little: throw away the
 +@@ -107,7 +108,7 @@ error_in_transform(Botan::Exception & e,
 +         pipe->process_msg(in);                                  \
 +         out = pipe->read_all_as_string(Pipe::LAST_MESSAGE);     \
 +       }                                                         \
 +-    catch (Botan::Exception & e)                                \
 ++    catch (std::exception & e)                                   \
 +       {                                                         \
 +         pipe.reset(new Pipe(new T(carg)));                      \
 +         error_in_transform(e, made_from);                       \
 +@@ -173,7 +174,7 @@ template<> string xform<Botan::Hex_Decod
 +             {
 +               throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
 +             }
 +-          catch(Botan::Exception & e)
 ++          catch(std::exception & e)
 +             {
 +               error_in_transform(e, made_from);
 +             }
 +@@ -219,7 +220,7 @@ void pack(T const & in, base64< gzip<T> 
 +       tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
 +       out = base64< gzip<T> >(tmp, in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Gzip_Compression,
 +                           new Base64_Encoder));
 +@@ -237,7 +238,7 @@ void unpack(base64< gzip<T> > const & in
 +       pipe->process_msg(in());
 +       out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Base64_Decoder,
 +                           new Gzip_Decompression));
 +@@ -264,7 +265,7 @@ calculate_ident(data const & dat,
 +       p->process_msg(dat());
 +       ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       p.reset(new Pipe(new Hash_Filter("SHA-160")));
 +       error_in_transform(e, dat.made_from);
 
 Property changes on: files/patch-botan.diff
 ___________________________________________________________________
 Added: svn:mime-type
 ## -0,0 +1 ##
 +text/plain
 \ No newline at end of property
 Added: fbsd:nokeywords
 ## -0,0 +1 ##
 +yes
 \ No newline at end of property
 Added: svn:eol-style
 ## -0,0 +1 ##
 +native
 \ No newline at end of property
 
 --------------000601070404060303050602--

From: Guido Falsi <madpilot@FreeBSD.org>
To: bug-followup@FreeBSD.org, lapo@lapo.it
Cc:  
Subject: Re: ports/178316: [MAINTAINER] devel/monotone: prepare for botan
 1.10.x
Date: Wed, 22 May 2013 01:17:59 +0200

 This is a multi-part message in MIME format.
 --------------050904060704040408040508
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Please disregard the previous patch. This one is the correct one.
 
 -- 
 Guido Falsi <madpilot@FreeBSD.org>
 
 --------------050904060704040408040508
 Content-Type: text/x-patch;
  name="monotone.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="monotone.diff"
 
 Index: Makefile
 ===================================================================
 --- Makefile	(revision 318654)
 +++ Makefile	(working copy)
 @@ -3,7 +3,7 @@
  
  PORTNAME=	monotone
  PORTVERSION=	1.0
 -PORTREVISION=	2
 +PORTREVISION=	3
  CATEGORIES=	devel
  MASTER_SITES=	http://www.monotone.ca/downloads/${PORTVERSION}/
  
 @@ -14,10 +14,10 @@
  LICENSE_FILE=	${WRKSRC}/COPYING
  
  BUILD_DEPENDS=	${LOCALBASE}/include/boost/shared_ptr.hpp:${PORTSDIR}/devel/boost-libs
 -LIB_DEPENDS=	pcre.3:${PORTSDIR}/devel/pcre \
 -		idn.17:${PORTSDIR}/dns/libidn \
 -		sqlite3.8:${PORTSDIR}/databases/sqlite3 \
 -		botan.0:${PORTSDIR}/security/botan
 +LIB_DEPENDS=	pcre:${PORTSDIR}/devel/pcre \
 +		idn:${PORTSDIR}/dns/libidn \
 +		sqlite3:${PORTSDIR}/databases/sqlite3 \
 +		botan-1.10:${PORTSDIR}/security/botan110
  
  SUB_FILES=	pkg-message
  USE_BZIP2=	yes
 @@ -25,6 +25,7 @@
  USES=		iconv
  USE_GMAKE=	yes
  USE_LUA=	5.1+
 +MAKE_JOBS_SAFE=	yes
  
  GNU_CONFIGURE=	yes
  CONFIGURE_ENV=	MAKEINFO="makeinfo --no-split"
 @@ -59,10 +60,6 @@
  
  .include <bsd.port.options.mk>
  
 -.if ${ARCH} == amd64
 -USE_GCC=	4.2+
 -.endif
 -
  .if ${PORT_OPTIONS:MNLS}
  USES+=	gettext
  PLIST_FILES+=	share/locale/de/LC_MESSAGES/monotone.mo \
 @@ -89,7 +86,7 @@
  	${REINPLACE_CMD} -e "s/\"lua/\"lua-${LUA_VER}/g" \
  		-e "s/\"idn/\"libidn/g" \
  		-e "s/\"pcre/\"libpcre/g" \
 -		-e "s/\"botan/\"botan-1.8/g" \
 +		-e "s/\"botan/\"botan-1.10/g" \
  		${WRKSRC}/configure
  
  post-install:
 Index: files/patch-Makefile.in
 ===================================================================
 --- files/patch-Makefile.in	(revision 0)
 +++ files/patch-Makefile.in	(working copy)
 @@ -0,0 +1,11 @@
 +--- Makefile.in.orig	2011-03-26 10:43:10.000000000 +0100
 ++++ Makefile.in	2013-05-22 00:42:41.059149227 +0200
 +@@ -976,7 +976,7 @@
 + @BUILD_PCH_TRUE@PCH_FILE = $(PCH_BUILD).gch
 + AM_CXXFLAGS = $(PCH_FLAGS)
 + SUFFIXES = .gch .merged.po .gmo
 +-AM_CPPFLAGS = $(intl_CFLAGS) $(pcre_CFLAGS) $(botan_CFLAGS) \
 ++AM_CPPFLAGS = $(botan_CFLAGS) $(intl_CFLAGS) $(pcre_CFLAGS) \
 + 	$(lua_CFLAGS) $(sqlite3_CFLAGS) $(idn_CFLAGS) $(am__append_4) \
 + 	$(am__append_10) $(am__append_12) $(am__append_15)
 + LDADD = src/libplatform.a src/lib3rdparty.a $(intl_LIBS) $(pcre_LIBS) \
 
 Property changes on: files/patch-Makefile.in
 ___________________________________________________________________
 Added: svn:mime-type
 ## -0,0 +1 ##
 +text/plain
 \ No newline at end of property
 Added: fbsd:nokeywords
 ## -0,0 +1 ##
 +yes
 \ No newline at end of property
 Added: svn:eol-style
 ## -0,0 +1 ##
 +native
 \ No newline at end of property
 Index: files/patch-botan.diff
 ===================================================================
 --- files/patch-botan.diff	(revision 0)
 +++ files/patch-botan.diff	(working copy)
 @@ -0,0 +1,631 @@
 +============================================================
 +--- src/database.cc	4c259f963c440fc95564dfec99b2f832f0bad643
 ++++ src/database.cc	87efeeff2d3263ba98af684a4022f1897434ed2d
 +@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
 +   rsa_pub_key pub;
 +   get_key(pub_id, pub);
 + 
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                pub().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +   shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +   shared_ptr<RSA_PublicKey> pub_key
 +@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
 +   else
 +     {
 +       rsa_pub_key pub;
 +-      SecureVector<Botan::byte> pub_block;
 + 
 +       if (!public_key_exists(id))
 +         return cert_unknown;
 + 
 +       get_key(id, pub);
 +-      pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                    pub().size());
 ++      SecureVector<Botan::byte> pub_block
 ++        (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +       L(FL("building verifier for %d-byte pub key") % pub_block.size());
 +       shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/gzip.cc	e7c19bee910e3d421fd073933810ec52092b1d9b
 ++++ src/gzip.cc	9da41f6820cdf39707b22c716e3682e0fa0fd745
 +@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
 +    if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Compression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
 + /*************************************************
 + * Compress Input with Gzip                       *
 + *************************************************/
 +-void Gzip_Compression::write(const byte input[], u32bit length)
 ++void Gzip_Compression::write(const byte input[], filter_length_t length)
 +    {
 + 
 +    count += length;
 +@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte 
 +       zlib->stream.avail_out = buffer.size();
 +       int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 +    }
 +@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
 +       zlib->stream.avail_out = buffer.size();
 +       rc = deflate(&(zlib->stream), Z_FINISH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression finishing deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 + 
 +@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
 +    {
 +    if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
 +-      throw Exception("DEFAULT_BUFFERSIZE is too small");
 ++      throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
 + 
 +    zlib = new Zlib_Stream;
 + 
 +@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    if(inflateInit2(&(zlib->stream), -15) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Decompression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
 + void Gzip_Decompression::start_msg()
 +    {
 +    if (!no_writes)
 +-      throw Exception("Gzip_Decompression: start_msg after already writing");
 ++      throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
 + 
 +    pipe.start_msg();
 +    datacount = 0;
 +@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
 + /*************************************************
 + * Decompress Input with Gzip                     *
 + *************************************************/
 +-void Gzip_Decompression::write(const byte input[], u32bit length)
 ++void Gzip_Decompression::write(const byte input[], filter_length_t length)
 +    {
 +    if(length) no_writes = false;
 + 
 +@@ -277,15 +277,16 @@ void Gzip_Decompression::write(const byt
 +          u32bit eat_len = eat_footer(input, length);
 +          input += eat_len;
 +          length -= eat_len;
 +-         if (length == 0)
 +-            return;
 +       }
 + 
 ++   if (length == 0)
 ++     return;
 ++
 +    // Check the gzip header
 +    if (pos < sizeof(GZIP::GZIP_HEADER))
 +       {
 +-      u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
 +-      u32bit cmplen = len;
 ++      filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
 ++      filter_length_t cmplen = len;
 +       // The last byte is the OS flag - we don't care about that
 +       if (pos + len - 1 >= GZIP::HEADER_POS_OS)
 +          cmplen--;
 +@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
 +          if(rc == Z_NEED_DICT)
 +             throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
 +          if(rc == Z_MEM_ERROR)
 +-            throw Exception("Gzip_Decompression: Memory allocation error");
 +-         throw Exception("Gzip_Decompression: Unknown decompress error");
 ++            throw Memory_Exhaustion();
 ++         throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
 +          }
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +@@ -346,8 +347,14 @@ u32bit Gzip_Decompression::eat_footer(co
 +       if (footer.size() >= GZIP::FOOTER_LENGTH)
 +          throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
 ++                                static_cast<size_t>(length));
 ++      footer += std::make_pair(input, eat_len);
 ++#else
 +       u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
 +       footer.append(input, eat_len);
 ++#endif
 + 
 +       if (footer.size() == GZIP::FOOTER_LENGTH)
 +          {
 +@@ -364,7 +371,7 @@ void Gzip_Decompression::check_footer()
 + void Gzip_Decompression::check_footer()
 +    {
 +    if (footer.size() != GZIP::FOOTER_LENGTH)
 +-      throw Exception("Gzip_Decompression: Error finalizing decompression");
 ++      throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
 + 
 +    pipe.end_msg();
 + 
 +@@ -377,7 +384,12 @@ void Gzip_Decompression::check_footer()
 +   for (int i = 0; i < 4; i++)
 +      buf[3-i] = tmpbuf[i];
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  tmpbuf.resize(4);
 ++  tmpbuf.copy(footer.begin(), 4);
 ++#else
 +   tmpbuf.set(footer.begin(), 4);
 ++#endif
 +   if (buf != tmpbuf)
 +       throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
 + 
 +@@ -400,7 +412,7 @@ void Gzip_Decompression::end_msg()
 +    // read, clear() will reset no_writes
 +    if(no_writes) return;
 + 
 +-   throw Exception("Gzip_Decompression: didn't find footer");
 ++   throw Decoding_Error("Gzip_Decompression: didn't find footer");
 + 
 +    }
 + 
 +@@ -412,7 +424,11 @@ void Gzip_Decompression::clear()
 +    no_writes = true;
 +    inflateReset(&(zlib->stream));
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++   footer.clear();
 ++#else
 +    footer.destroy();
 ++#endif
 +    pos = 0;
 +    datacount = 0;
 +    }
 +============================================================
 +--- src/gzip.hh	649dfc0b250954f39c0f73870f8bec3f32f7fa43
 ++++ src/gzip.hh	aff9da63bb22366bccf69c2d75ee7790406d2455
 +@@ -7,11 +7,18 @@
 + #ifndef BOTAN_EXT_GZIP_H__
 + #define BOTAN_EXT_GZIP_H__
 + 
 ++#include <botan/version.h>
 + #include <botan/filter.h>
 + #include <botan/pipe.h>
 + 
 + namespace Botan {
 + 
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
 ++// implementation something compatible to work with.
 ++typedef std::bad_alloc Memory_Exhaustion;
 ++#endif
 ++
 + namespace GZIP {
 + 
 +    /* A basic header - we only need to set the IDs and compression method */
 +@@ -30,13 +37,19 @@ namespace GZIP {
 + 
 + }
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++typedef size_t filter_length_t;
 ++#else
 ++typedef u32bit filter_length_t;
 ++#endif
 ++
 + /*************************************************
 + * Gzip Compression Filter                        *
 + *************************************************/
 + class Gzip_Compression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Compression"; }
 +@@ -60,7 +73,7 @@ class Gzip_Decompression : public Filter
 + class Gzip_Decompression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Decompression"; }
 +============================================================
 +--- src/key_packet.cc	d1306df89dd684badac02c03744cd446381c07d3
 ++++ src/key_packet.cc	c97262d161b23c9640972188979669b3e95afe7b
 +@@ -106,8 +106,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +============================================================
 +--- src/key_store.cc	64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
 ++++ src/key_store.cc	b7859345f7c665914d16357409bdff24a48b7996
 +@@ -572,13 +572,21 @@ 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)
 ++#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (Botan::Invalid_Argument & e)
 ++#else
 +   catch (Botan::Exception & e)
 ++#endif
 +     {
 +       L(FL("failed to load key with no passphrase: %s") % e.what());
 + 
 +@@ -605,13 +613,18 @@ key_store_state::decrypt_private_key(key
 +           {
 +             Botan::DataSource_Memory ds(kp.priv());
 + #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
 +-            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
 ++            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
 ++                                                   phrase()));
 + #else
 +             pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
 + #endif
 +             break;
 +           }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++        catch (Botan::Invalid_Argument)
 ++#else
 +         catch (Botan::Exception & e)
 ++#endif
 +           {
 +             cycles++;
 +             L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
 +@@ -822,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
 +       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
 +                          plain.size());
 +     }
 +-  catch (Botan::Exception & ex)
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (std::exception & e)
 ++#else
 ++  catch (Botan::Exception & e)
 ++#endif
 +     {
 +       E(false, ciphertext.made_from,
 +-        F("Botan error decrypting data: '%s'") % ex.what());
 ++        F("Botan error decrypting data: '%s'") % e.what());
 +     }
 + }
 + 
 +@@ -856,9 +873,9 @@ key_store::make_signature(database & db,
 +     {
 +       if (agent.connected()) {
 +         //grab the monotone public key as an RSA_PublicKey
 +-        SecureVector<Botan::byte> pub_block;
 +-        pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
 +-                      key.pub().size());
 ++        SecureVector<Botan::byte> pub_block
 ++          (reinterpret_cast<Botan::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 =
 +           shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +@@ -1031,8 +1048,14 @@ key_store_state::migrate_old_key_pair
 +   for (;;)
 +     try
 +       {
 ++#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()),
 ++                      phrase().size());
 ++#else
 +         arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
 +                      phrase().size());
 ++#endif
 + 
 +         Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
 + 
 +@@ -1051,7 +1074,11 @@ key_store_state::migrate_old_key_pair
 + #endif
 +         break;
 +       }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++    catch (Botan::Invalid_Argument & e)
 ++#else
 +     catch (Botan::Exception & e)
 ++#endif
 +       {
 +         L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
 +           % cycles % e.what());
 +============================================================
 +--- src/monotone.cc	a25ecdd170a601db798b63a60add7681609a34c4
 ++++ src/monotone.cc	764bc9ca406b41d21efd552a0d810bc2849e0588
 +@@ -156,27 +156,53 @@ cpp_main(int argc, char ** argv)
 +       E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
 +         F("monotone does not support Botan 1.7.14"));
 + 
 +-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
 ++      // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
 ++      // se. As 1.10.1 is already out, let's simply disable support for
 ++      // that specific (testing) version of botan.
 ++      E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
 ++        F("monotone does not support Botan 1.9.9"));
 ++
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
 ++      // motonote binary compiled against botan younger than 1.7.7
 +       E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
 +         F("this monotone binary requires Botan 1.6.3 or newer"));
 +-      E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 +-        F("this monotone binary does not work with Botan newer than 1.7.6"));
 +-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 ++        F("this monotone binary does not work with Botan 1.7.7 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
 ++      // motonote binary compiled against botan 1.7.7 - 1.7.21
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 +         F("this monotone binary requires Botan 1.7.7 or newer"));
 +-      // While compiling against 1.7.22 or newer is recommended, because
 +-      // it enables new features of Botan, the monotone binary compiled
 +-      // against Botan 1.7.21 and before should still work with newer Botan
 +-      // versions, including all of the stable branch 1.8.x.
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 +-#else
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 ++      // While compiling against 1.7.22 or newer is recommended, because it
 ++      // enables new features of Botan, the monotone binary compiled against
 ++      // Botan 1.7.21 and before should still work with newer Botan version,
 ++      // including all of the stable branch 1.8.x, up to and including
 ++      // 1.9.3.
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++      // motonote binary compiled against botan 1.7.22 - 1.9.3
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 +         F("this monotone binary requires Botan 1.7.22 or newer"));
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      // motonote binary compiled against botan 1.9.4 - 1.9.10
 ++#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary requires Botan 1.9.4 or newer"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.11 or newer"));
 ++
 ++#else
 ++      // motonote binary compiled against botan 1.9.11 and newer
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary requires Botan 1.9.11 or newer"));
 + #endif
 + 
 ++
 +       app_state app;
 +       try
 +         {
 +============================================================
 +--- src/packet.cc	f61360ed2524fdf53411bd24d022a2a3c9e6e9c7
 ++++ src/packet.cc	571ff6eae1d269a146da74f2730b70376957d3bb
 +@@ -156,8 +156,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +@@ -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,16 @@ read_packets(istream & in, packet_consum
 +   return count;
 + }
 + 
 ++// Dummy User_Interface implementation for Botan
 ++#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("Passphrase required");
 ++}
 ++#endif
 + 
 +-
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/packet.hh	0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
 ++++ src/packet.hh	9c43d30145f0292d6ceda5e717e366fdead5a4d6
 +@@ -10,6 +10,10 @@
 + #ifndef __PACKET_HH__
 + #define __PACKET_HH__
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++#include <botan/ui.h>
 ++#endif
 ++
 + #include "vocab.hh"
 + 
 + struct cert;
 +@@ -84,8 +88,23 @@ 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)
 ++// A helper class implementing Botan::User_Interface - which doesn't really
 ++// interface with the user, but provides the necessary plumbing for Botan.
 ++//
 ++// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
 ++typedef std::runtime_error Passphrase_Required;
 ++
 ++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;
 ++};
 + #endif
 + 
 ++#endif
 ++
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/sha1.cc	5e1aa972d7c7d66e06320b039989652b830dcd75
 ++++ src/sha1.cc	42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
 +@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
 +   Botan::Default_Benchmark_Timer timer;
 +   std::map<std::string, double> results =
 +     Botan::algorithm_benchmark("SHA-1",  milliseconds, timer, rng, af);
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  std::map<std::string, double> results =
 ++    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 + #else
 +   std::map<std::string, double> results =
 +-    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 ++    Botan::algorithm_benchmark("SHA-1",  af, rng, milliseconds, 16);
 + #endif
 + 
 +   for(std::map<std::string, double>::const_iterator i = results.begin();
 +============================================================
 +--- src/ssh_agent.cc	6d188e7012a0b82f782563b09bbd7adf3f70cf75
 ++++ src/ssh_agent.cc	4a0dcab873559e934e41c5f220b5434d35600d9b
 +@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
 + ssh_agent::has_key(const keypair & key)
 + {
 +   //grab the monotone public key as an RSA_PublicKey
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 +-                (key.pub)().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 ++     (key.pub)().size());
 +   L(FL("has_key: building %d-byte pub key") % pub_block.size());
 +   shared_ptr<X509_PublicKey> x509_key =
 +     shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/transforms.cc	cdfb6854ef4992faba21074145f3c8269b845b11
 ++++ src/transforms.cc	b99278ffe95c0081bf4986bc74d3699c37a52948
 +@@ -53,15 +53,16 @@ using Botan::Hash_Filter;
 + // paradigm "must" be used. this program is intended for source code
 + // control and I make no bones about it.
 + 
 +-NORETURN(static inline void error_in_transform(Botan::Exception & e));
 ++NORETURN(static inline void error_in_transform(std::exception & e));
 + 
 + static inline void
 +-error_in_transform(Botan::Exception & e, origin::type caused_by)
 ++error_in_transform(std::exception & e, origin::type caused_by)
 + {
 +   // these classes can all indicate data corruption
 +   if (typeid(e) == typeid(Botan::Encoding_Error)
 +       || typeid(e) == typeid(Botan::Decoding_Error)
 +       || typeid(e) == typeid(Botan::Stream_IO_Error)
 ++      || typeid(e) == typeid(Botan::Invalid_Argument)
 +       || typeid(e) == typeid(Botan::Integrity_Failure))
 +     {
 +       // clean up the what() string a little: throw away the
 +@@ -107,7 +108,7 @@ error_in_transform(Botan::Exception & e,
 +         pipe->process_msg(in);                                  \
 +         out = pipe->read_all_as_string(Pipe::LAST_MESSAGE);     \
 +       }                                                         \
 +-    catch (Botan::Exception & e)                                \
 ++    catch (std::exception & e)                                   \
 +       {                                                         \
 +         pipe.reset(new Pipe(new T(carg)));                      \
 +         error_in_transform(e, made_from);                       \
 +@@ -173,7 +174,7 @@ template<> string xform<Botan::Hex_Decod
 +             {
 +               throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
 +             }
 +-          catch(Botan::Exception & e)
 ++          catch(std::exception & e)
 +             {
 +               error_in_transform(e, made_from);
 +             }
 +@@ -219,7 +220,7 @@ void pack(T const & in, base64< gzip<T> 
 +       tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
 +       out = base64< gzip<T> >(tmp, in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Gzip_Compression,
 +                           new Base64_Encoder));
 +@@ -237,7 +238,7 @@ void unpack(base64< gzip<T> > const & in
 +       pipe->process_msg(in());
 +       out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Base64_Decoder,
 +                           new Gzip_Decompression));
 +@@ -264,7 +265,7 @@ calculate_ident(data const & dat,
 +       p->process_msg(dat());
 +       ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       p.reset(new Pipe(new Hash_Filter("SHA-160")));
 +       error_in_transform(e, dat.made_from);
 
 Property changes on: files/patch-botan.diff
 ___________________________________________________________________
 Added: svn:mime-type
 ## -0,0 +1 ##
 +text/plain
 \ No newline at end of property
 Added: fbsd:nokeywords
 ## -0,0 +1 ##
 +yes
 \ No newline at end of property
 Added: svn:eol-style
 ## -0,0 +1 ##
 +native
 \ No newline at end of property
 
 --------------050904060704040408040508--

From: Lapo Luchini <lapo@lapo.it>
To: Guido Falsi <madpilot@FreeBSD.org>, bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/178316: [MAINTAINER] devel/monotone: prepare for botan
 1.10.x
Date: Wed, 22 May 2013 14:31:30 +0200

 I approve.
State-Changed-From-To: open->closed 
State-Changed-By: madpilot 
State-Changed-When: Wed May 22 18:09:44 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178316 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/178316: commit references a PR
Date: Wed, 22 May 2013 18:09:41 +0000 (UTC)

 Author: madpilot
 Date: Wed May 22 18:09:24 2013
 New Revision: 318783
 URL: http://svnweb.freebsd.org/changeset/ports/318783
 
 Log:
   - Make monotone depend on new botan 1.10 port by importing a patch from upstream
   - While here mark it MAKE_JOBS_SAFE
   - Remove version numbers from LIB_DEPENDS
   - Allow the port to compile with clang on amd64
   
   PR:		ports/178316
   Submitted by:	Lapo Luchini <lapo@lapo.it> (maintainer)
 
 Added:
   head/devel/monotone/files/patch-Makefile.in   (contents, props changed)
   head/devel/monotone/files/patch-botan.diff   (contents, props changed)
 Modified:
   head/devel/monotone/Makefile
 
 Modified: head/devel/monotone/Makefile
 ==============================================================================
 --- head/devel/monotone/Makefile	Wed May 22 18:07:53 2013	(r318782)
 +++ head/devel/monotone/Makefile	Wed May 22 18:09:24 2013	(r318783)
 @@ -3,7 +3,7 @@
  
  PORTNAME=	monotone
  PORTVERSION=	1.0
 -PORTREVISION=	2
 +PORTREVISION=	3
  CATEGORIES=	devel
  MASTER_SITES=	http://www.monotone.ca/downloads/${PORTVERSION}/
  
 @@ -14,10 +14,10 @@ LICENSE=	GPLv2
  LICENSE_FILE=	${WRKSRC}/COPYING
  
  BUILD_DEPENDS=	${LOCALBASE}/include/boost/shared_ptr.hpp:${PORTSDIR}/devel/boost-libs
 -LIB_DEPENDS=	pcre.3:${PORTSDIR}/devel/pcre \
 -		idn.17:${PORTSDIR}/dns/libidn \
 -		sqlite3.8:${PORTSDIR}/databases/sqlite3 \
 -		botan.0:${PORTSDIR}/security/botan
 +LIB_DEPENDS=	pcre:${PORTSDIR}/devel/pcre \
 +		idn:${PORTSDIR}/dns/libidn \
 +		sqlite3:${PORTSDIR}/databases/sqlite3 \
 +		botan-1.10:${PORTSDIR}/security/botan110
  
  SUB_FILES=	pkg-message
  USE_BZIP2=	yes
 @@ -25,6 +25,7 @@ USE_PERL5_BUILD=yes
  USES=		iconv
  USE_GMAKE=	yes
  USE_LUA=	5.1+
 +MAKE_JOBS_SAFE=	yes
  
  GNU_CONFIGURE=	yes
  CONFIGURE_ENV=	MAKEINFO="makeinfo --no-split"
 @@ -59,10 +60,6 @@ PORTDOCS=	*
  
  .include <bsd.port.options.mk>
  
 -.if ${ARCH} == amd64
 -USE_GCC=	4.2+
 -.endif
 -
  .if ${PORT_OPTIONS:MNLS}
  USES+=	gettext
  PLIST_FILES+=	share/locale/de/LC_MESSAGES/monotone.mo \
 @@ -89,7 +86,7 @@ post-patch:
  	${REINPLACE_CMD} -e "s/\"lua/\"lua-${LUA_VER}/g" \
  		-e "s/\"idn/\"libidn/g" \
  		-e "s/\"pcre/\"libpcre/g" \
 -		-e "s/\"botan/\"botan-1.8/g" \
 +		-e "s/\"botan/\"botan-1.10/g" \
  		${WRKSRC}/configure
  
  post-install:
 
 Added: head/devel/monotone/files/patch-Makefile.in
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/devel/monotone/files/patch-Makefile.in	Wed May 22 18:09:24 2013	(r318783)
 @@ -0,0 +1,11 @@
 +--- Makefile.in.orig	2011-03-26 10:43:10.000000000 +0100
 ++++ Makefile.in	2013-05-22 00:42:41.059149227 +0200
 +@@ -976,7 +976,7 @@
 + @BUILD_PCH_TRUE@PCH_FILE = $(PCH_BUILD).gch
 + AM_CXXFLAGS = $(PCH_FLAGS)
 + SUFFIXES = .gch .merged.po .gmo
 +-AM_CPPFLAGS = $(intl_CFLAGS) $(pcre_CFLAGS) $(botan_CFLAGS) \
 ++AM_CPPFLAGS = $(botan_CFLAGS) $(intl_CFLAGS) $(pcre_CFLAGS) \
 + 	$(lua_CFLAGS) $(sqlite3_CFLAGS) $(idn_CFLAGS) $(am__append_4) \
 + 	$(am__append_10) $(am__append_12) $(am__append_15)
 + LDADD = src/libplatform.a src/lib3rdparty.a $(intl_LIBS) $(pcre_LIBS) \
 
 Added: head/devel/monotone/files/patch-botan.diff
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/devel/monotone/files/patch-botan.diff	Wed May 22 18:09:24 2013	(r318783)
 @@ -0,0 +1,631 @@
 +============================================================
 +--- src/database.cc	4c259f963c440fc95564dfec99b2f832f0bad643
 ++++ src/database.cc	87efeeff2d3263ba98af684a4022f1897434ed2d
 +@@ -3425,9 +3425,8 @@ database::encrypt_rsa(key_id const & pub
 +   rsa_pub_key pub;
 +   get_key(pub_id, pub);
 + 
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                pub().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +   shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +   shared_ptr<RSA_PublicKey> pub_key
 +@@ -3471,14 +3470,13 @@ database::check_signature(key_id const &
 +   else
 +     {
 +       rsa_pub_key pub;
 +-      SecureVector<Botan::byte> pub_block;
 + 
 +       if (!public_key_exists(id))
 +         return cert_unknown;
 + 
 +       get_key(id, pub);
 +-      pub_block.set(reinterpret_cast<Botan::byte const *>(pub().data()),
 +-                    pub().size());
 ++      SecureVector<Botan::byte> pub_block
 ++        (reinterpret_cast<Botan::byte const *>(pub().data()), pub().size());
 + 
 +       L(FL("building verifier for %d-byte pub key") % pub_block.size());
 +       shared_ptr<X509_PublicKey> x509_key(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/gzip.cc	e7c19bee910e3d421fd073933810ec52092b1d9b
 ++++ src/gzip.cc	9da41f6820cdf39707b22c716e3682e0fa0fd745
 +@@ -110,7 +110,7 @@ Gzip_Compression::Gzip_Compression(u32bi
 +    if(deflateInit2(&(zlib->stream), level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Compression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -137,7 +137,7 @@ void Gzip_Compression::start_msg()
 + /*************************************************
 + * Compress Input with Gzip                       *
 + *************************************************/
 +-void Gzip_Compression::write(const byte input[], u32bit length)
 ++void Gzip_Compression::write(const byte input[], filter_length_t length)
 +    {
 + 
 +    count += length;
 +@@ -152,7 +152,7 @@ void Gzip_Compression::write(const byte 
 +       zlib->stream.avail_out = buffer.size();
 +       int rc = deflate(&(zlib->stream), Z_NO_FLUSH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 +    }
 +@@ -172,7 +172,7 @@ void Gzip_Compression::end_msg()
 +       zlib->stream.avail_out = buffer.size();
 +       rc = deflate(&(zlib->stream), Z_FINISH);
 +       if (rc != Z_OK && rc != Z_STREAM_END)
 +-         throw Exception("Internal error in Gzip_Compression finishing deflate.");
 ++         throw Invalid_State("Internal error in Gzip_Compression finishing deflate.");
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       }
 + 
 +@@ -228,7 +228,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    no_writes(true), pipe(new Hash_Filter("CRC32")), footer(0)
 +    {
 +    if (DEFAULT_BUFFERSIZE < sizeof(GZIP::GZIP_HEADER))
 +-      throw Exception("DEFAULT_BUFFERSIZE is too small");
 ++      throw Decoding_Error("DEFAULT_BUFFERSIZE is too small");
 + 
 +    zlib = new Zlib_Stream;
 + 
 +@@ -237,7 +237,7 @@ Gzip_Decompression::Gzip_Decompression()
 +    if(inflateInit2(&(zlib->stream), -15) != Z_OK)
 +       {
 +       delete zlib; zlib = 0;
 +-      throw Exception("Gzip_Decompression: Memory allocation error");
 ++      throw Memory_Exhaustion();
 +       }
 +    }
 + 
 +@@ -256,7 +256,7 @@ void Gzip_Decompression::start_msg()
 + void Gzip_Decompression::start_msg()
 +    {
 +    if (!no_writes)
 +-      throw Exception("Gzip_Decompression: start_msg after already writing");
 ++      throw Decoding_Error("Gzip_Decompression: start_msg after already writing");
 + 
 +    pipe.start_msg();
 +    datacount = 0;
 +@@ -267,7 +267,7 @@ void Gzip_Decompression::start_msg()
 + /*************************************************
 + * Decompress Input with Gzip                     *
 + *************************************************/
 +-void Gzip_Decompression::write(const byte input[], u32bit length)
 ++void Gzip_Decompression::write(const byte input[], filter_length_t length)
 +    {
 +    if(length) no_writes = false;
 + 
 +@@ -277,15 +277,16 @@ void Gzip_Decompression::write(const byt
 +          u32bit eat_len = eat_footer(input, length);
 +          input += eat_len;
 +          length -= eat_len;
 +-         if (length == 0)
 +-            return;
 +       }
 + 
 ++   if (length == 0)
 ++     return;
 ++
 +    // Check the gzip header
 +    if (pos < sizeof(GZIP::GZIP_HEADER))
 +       {
 +-      u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length);
 +-      u32bit cmplen = len;
 ++      filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length);
 ++      filter_length_t cmplen = len;
 +       // The last byte is the OS flag - we don't care about that
 +       if (pos + len - 1 >= GZIP::HEADER_POS_OS)
 +          cmplen--;
 +@@ -317,8 +318,8 @@ void Gzip_Decompression::write(const byt
 +          if(rc == Z_NEED_DICT)
 +             throw Decoding_Error("Gzip_Decompression: Need preset dictionary");
 +          if(rc == Z_MEM_ERROR)
 +-            throw Exception("Gzip_Decompression: Memory allocation error");
 +-         throw Exception("Gzip_Decompression: Unknown decompress error");
 ++            throw Memory_Exhaustion();
 ++         throw Decoding_Error("Gzip_Decompression: Unknown decompress error");
 +          }
 +       send(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +       pipe.write(buffer.begin(), buffer.size() - zlib->stream.avail_out);
 +@@ -346,8 +347,14 @@ u32bit Gzip_Decompression::eat_footer(co
 +       if (footer.size() >= GZIP::FOOTER_LENGTH)
 +          throw Decoding_Error("Gzip_Decompression: Data integrity error in footer");
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(),
 ++                                static_cast<size_t>(length));
 ++      footer += std::make_pair(input, eat_len);
 ++#else
 +       u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length);
 +       footer.append(input, eat_len);
 ++#endif
 + 
 +       if (footer.size() == GZIP::FOOTER_LENGTH)
 +          {
 +@@ -364,7 +371,7 @@ void Gzip_Decompression::check_footer()
 + void Gzip_Decompression::check_footer()
 +    {
 +    if (footer.size() != GZIP::FOOTER_LENGTH)
 +-      throw Exception("Gzip_Decompression: Error finalizing decompression");
 ++      throw Decoding_Error("Gzip_Decompression: Error finalizing decompression");
 + 
 +    pipe.end_msg();
 + 
 +@@ -377,7 +384,12 @@ void Gzip_Decompression::check_footer()
 +   for (int i = 0; i < 4; i++)
 +      buf[3-i] = tmpbuf[i];
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  tmpbuf.resize(4);
 ++  tmpbuf.copy(footer.begin(), 4);
 ++#else
 +   tmpbuf.set(footer.begin(), 4);
 ++#endif
 +   if (buf != tmpbuf)
 +       throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error");
 + 
 +@@ -400,7 +412,7 @@ void Gzip_Decompression::end_msg()
 +    // read, clear() will reset no_writes
 +    if(no_writes) return;
 + 
 +-   throw Exception("Gzip_Decompression: didn't find footer");
 ++   throw Decoding_Error("Gzip_Decompression: didn't find footer");
 + 
 +    }
 + 
 +@@ -412,7 +424,11 @@ void Gzip_Decompression::clear()
 +    no_writes = true;
 +    inflateReset(&(zlib->stream));
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++   footer.clear();
 ++#else
 +    footer.destroy();
 ++#endif
 +    pos = 0;
 +    datacount = 0;
 +    }
 +============================================================
 +--- src/gzip.hh	649dfc0b250954f39c0f73870f8bec3f32f7fa43
 ++++ src/gzip.hh	aff9da63bb22366bccf69c2d75ee7790406d2455
 +@@ -7,11 +7,18 @@
 + #ifndef BOTAN_EXT_GZIP_H__
 + #define BOTAN_EXT_GZIP_H__
 + 
 ++#include <botan/version.h>
 + #include <botan/filter.h>
 + #include <botan/pipe.h>
 + 
 + namespace Botan {
 + 
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++// Only 1.9.4 and newer export the Memory_Exception. Give this gzip
 ++// implementation something compatible to work with.
 ++typedef std::bad_alloc Memory_Exhaustion;
 ++#endif
 ++
 + namespace GZIP {
 + 
 +    /* A basic header - we only need to set the IDs and compression method */
 +@@ -30,13 +37,19 @@ namespace GZIP {
 + 
 + }
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++typedef size_t filter_length_t;
 ++#else
 ++typedef u32bit filter_length_t;
 ++#endif
 ++
 + /*************************************************
 + * Gzip Compression Filter                        *
 + *************************************************/
 + class Gzip_Compression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Compression"; }
 +@@ -60,7 +73,7 @@ class Gzip_Decompression : public Filter
 + class Gzip_Decompression : public Filter
 +    {
 +    public:
 +-      void write(const byte input[], u32bit length);
 ++      void write(const byte input[], filter_length_t length);
 +       void start_msg();
 +       void end_msg();
 +       std::string name() const { return "Gzip_Decompression"; }
 +============================================================
 +--- src/key_packet.cc	d1306df89dd684badac02c03744cd446381c07d3
 ++++ src/key_packet.cc	c97262d161b23c9640972188979669b3e95afe7b
 +@@ -106,8 +106,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +============================================================
 +--- src/key_store.cc	64c4c4bed1fadc26b51207b9f61343f9dd7d3c6e
 ++++ src/key_store.cc	b7859345f7c665914d16357409bdff24a48b7996
 +@@ -572,13 +572,21 @@ 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)
 ++#elif BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (Botan::Invalid_Argument & e)
 ++#else
 +   catch (Botan::Exception & e)
 ++#endif
 +     {
 +       L(FL("failed to load key with no passphrase: %s") % e.what());
 + 
 +@@ -605,13 +613,18 @@ key_store_state::decrypt_private_key(key
 +           {
 +             Botan::DataSource_Memory ds(kp.priv());
 + #if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,7)
 +-            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(), phrase()));
 ++            pkcs8_key.reset(Botan::PKCS8::load_key(ds, lazy_rng::get(),
 ++                                                   phrase()));
 + #else
 +             pkcs8_key.reset(Botan::PKCS8::load_key(ds, phrase()));
 + #endif
 +             break;
 +           }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++        catch (Botan::Invalid_Argument)
 ++#else
 +         catch (Botan::Exception & e)
 ++#endif
 +           {
 +             cycles++;
 +             L(FL("decrypt_private_key: failure %d to load encrypted key: %s")
 +@@ -822,10 +835,14 @@ key_store::decrypt_rsa(key_id const & id
 +       plaintext = string(reinterpret_cast<char const*>(plain.begin()),
 +                          plain.size());
 +     }
 +-  catch (Botan::Exception & ex)
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++  catch (std::exception & e)
 ++#else
 ++  catch (Botan::Exception & e)
 ++#endif
 +     {
 +       E(false, ciphertext.made_from,
 +-        F("Botan error decrypting data: '%s'") % ex.what());
 ++        F("Botan error decrypting data: '%s'") % e.what());
 +     }
 + }
 + 
 +@@ -856,9 +873,9 @@ key_store::make_signature(database & db,
 +     {
 +       if (agent.connected()) {
 +         //grab the monotone public key as an RSA_PublicKey
 +-        SecureVector<Botan::byte> pub_block;
 +-        pub_block.set(reinterpret_cast<Botan::byte const *>(key.pub().data()),
 +-                      key.pub().size());
 ++        SecureVector<Botan::byte> pub_block
 ++          (reinterpret_cast<Botan::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 =
 +           shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +@@ -1031,8 +1048,14 @@ key_store_state::migrate_old_key_pair
 +   for (;;)
 +     try
 +       {
 ++#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()),
 ++                      phrase().size());
 ++#else
 +         arc4_key.set(reinterpret_cast<Botan::byte const *>(phrase().data()),
 +                      phrase().size());
 ++#endif
 + 
 +         Pipe arc4_decryptor(get_cipher("ARC4", arc4_key, Botan::DECRYPTION));
 + 
 +@@ -1051,7 +1074,11 @@ key_store_state::migrate_old_key_pair
 + #endif
 +         break;
 +       }
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,4)
 ++    catch (Botan::Invalid_Argument & e)
 ++#else
 +     catch (Botan::Exception & e)
 ++#endif
 +       {
 +         L(FL("migrate_old_key_pair: failure %d to load old private key: %s")
 +           % cycles % e.what());
 +============================================================
 +--- src/monotone.cc	a25ecdd170a601db798b63a60add7681609a34c4
 ++++ src/monotone.cc	764bc9ca406b41d21efd552a0d810bc2849e0588
 +@@ -156,27 +156,53 @@ cpp_main(int argc, char ** argv)
 +       E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,7,14), origin::system,
 +         F("monotone does not support Botan 1.7.14"));
 + 
 +-#if BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,6)
 ++      // In Botan 1.9.9, the DataSink_Stream cannot be instantiated per
 ++      // se. As 1.10.1 is already out, let's simply disable support for
 ++      // that specific (testing) version of botan.
 ++      E(linked_botan_version != BOTAN_VERSION_CODE_FOR(1,9,9), origin::system,
 ++        F("monotone does not support Botan 1.9.9"));
 ++
 ++#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,7)
 ++      // motonote binary compiled against botan younger than 1.7.7
 +       E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,6,3), origin::system,
 +         F("this monotone binary requires Botan 1.6.3 or newer"));
 +-      E(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 +-        F("this monotone binary does not work with Botan newer than 1.7.6"));
 +-#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22)
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), origin::system,
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 ++        F("this monotone binary does not work with Botan 1.7.7 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,7,22)
 ++      // motonote binary compiled against botan 1.7.7 - 1.7.21
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,7), origin::system,
 +         F("this monotone binary requires Botan 1.7.7 or newer"));
 +-      // While compiling against 1.7.22 or newer is recommended, because
 +-      // it enables new features of Botan, the monotone binary compiled
 +-      // against Botan 1.7.21 and before should still work with newer Botan
 +-      // versions, including all of the stable branch 1.8.x.
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 +-#else
 +-      E(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 ++      // While compiling against 1.7.22 or newer is recommended, because it
 ++      // enables new features of Botan, the monotone binary compiled against
 ++      // Botan 1.7.21 and before should still work with newer Botan version,
 ++      // including all of the stable branch 1.8.x, up to and including
 ++      // 1.9.3.
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,4)
 ++      // motonote binary compiled against botan 1.7.22 - 1.9.3
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,7,22), origin::system,
 +         F("this monotone binary requires Botan 1.7.22 or newer"));
 +-      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), origin::system,
 +-        F("this monotone binary does not work with Botan 1.9.x"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.4 or newer"));
 ++
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++      // motonote binary compiled against botan 1.9.4 - 1.9.10
 ++#pragma message ( "The resulting monotone binary won't be able to run with any stable release of botan." )
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,4), origin::system,
 ++        F("this monotone binary requires Botan 1.9.4 or newer"));
 ++      E(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary does not work with Botan 1.9.11 or newer"));
 ++
 ++#else
 ++      // motonote binary compiled against botan 1.9.11 and newer
 ++      E(linked_botan_version >= BOTAN_VERSION_CODE_FOR(1,9,11), origin::system,
 ++        F("this monotone binary requires Botan 1.9.11 or newer"));
 + #endif
 + 
 ++
 +       app_state app;
 +       try
 +         {
 +============================================================
 +--- src/packet.cc	f61360ed2524fdf53411bd24d022a2a3c9e6e9c7
 ++++ src/packet.cc	571ff6eae1d269a146da74f2730b70376957d3bb
 +@@ -156,8 +156,8 @@ namespace
 +     void validate_public_key_data(string const & name, string const & keydata) const
 +     {
 +       string decoded = decode_base64_as<string>(keydata, origin::user);
 +-      Botan::SecureVector<Botan::byte> key_block;
 +-      key_block.set(reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 ++      Botan::SecureVector<Botan::byte> key_block
 ++        (reinterpret_cast<Botan::byte const *>(decoded.c_str()), decoded.size());
 +       try
 +         {
 +           Botan::X509::load_key(key_block);
 +@@ -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,16 @@ read_packets(istream & in, packet_consum
 +   return count;
 + }
 + 
 ++// Dummy User_Interface implementation for Botan
 ++#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("Passphrase required");
 ++}
 ++#endif
 + 
 +-
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/packet.hh	0a224e6e92f244e2c3e9a5cdb935eb8613d7e85b
 ++++ src/packet.hh	9c43d30145f0292d6ceda5e717e366fdead5a4d6
 +@@ -10,6 +10,10 @@
 + #ifndef __PACKET_HH__
 + #define __PACKET_HH__
 + 
 ++#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11)
 ++#include <botan/ui.h>
 ++#endif
 ++
 + #include "vocab.hh"
 + 
 + struct cert;
 +@@ -84,8 +88,23 @@ 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)
 ++// A helper class implementing Botan::User_Interface - which doesn't really
 ++// interface with the user, but provides the necessary plumbing for Botan.
 ++//
 ++// See Botan commit 2d09d7d0cd4bd0e7155d001dd65a4f29103b158c
 ++typedef std::runtime_error Passphrase_Required;
 ++
 ++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;
 ++};
 + #endif
 + 
 ++#endif
 ++
 + // Local Variables:
 + // mode: C++
 + // fill-column: 76
 +============================================================
 +--- src/sha1.cc	5e1aa972d7c7d66e06320b039989652b830dcd75
 ++++ src/sha1.cc	42e48b22fd88b25e0d38d4f91e1f13f8a83c7120
 +@@ -50,9 +50,12 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh
 +   Botan::Default_Benchmark_Timer timer;
 +   std::map<std::string, double> results =
 +     Botan::algorithm_benchmark("SHA-1",  milliseconds, timer, rng, af);
 ++#elif BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR(1,9,11)
 ++  std::map<std::string, double> results =
 ++    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 + #else
 +   std::map<std::string, double> results =
 +-    Botan::algorithm_benchmark("SHA-1",  milliseconds, rng, af);
 ++    Botan::algorithm_benchmark("SHA-1",  af, rng, milliseconds, 16);
 + #endif
 + 
 +   for(std::map<std::string, double>::const_iterator i = results.begin();
 +============================================================
 +--- src/ssh_agent.cc	6d188e7012a0b82f782563b09bbd7adf3f70cf75
 ++++ src/ssh_agent.cc	4a0dcab873559e934e41c5f220b5434d35600d9b
 +@@ -385,9 +385,9 @@ ssh_agent::has_key(const keypair & key)
 + ssh_agent::has_key(const keypair & key)
 + {
 +   //grab the monotone public key as an RSA_PublicKey
 +-  SecureVector<Botan::byte> pub_block;
 +-  pub_block.set(reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 +-                (key.pub)().size());
 ++  SecureVector<Botan::byte> pub_block
 ++    (reinterpret_cast<Botan::byte const *>((key.pub)().data()),
 ++     (key.pub)().size());
 +   L(FL("has_key: building %d-byte pub key") % pub_block.size());
 +   shared_ptr<X509_PublicKey> x509_key =
 +     shared_ptr<X509_PublicKey>(Botan::X509::load_key(pub_block));
 +============================================================
 +--- src/transforms.cc	cdfb6854ef4992faba21074145f3c8269b845b11
 ++++ src/transforms.cc	b99278ffe95c0081bf4986bc74d3699c37a52948
 +@@ -53,15 +53,16 @@ using Botan::Hash_Filter;
 + // paradigm "must" be used. this program is intended for source code
 + // control and I make no bones about it.
 + 
 +-NORETURN(static inline void error_in_transform(Botan::Exception & e));
 ++NORETURN(static inline void error_in_transform(std::exception & e));
 + 
 + static inline void
 +-error_in_transform(Botan::Exception & e, origin::type caused_by)
 ++error_in_transform(std::exception & e, origin::type caused_by)
 + {
 +   // these classes can all indicate data corruption
 +   if (typeid(e) == typeid(Botan::Encoding_Error)
 +       || typeid(e) == typeid(Botan::Decoding_Error)
 +       || typeid(e) == typeid(Botan::Stream_IO_Error)
 ++      || typeid(e) == typeid(Botan::Invalid_Argument)
 +       || typeid(e) == typeid(Botan::Integrity_Failure))
 +     {
 +       // clean up the what() string a little: throw away the
 +@@ -107,7 +108,7 @@ error_in_transform(Botan::Exception & e,
 +         pipe->process_msg(in);                                  \
 +         out = pipe->read_all_as_string(Pipe::LAST_MESSAGE);     \
 +       }                                                         \
 +-    catch (Botan::Exception & e)                                \
 ++    catch (std::exception & e)                                   \
 +       {                                                         \
 +         pipe.reset(new Pipe(new T(carg)));                      \
 +         error_in_transform(e, made_from);                       \
 +@@ -173,7 +174,7 @@ template<> string xform<Botan::Hex_Decod
 +             {
 +               throw Botan::Decoding_Error(string("invalid hex character '") + (char)c + "'");
 +             }
 +-          catch(Botan::Exception & e)
 ++          catch(std::exception & e)
 +             {
 +               error_in_transform(e, made_from);
 +             }
 +@@ -219,7 +220,7 @@ void pack(T const & in, base64< gzip<T> 
 +       tmp = pipe->read_all_as_string(Pipe::LAST_MESSAGE);
 +       out = base64< gzip<T> >(tmp, in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Gzip_Compression,
 +                           new Base64_Encoder));
 +@@ -237,7 +238,7 @@ void unpack(base64< gzip<T> > const & in
 +       pipe->process_msg(in());
 +       out = T(pipe->read_all_as_string(Pipe::LAST_MESSAGE), in.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       pipe.reset(new Pipe(new Base64_Decoder,
 +                           new Gzip_Decompression));
 +@@ -264,7 +265,7 @@ calculate_ident(data const & dat,
 +       p->process_msg(dat());
 +       ident = id(p->read_all_as_string(Pipe::LAST_MESSAGE), dat.made_from);
 +     }
 +-  catch (Botan::Exception & e)
 ++  catch (std::exception & e)
 +     {
 +       p.reset(new Pipe(new Hash_Filter("SHA-160")));
 +       error_in_transform(e, dat.made_from);
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
