aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py17
-rw-r--r--src/build-data/cc/clang.txt1
-rw-r--r--src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp28
-rw-r--r--src/lib/entropy/darwin_secrandom/darwin_secrandom.h31
-rw-r--r--src/lib/entropy/darwin_secrandom/info.txt17
-rw-r--r--src/lib/entropy/entropy_srcs.cpp8
6 files changed, 99 insertions, 3 deletions
diff --git a/configure.py b/configure.py
index 44087b28b..ebde4d9a3 100755
--- a/configure.py
+++ b/configure.py
@@ -545,7 +545,7 @@ class ModuleInfo(object):
lex_me_harder(infofile, self,
['source', 'header:internal', 'header:public',
'requires', 'os', 'arch', 'cc', 'libs',
- 'comment', 'warning'],
+ 'frameworks', 'comment', 'warning'],
{
'load_on': 'auto',
'define': [],
@@ -584,6 +584,7 @@ class ModuleInfo(object):
return result
self.libs = convert_lib_list(self.libs)
+ self.frameworks = convert_lib_list(self.frameworks)
def add_dir_name(filename):
if filename.count(':') == 0:
@@ -769,6 +770,7 @@ class CompilerInfo(object):
'add_include_dir_option': '-I',
'add_lib_dir_option': '-L',
'add_lib_option': '-l',
+ 'add_framework_option': '-framework ',
'compile_flags_release': '',
'compile_flags_debug': '',
'lib_opt_flags_release': '',
@@ -1170,9 +1172,18 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
Figure out what external libraries are needed based on selected modules
"""
def link_to():
+ return do_link_to('libs')
+
+ """
+ Figure out what external frameworks are needed based on selected modules
+ """
+ def link_to_frameworks():
+ return do_link_to('frameworks')
+
+ def do_link_to(module_member_name):
libs = set()
for module in modules:
- for (osname,link_to) in module.libs.items():
+ for (osname,link_to) in getattr(module, module_member_name).items():
if osname == 'all' or osname == osinfo.basename:
libs |= set(link_to)
else:
@@ -1303,7 +1314,7 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'app_link_cmd': cc.binary_link_command_for(osinfo.basename, options),
'test_link_cmd': cc.binary_link_command_for(osinfo.basename, options),
- 'link_to': ' '.join([cc.add_lib_option + lib for lib in link_to()]),
+ 'link_to': ' '.join([cc.add_lib_option + lib for lib in link_to()] + [cc.add_framework_option + fw for fw in link_to_frameworks()]),
'module_defines': make_cpp_macros(sorted(flatten([m.defines() for m in modules]))),
diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index 0fbc67ce9..129218dcd 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -6,6 +6,7 @@ output_to_option "-o "
add_include_dir_option -I
add_lib_dir_option -L
add_lib_option -l
+add_framework_option "-framework "
lang_flags "-std=c++11 -D_REENTRANT -fstack-protector"
diff --git a/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp b/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp
new file mode 100644
index 000000000..f04b75a12
--- /dev/null
+++ b/src/lib/entropy/darwin_secrandom/darwin_secrandom.cpp
@@ -0,0 +1,28 @@
+/*
+* Darwin SecRandomCopyBytes EntropySource
+* (C) 2015 Daniel Seither (Kullo GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include <botan/internal/darwin_secrandom.h>
+#include <Security/Security.h>
+
+namespace Botan {
+
+/**
+* Gather entropy from SecRandomCopyBytes
+*/
+void Darwin_SecRandom::poll(Entropy_Accumulator& accum)
+ {
+ const size_t ENTROPY_BITS_PER_BYTE = 8;
+ const size_t BUF_SIZE = 256;
+
+ m_buf.resize(BUF_SIZE);
+ if (0 == SecRandomCopyBytes(kSecRandomDefault, m_buf.size(), m_buf.data()))
+ {
+ accum.add(m_buf.data(), m_buf.size(), ENTROPY_BITS_PER_BYTE);
+ }
+ }
+
+}
diff --git a/src/lib/entropy/darwin_secrandom/darwin_secrandom.h b/src/lib/entropy/darwin_secrandom/darwin_secrandom.h
new file mode 100644
index 000000000..504d5cc64
--- /dev/null
+++ b/src/lib/entropy/darwin_secrandom/darwin_secrandom.h
@@ -0,0 +1,31 @@
+/*
+* Darwin SecRandomCopyBytes EntropySource
+* (C) 2015 Daniel Seither (Kullo GmbH)
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_ENTROPY_SRC_DARWIN_SECRANDOM_H__
+#define BOTAN_ENTROPY_SRC_DARWIN_SECRANDOM_H__
+
+#include <botan/entropy_src.h>
+
+namespace Botan {
+
+/**
+* Entropy source using SecRandomCopyBytes from Darwin's Security.framework
+*/
+class Darwin_SecRandom : public EntropySource
+ {
+ public:
+ std::string name() const override { return "Darwin SecRandomCopyBytes"; }
+
+ void poll(Entropy_Accumulator& accum) override;
+
+ private:
+ secure_vector<byte> m_buf;
+ };
+
+}
+
+#endif
diff --git a/src/lib/entropy/darwin_secrandom/info.txt b/src/lib/entropy/darwin_secrandom/info.txt
new file mode 100644
index 000000000..e12c341fd
--- /dev/null
+++ b/src/lib/entropy/darwin_secrandom/info.txt
@@ -0,0 +1,17 @@
+define ENTROPY_SRC_DARWIN_SECRANDOM 20150925
+
+<source>
+darwin_secrandom.cpp
+</source>
+
+<header:internal>
+darwin_secrandom.h
+</header:internal>
+
+<os>
+darwin
+</os>
+
+<frameworks>
+darwin -> Security
+</frameworks> \ No newline at end of file
diff --git a/src/lib/entropy/entropy_srcs.cpp b/src/lib/entropy/entropy_srcs.cpp
index d44ab8c92..d57160c88 100644
--- a/src/lib/entropy/entropy_srcs.cpp
+++ b/src/lib/entropy/entropy_srcs.cpp
@@ -43,6 +43,10 @@
#include <botan/internal/proc_walk.h>
#endif
+#if defined(BOTAN_HAS_ENTROPY_SRC_DARWIN_SECRANDOM)
+ #include <botan/internal/darwin_secrandom.h>
+#endif
+
namespace Botan {
namespace {
@@ -97,6 +101,10 @@ std::vector<std::unique_ptr<EntropySource>> get_default_entropy_sources()
));
#endif
+#if defined(BOTAN_HAS_ENTROPY_SRC_DARWIN_SECRANDOM)
+ sources.push_back(std::unique_ptr<EntropySource>(new Darwin_SecRandom));
+#endif
+
return sources;
}