aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/dsa/dsa.cpp15
-rw-r--r--src/lib/pubkey/pkcs8.cpp3
-rw-r--r--src/lib/pubkey/pkcs8.h2
-rw-r--r--src/lib/pubkey/rsa/rsa.cpp11
-rw-r--r--src/lib/pubkey/x509_key.cpp2
-rw-r--r--src/lib/pubkey/x509_key.h2
6 files changed, 33 insertions, 2 deletions
diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp
index 15dc45373..9c8ae0821 100644
--- a/src/lib/pubkey/dsa/dsa.cpp
+++ b/src/lib/pubkey/dsa/dsa.cpp
@@ -17,7 +17,9 @@
#include <botan/rfc6979.h>
#endif
-#include <future>
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
+ #include <future>
+#endif
namespace Botan {
@@ -124,11 +126,17 @@ DSA_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
const BigInt k = BigInt::random_integer(rng, 1, m_q);
#endif
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
auto future_r = std::async(std::launch::async,
[&]() { return m_mod_q.reduce(m_powermod_g_p(k)); });
BigInt s = inverse_mod(k, m_q);
const BigInt r = future_r.get();
+#else
+ BigInt s = inverse_mod(k, m_q);
+ const BigInt r = m_mod_q.reduce(m_powermod_g_p(k));
+#endif
+
s = m_mod_q.multiply(s, mul_add(m_x, r, i));
// With overwhelming probability, a bug rather than actual zero r/s
@@ -184,11 +192,16 @@ bool DSA_Verification_Operation::verify(const byte msg[], size_t msg_len,
s = inverse_mod(s, m_q);
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
auto future_s_i = std::async(std::launch::async,
[&]() { return m_powermod_g_p(m_mod_q.multiply(s, i)); });
BigInt s_r = m_powermod_y_p(m_mod_q.multiply(s, r));
BigInt s_i = future_s_i.get();
+#else
+ BigInt s_r = m_powermod_y_p(m_mod_q.multiply(s, r));
+ BigInt s_i = m_powermod_g_p(m_mod_q.multiply(s, i));
+#endif
s = m_mod_p.multiply(s_i, s_r);
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp
index ddf9be2f0..96dfd5e44 100644
--- a/src/lib/pubkey/pkcs8.cpp
+++ b/src/lib/pubkey/pkcs8.cpp
@@ -262,6 +262,8 @@ Private_Key* load_key(DataSource& source,
throw PKCS8_Exception( "Internal error: Attempt to read password for unencrypted key" );}, false);
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+
/*
* Extract an encrypted private key and return it
*/
@@ -293,6 +295,7 @@ Private_Key* load_key(const std::string& fsname,
return load_key(source, rng, []() -> std::string {
throw PKCS8_Exception( "Internal error: Attempt to read password for unencrypted key" );}, false);
}
+#endif
/*
* Make a copy of this private key
diff --git a/src/lib/pubkey/pkcs8.h b/src/lib/pubkey/pkcs8.h
index 791a612df..9cc350285 100644
--- a/src/lib/pubkey/pkcs8.h
+++ b/src/lib/pubkey/pkcs8.h
@@ -108,6 +108,7 @@ BOTAN_DLL Private_Key* load_key(DataSource& source,
BOTAN_DLL Private_Key* load_key(DataSource& source,
RandomNumberGenerator& rng);
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/**
* Load an encrypted key from a file.
* @param filename the path to the file containing the encoded key
@@ -136,6 +137,7 @@ BOTAN_DLL Private_Key* load_key(const std::string& filename,
*/
BOTAN_DLL Private_Key* load_key(const std::string& filename,
RandomNumberGenerator& rng);
+#endif
/**
* Copy an existing encoded key object.
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp
index b40f485e3..d201ca277 100644
--- a/src/lib/pubkey/rsa/rsa.cpp
+++ b/src/lib/pubkey/rsa/rsa.cpp
@@ -14,12 +14,16 @@
#include <botan/workfactor.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
-#include <future>
#if defined(BOTAN_HAS_OPENSSL)
#include <botan/internal/openssl.h>
#endif
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
+#include <future>
+#endif
+
+
namespace Botan {
size_t RSA_PublicKey::estimated_strength() const
@@ -218,9 +222,14 @@ class RSA_Private_Operation
BigInt private_op(const BigInt& m) const
{
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
auto future_j1 = std::async(std::launch::async, m_powermod_d1_p, m);
BigInt j2 = m_powermod_d2_q(m);
BigInt j1 = future_j1.get();
+#else
+ BigInt j1 = m_powermod_d1_p(m);
+ BigInt j2 = m_powermod_d2_q(m);
+#endif
j1 = m_mod_p.reduce(sub_mul(j1, j2, m_c));
diff --git a/src/lib/pubkey/x509_key.cpp b/src/lib/pubkey/x509_key.cpp
index ccb94cea7..08e17bfed 100644
--- a/src/lib/pubkey/x509_key.cpp
+++ b/src/lib/pubkey/x509_key.cpp
@@ -78,6 +78,7 @@ Public_Key* load_key(DataSource& source)
}
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* Extract a public key and return it
*/
@@ -86,6 +87,7 @@ Public_Key* load_key(const std::string& fsname)
DataSource_Stream source(fsname, true);
return X509::load_key(source);
}
+#endif
/*
* Extract a public key and return it
diff --git a/src/lib/pubkey/x509_key.h b/src/lib/pubkey/x509_key.h
index cbb0412d2..7162b338e 100644
--- a/src/lib/pubkey/x509_key.h
+++ b/src/lib/pubkey/x509_key.h
@@ -46,12 +46,14 @@ BOTAN_DLL std::string PEM_encode(const Public_Key& key);
*/
BOTAN_DLL Public_Key* load_key(DataSource& source);
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/**
* Create a public key from a file
* @param filename pathname to the file to load
* @return new public key object
*/
BOTAN_DLL Public_Key* load_key(const std::string& filename);
+#endif
/**
* Create a public key from a memory region.