aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <lloyd@randombit.net>2016-10-10 01:50:46 -0400
committerJack Lloyd <lloyd@randombit.net>2016-10-10 01:50:46 -0400
commit227d59d886418ace13aa91c1b0dc5fea91efbb4a (patch)
treebdf9579874d66acac518ac53ce1ddcde6fb4d719
parent35657e0f76931f0d3a333610e7065c81c35e9f1e (diff)
Add IncludeOS target. Make filesystem support optional.
-rwxr-xr-xconfigure.py5
-rw-r--r--src/build-data/os/includeos.txt4
-rw-r--r--src/lib/cert/x509/pkcs10.cpp6
-rw-r--r--src/lib/cert/x509/x509_crl.cpp6
-rw-r--r--src/lib/cert/x509/x509_obj.cpp2
-rw-r--r--src/lib/cert/x509/x509_obj.h5
-rw-r--r--src/lib/cert/x509/x509cert.cpp6
-rw-r--r--src/lib/filters/data_snk.cpp7
-rw-r--r--src/lib/filters/data_snk.h4
-rw-r--r--src/lib/misc/srp6/srp6_files.cpp5
-rw-r--r--src/lib/misc/srp6/srp6_files.h7
-rw-r--r--src/lib/pubkey/pkcs8.cpp3
-rw-r--r--src/lib/pubkey/pkcs8.h2
-rw-r--r--src/lib/pubkey/x509_key.cpp2
-rw-r--r--src/lib/pubkey/x509_key.h2
-rw-r--r--src/lib/utils/data_src.cpp9
-rw-r--r--src/lib/utils/data_src.h4
-rw-r--r--src/lib/utils/os_utils.cpp4
-rw-r--r--src/tests/test_x509_path.cpp2
19 files changed, 67 insertions, 18 deletions
diff --git a/configure.py b/configure.py
index 037d47d54..24d84d633 100755
--- a/configure.py
+++ b/configure.py
@@ -1019,6 +1019,7 @@ class OsInfo(object):
'bin_dir': 'bin',
'lib_dir': 'lib',
'doc_dir': 'share/doc',
+ 'with_filesystem': 'yes',
'building_shared_supported': 'yes',
'install_cmd_data': 'install -m 644',
'install_cmd_exec': 'install -m 755'
@@ -1027,6 +1028,7 @@ class OsInfo(object):
self.ar_needs_ranlib = bool(self.ar_needs_ranlib)
self.building_shared_supported = (True if self.building_shared_supported == 'yes' else False)
+ self.with_filesystem = (True if self.with_filesystem == 'yes' else False)
def ranlib_command(self):
return ('ranlib' if self.ar_needs_ranlib else 'true')
@@ -1046,6 +1048,9 @@ class OsInfo(object):
if feat not in self.target_features:
yield 'TARGET_OS_HAS_' + feat.upper()
+ if self.with_filesystem:
+ yield 'TARGET_OS_HAS_FILESYSTEM'
+
r += sorted(feat_macros())
return r
diff --git a/src/build-data/os/includeos.txt b/src/build-data/os/includeos.txt
new file mode 100644
index 000000000..a724d188b
--- /dev/null
+++ b/src/build-data/os/includeos.txt
@@ -0,0 +1,4 @@
+os_type unikernel
+
+building_shared_supported no
+with_filesystem no
diff --git a/src/lib/cert/x509/pkcs10.cpp b/src/lib/cert/x509/pkcs10.cpp
index 40a9894cc..ccd22454b 100644
--- a/src/lib/cert/x509/pkcs10.cpp
+++ b/src/lib/cert/x509/pkcs10.cpp
@@ -25,14 +25,16 @@ PKCS10_Request::PKCS10_Request(DataSource& in) :
do_decode();
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* PKCS10_Request Constructor
*/
-PKCS10_Request::PKCS10_Request(const std::string& in) :
- X509_Object(in, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
+PKCS10_Request::PKCS10_Request(const std::string& fsname) :
+ X509_Object(fsname, "CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
{
do_decode();
}
+#endif
/*
* PKCS10_Request Constructor
diff --git a/src/lib/cert/x509/x509_crl.cpp b/src/lib/cert/x509/x509_crl.cpp
index 3c75825c1..8eb4c01db 100644
--- a/src/lib/cert/x509/x509_crl.cpp
+++ b/src/lib/cert/x509/x509_crl.cpp
@@ -24,14 +24,16 @@ X509_CRL::X509_CRL(DataSource& in, bool touc) :
do_decode();
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* Load a X.509 CRL
*/
-X509_CRL::X509_CRL(const std::string& in, bool touc) :
- X509_Object(in, "CRL/X509 CRL"), m_throw_on_unknown_critical(touc)
+X509_CRL::X509_CRL(const std::string& fsname, bool touc) :
+ X509_Object(fsname, "CRL/X509 CRL"), m_throw_on_unknown_critical(touc)
{
do_decode();
}
+#endif
X509_CRL::X509_CRL(const std::vector<byte>& in, bool touc) :
X509_Object(in, "CRL/X509 CRL"), m_throw_on_unknown_critical(touc)
diff --git a/src/lib/cert/x509/x509_obj.cpp b/src/lib/cert/x509/x509_obj.cpp
index 983be40b2..3c5d2a9b4 100644
--- a/src/lib/cert/x509/x509_obj.cpp
+++ b/src/lib/cert/x509/x509_obj.cpp
@@ -25,6 +25,7 @@ X509_Object::X509_Object(DataSource& stream, const std::string& labels)
init(stream, labels);
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* Create a generic X.509 object
*/
@@ -33,6 +34,7 @@ X509_Object::X509_Object(const std::string& file, const std::string& labels)
DataSource_Stream stream(file, true);
init(stream, labels);
}
+#endif
/*
* Create a generic X.509 object
diff --git a/src/lib/cert/x509/x509_obj.h b/src/lib/cert/x509/x509_obj.h
index eb929451c..c3e4ca830 100644
--- a/src/lib/cert/x509/x509_obj.h
+++ b/src/lib/cert/x509/x509_obj.h
@@ -88,9 +88,12 @@ class BOTAN_DLL X509_Object : public ASN1_Object
virtual ~X509_Object() {}
protected:
X509_Object(DataSource& src, const std::string& pem_labels);
- X509_Object(const std::string& file, const std::string& pem_labels);
X509_Object(const std::vector<byte>& vec, const std::string& labels);
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+ X509_Object(const std::string& file, const std::string& pem_labels);
+#endif
+
void do_decode();
X509_Object() {}
AlgorithmIdentifier m_sig_algo;
diff --git a/src/lib/cert/x509/x509cert.cpp b/src/lib/cert/x509/x509cert.cpp
index 5765214ae..f56495a79 100644
--- a/src/lib/cert/x509/x509cert.cpp
+++ b/src/lib/cert/x509/x509cert.cpp
@@ -50,16 +50,18 @@ X509_Certificate::X509_Certificate(DataSource& in) :
do_decode();
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* X509_Certificate Constructor
*/
-X509_Certificate::X509_Certificate(const std::string& in) :
- X509_Object(in, "CERTIFICATE/X509 CERTIFICATE"),
+X509_Certificate::X509_Certificate(const std::string& fsname) :
+ X509_Object(fsname, "CERTIFICATE/X509 CERTIFICATE"),
m_self_signed(false),
m_v3_extensions(false)
{
do_decode();
}
+#endif
/*
* X509_Certificate Constructor
diff --git a/src/lib/filters/data_snk.cpp b/src/lib/filters/data_snk.cpp
index df35b12bf..efedef268 100644
--- a/src/lib/filters/data_snk.cpp
+++ b/src/lib/filters/data_snk.cpp
@@ -8,10 +8,14 @@
#include <botan/data_snk.h>
#include <botan/exceptn.h>
-#include <fstream>
+
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+ #include <fstream>
+#endif
namespace Botan {
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
/*
* Write to a stream
*/
@@ -58,5 +62,6 @@ DataSink_Stream::~DataSink_Stream()
{
delete m_sink_p;
}
+#endif
}
diff --git a/src/lib/filters/data_snk.h b/src/lib/filters/data_snk.h
index 56b292e46..2405fdf98 100644
--- a/src/lib/filters/data_snk.h
+++ b/src/lib/filters/data_snk.h
@@ -27,6 +27,8 @@ class BOTAN_DLL DataSink : public Filter
DataSink(const DataSink&) = delete;
};
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+
/**
* This class represents a data sink which writes its output to a stream.
*/
@@ -62,6 +64,8 @@ class BOTAN_DLL DataSink_Stream : public DataSink
std::ostream& m_sink;
};
+#endif
+
}
#endif
diff --git a/src/lib/misc/srp6/srp6_files.cpp b/src/lib/misc/srp6/srp6_files.cpp
index 14ab1ac61..606c12ad7 100644
--- a/src/lib/misc/srp6/srp6_files.cpp
+++ b/src/lib/misc/srp6/srp6_files.cpp
@@ -8,14 +8,11 @@
#include <botan/srp6_files.h>
#include <botan/parsing.h>
#include <botan/base64.h>
-#include <fstream>
namespace Botan {
-SRP6_Authenticator_File::SRP6_Authenticator_File(const std::string& filename)
+SRP6_Authenticator_File::SRP6_Authenticator_File(std::istream& in)
{
- std::ifstream in(filename);
-
if(!in)
return; // no entries
diff --git a/src/lib/misc/srp6/srp6_files.h b/src/lib/misc/srp6/srp6_files.h
index 2b20de7a3..db128727e 100644
--- a/src/lib/misc/srp6/srp6_files.h
+++ b/src/lib/misc/srp6/srp6_files.h
@@ -9,6 +9,7 @@
#define BOTAN_SRP6A_FILES_H__
#include <botan/bigint.h>
+#include <iosfwd>
#include <string>
#include <map>
@@ -20,11 +21,11 @@ namespace Botan {
class BOTAN_DLL SRP6_Authenticator_File
{
public:
+
/**
- * @param filename will be opened and processed as a SRP
- * authenticator file
+ * @param input will be read and processed as SRP authenticator file
*/
- explicit SRP6_Authenticator_File(const std::string& filename);
+ explicit SRP6_Authenticator_File(std::istream& input);
bool lookup_user(const std::string& username,
BigInt& v,
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/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.
diff --git a/src/lib/utils/data_src.cpp b/src/lib/utils/data_src.cpp
index 0c06f2fe4..7da94d7c0 100644
--- a/src/lib/utils/data_src.cpp
+++ b/src/lib/utils/data_src.cpp
@@ -8,9 +8,12 @@
#include <botan/data_src.h>
#include <botan/exceptn.h>
-#include <fstream>
#include <algorithm>
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+ #include <fstream>
+#endif
+
namespace Botan {
/*
@@ -98,6 +101,8 @@ DataSource_Memory::DataSource_Memory(const std::string& in) :
{
}
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+
/*
* Read from a stream
*/
@@ -209,4 +214,6 @@ DataSource_Stream::~DataSource_Stream()
delete m_source_p;
}
+#endif
+
}
diff --git a/src/lib/utils/data_src.h b/src/lib/utils/data_src.h
index 6a100ce63..b24fd75a4 100644
--- a/src/lib/utils/data_src.h
+++ b/src/lib/utils/data_src.h
@@ -138,6 +138,8 @@ class BOTAN_DLL DataSource_Memory : public DataSource
size_t m_offset;
};
+#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
+
/**
* This class represents a Stream-Based DataSource.
*/
@@ -175,6 +177,8 @@ class BOTAN_DLL DataSource_Stream : public DataSource
size_t m_total_read;
};
+#endif
+
}
#endif
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 2f17da952..56ec59cc0 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -33,8 +33,10 @@ uint32_t get_process_id()
return ::getpid();
#elif defined(BOTAN_TARGET_OS_IS_WINDOWS) || defined(BOTAN_TARGET_OS_IS_MINGW)
return ::GetCurrentProcessId();
+#elif defined(BOTAN_TARGET_OS_TYPE_IS_UNIKERNEL)
+ return 0;
#else
- throw Exception("get_process_id not supported");
+ #error "Missing get_process_id"
#endif
}
diff --git a/src/tests/test_x509_path.cpp b/src/tests/test_x509_path.cpp
index 7e2039ab4..96cc7a190 100644
--- a/src/tests/test_x509_path.cpp
+++ b/src/tests/test_x509_path.cpp
@@ -23,7 +23,7 @@ namespace Botan_Tests {
namespace {
-#if defined(BOTAN_HAS_X509_CERTIFICATES)
+#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
std::map<std::string, std::string> read_results(const std::string& results_file)
{