aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-02-24 13:55:53 +0000
committerlloyd <[email protected]>2010-02-24 13:55:53 +0000
commit3e95540b28f3d828c4578381c318545f6ad49589 (patch)
tree31daed2385f63d6d8385abbac525769e9f83aee1 /src
parent01a6b5d010f459e8eeb0ef2ce97ecaf885ae1809 (diff)
Drop async.h and switch to using std::async which was added to GCC before
the 4.5 release.
Diffstat (limited to 'src')
-rw-r--r--src/pubkey/dsa/dsa_op.cpp7
-rw-r--r--src/pubkey/elgamal/elg_op.cpp4
-rw-r--r--src/pubkey/if_algo/if_op.cpp9
-rw-r--r--src/pubkey/nr/nr_op.cpp4
-rw-r--r--src/utils/async.h33
-rw-r--r--src/utils/info.txt1
6 files changed, 10 insertions, 48 deletions
diff --git a/src/pubkey/dsa/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp
index 5eb9e92be..e83fd83b7 100644
--- a/src/pubkey/dsa/dsa_op.cpp
+++ b/src/pubkey/dsa/dsa_op.cpp
@@ -6,7 +6,7 @@
*/
#include <botan/dsa_op.h>
-#include <botan/internal/async.h>
+#include <future>
namespace Botan {
@@ -42,7 +42,7 @@ bool Default_DSA_Op::verify(const byte msg[], u32bit msg_len,
s = inverse_mod(s, q);
- auto future_s_i = std_async(
+ auto future_s_i = std::async(std::launch::async,
[&]() { return powermod_g_p(mod_q.multiply(s, i)); });
BigInt s_r = powermod_y_p(mod_q.multiply(s, r));
@@ -62,7 +62,8 @@ SecureVector<byte> Default_DSA_Op::sign(const byte in[], u32bit length,
if(x == 0)
throw Internal_Error("Default_DSA_Op::sign: No private key");
- auto future_r = std_async([&]() { return mod_q.reduce(powermod_g_p(k)); });
+ auto future_r = std::async(std::launch::async,
+ [&]() { return mod_q.reduce(powermod_g_p(k)); });
const BigInt& q = group.get_q();
BigInt i(in, length);
diff --git a/src/pubkey/elgamal/elg_op.cpp b/src/pubkey/elgamal/elg_op.cpp
index 49db44251..4bde60bee 100644
--- a/src/pubkey/elgamal/elg_op.cpp
+++ b/src/pubkey/elgamal/elg_op.cpp
@@ -6,7 +6,7 @@
*/
#include <botan/elg_op.h>
-#include <botan/internal/async.h>
+#include <future>
namespace Botan {
@@ -34,7 +34,7 @@ SecureVector<byte> Default_ELG_Op::encrypt(const byte in[], u32bit length,
if(m >= p)
throw Invalid_Argument("Default_ELG_Op::encrypt: Input is too large");
- auto future_a = std_async([&]() { return powermod_g_p(k); });
+ auto future_a = std::async(std::launch::async, powermod_g_p, k);
BigInt b = mod_p.multiply(m, powermod_y_p(k));
BigInt a = future_a.get();
diff --git a/src/pubkey/if_algo/if_op.cpp b/src/pubkey/if_algo/if_op.cpp
index 58618775b..99f68400d 100644
--- a/src/pubkey/if_algo/if_op.cpp
+++ b/src/pubkey/if_algo/if_op.cpp
@@ -7,7 +7,7 @@
#include <botan/if_op.h>
#include <botan/numthry.h>
-#include <botan/internal/async.h>
+#include <future>
namespace Botan {
@@ -39,12 +39,7 @@ BigInt Default_IF_Op::private_op(const BigInt& i) const
if(q == 0)
throw Internal_Error("Default_IF_Op::private_op: No private key");
- /*
- * A simple std::bind(powermod_d1_p, i) would work instead of a
- * lambda but GCC 4.5's std::result_of doesn't use decltype and gets
- * confused
- */
- auto future_j1 = std_async([&]() { return powermod_d1_p(i); });
+ auto future_j1 = std::async(std::launch::async, powermod_d1_p, i);
BigInt j2 = powermod_d2_q(i);
BigInt j1 = future_j1.get();
diff --git a/src/pubkey/nr/nr_op.cpp b/src/pubkey/nr/nr_op.cpp
index da104802d..10890a127 100644
--- a/src/pubkey/nr/nr_op.cpp
+++ b/src/pubkey/nr/nr_op.cpp
@@ -6,7 +6,7 @@
*/
#include <botan/nr_op.h>
-#include <botan/internal/async.h>
+#include <future>
namespace Botan {
@@ -38,7 +38,7 @@ SecureVector<byte> Default_NR_Op::verify(const byte in[], u32bit length) const
if(c.is_zero() || c >= q || d >= q)
throw Invalid_Argument("Default_NR_Op::verify: Invalid signature");
- auto future_y_c = std_async([&]() { return powermod_y_p(c); });
+ auto future_y_c = std::async(std::launch::async, powermod_y_p, c);
BigInt g_d = powermod_g_p(d);
BigInt i = mod_p.multiply(g_d, future_y_c.get());
diff --git a/src/utils/async.h b/src/utils/async.h
deleted file mode 100644
index 1ffa2c4cb..000000000
--- a/src/utils/async.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
-* Standin for C++0x's std::async
-* (C) 2009 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_ASYNC_H__
-#define BOTAN_ASYNC_H__
-
-#include <future>
-#include <thread>
-
-namespace Botan {
-
-/**
-* A simple version of std::async (as it is not in GCC 4.5)
-* Will be removed once GCC supports it natively
-*/
-template<typename F>
-auto std_async(F f) -> std::future<decltype(f())>
- {
- typedef decltype(f()) result_type;
- std::packaged_task<result_type ()> task(std::move(f));
- std::future<result_type> future = task.get_future();
- std::thread thread(std::move(task));
- thread.detach();
- return future;
- }
-
-}
-
-#endif
diff --git a/src/utils/info.txt b/src/utils/info.txt
index 2fb17fd80..2fb3e79a5 100644
--- a/src/utils/info.txt
+++ b/src/utils/info.txt
@@ -13,7 +13,6 @@ version.cpp
</source>
<header:internal>
-async.h
bit_ops.h
debug.h
mlock.h