aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/asn1/asn1_oid.cpp2
-rw-r--r--src/lib/base/scan_name.cpp10
-rw-r--r--src/lib/cert/x509/x509_ca.cpp2
-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
-rw-r--r--src/lib/entropy/proc_walk/proc_walk.cpp2
-rw-r--r--src/lib/misc/openpgp/openpgp.cpp8
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.cpp2
-rw-r--r--src/lib/utils/filesystem.cpp2
11 files changed, 98 insertions, 14 deletions
diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp
index 21c2daafb..2fbc4b27c 100644
--- a/src/lib/asn1/asn1_oid.cpp
+++ b/src/lib/asn1/asn1_oid.cpp
@@ -54,7 +54,7 @@ std::string OID::as_string() const
{
oid_str += std::to_string(id[i]);
if(i != id.size() - 1)
- oid_str += '.';
+ oid_str += ".";
}
return oid_str;
}
diff --git a/src/lib/base/scan_name.cpp b/src/lib/base/scan_name.cpp
index 4b0c95004..5c8c55b27 100644
--- a/src/lib/base/scan_name.cpp
+++ b/src/lib/base/scan_name.cpp
@@ -29,7 +29,7 @@ std::string make_arg(
if(name[i].first > level)
{
- output += '(' + name[i].second;
+ output += "(" + name[i].second;
++paren_depth;
}
else if(name[i].first < level)
@@ -48,7 +48,7 @@ std::string make_arg(
}
for(size_t i = 0; i != paren_depth; ++i)
- output += ')';
+ output += ")";
return output;
}
@@ -141,14 +141,14 @@ std::string SCAN_Name::all_arguments() const
std::string out;
if(arg_count())
{
- out += '(';
+ out += "(";
for(size_t i = 0; i != arg_count(); ++i)
{
out += arg(i);
if(i != arg_count() - 1)
- out += ',';
+ out += ",";
}
- out += ')';
+ out += ")";
}
return out;
}
diff --git a/src/lib/cert/x509/x509_ca.cpp b/src/lib/cert/x509/x509_ca.cpp
index b6bb5d8ce..d329bfdd8 100644
--- a/src/lib/cert/x509/x509_ca.cpp
+++ b/src/lib/cert/x509/x509_ca.cpp
@@ -243,7 +243,7 @@ PK_Signer* choose_sig_format(const Private_Key& key,
const Signature_Format format = (key.message_parts() > 1) ? DER_SEQUENCE : IEEE_1363;
- padding = padding + '(' + hash->name() + ')';
+ padding = padding + "(" + hash->name() + ")";
sig_algo.oid = OIDS::lookup(algo_name + "/" + padding);
sig_algo.parameters = key.algorithm_identifier().parameters;
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;
}
diff --git a/src/lib/entropy/proc_walk/proc_walk.cpp b/src/lib/entropy/proc_walk/proc_walk.cpp
index 7fbea678e..3d63e5d5a 100644
--- a/src/lib/entropy/proc_walk/proc_walk.cpp
+++ b/src/lib/entropy/proc_walk/proc_walk.cpp
@@ -86,7 +86,7 @@ int Directory_Walker::next_fd()
if(filename == "." || filename == "..")
continue;
- const std::string full_path = entry.second + '/' + filename;
+ const std::string full_path = entry.second + "/" + filename;
struct stat stat_buf;
if(::lstat(full_path.c_str(), &stat_buf) == -1)
diff --git a/src/lib/misc/openpgp/openpgp.cpp b/src/lib/misc/openpgp/openpgp.cpp
index 3a464d906..f42ce875e 100644
--- a/src/lib/misc/openpgp/openpgp.cpp
+++ b/src/lib/misc/openpgp/openpgp.cpp
@@ -28,16 +28,16 @@ std::string PGP_encode(
std::string pgp_encoded = PGP_HEADER;
if(headers.find("Version") != headers.end())
- pgp_encoded += "Version: " + headers.find("Version")->second + '\n';
+ pgp_encoded += "Version: " + headers.find("Version")->second + "\n";
std::map<std::string, std::string>::const_iterator i = headers.begin();
while(i != headers.end())
{
if(i->first != "Version")
- pgp_encoded += i->first + ": " + i->second + '\n';
+ pgp_encoded += i->first + ": " + i->second + "\n";
++i;
}
- pgp_encoded += '\n';
+ pgp_encoded += "\n";
Pipe pipe(new Fork(
new Base64_Encoder(true, PGP_WIDTH),
@@ -48,7 +48,7 @@ std::string PGP_encode(
pipe.process_msg(input, length);
pgp_encoded += pipe.read_all_as_string(0);
- pgp_encoded += '=' + pipe.read_all_as_string(1) + '\n';
+ pgp_encoded += "=" + pipe.read_all_as_string(1) + "\n";
pgp_encoded += PGP_TRAILER;
return pgp_encoded;
diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp
index 9133f9174..4d9bcf2e8 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.cpp
+++ b/src/lib/pubkey/mce/polyn_gf2m.cpp
@@ -508,7 +508,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
else
{
/* t odd */
- cond1 = r0.get_degree() <= break_deg - 1;
+ cond1 = r0.get_degree() < break_deg;
cond2 = u0.get_degree() < break_deg - 1;
cond1 &= cond2;
}
diff --git a/src/lib/utils/filesystem.cpp b/src/lib/utils/filesystem.cpp
index 950d4d4e2..8d51e64bd 100644
--- a/src/lib/utils/filesystem.cpp
+++ b/src/lib/utils/filesystem.cpp
@@ -86,7 +86,7 @@ std::vector<std::string> impl_readdir(const std::string& dir_path)
const std::string filename = dirent->d_name;
if(filename == "." || filename == "..")
continue;
- const std::string full_path = cur_path + '/' + filename;
+ const std::string full_path = cur_path + "/" + filename;
struct stat stat_buf;