aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/info.txt4
-rw-r--r--src/utils/mlock.cpp2
-rw-r--r--src/utils/mlock.h32
-rw-r--r--src/utils/rounding.h35
-rw-r--r--src/utils/util.cpp68
-rw-r--r--src/utils/util.h39
6 files changed, 70 insertions, 110 deletions
diff --git a/src/utils/info.txt b/src/utils/info.txt
index ab50b88ad..68981729f 100644
--- a/src/utils/info.txt
+++ b/src/utils/info.txt
@@ -17,16 +17,16 @@ exceptn.cpp
exceptn.h
loadstor.h
mem_ops.h
+mlock.h
mlock.cpp
parsing.cpp
parsing.h
rotate.h
+rounding.h
stl_util.h
types.h
ui.cpp
ui.h
-util.cpp
-util.h
version.cpp
version.h
xor_buf.h
diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp
index 9bb062da5..6453d8a30 100644
--- a/src/utils/mlock.cpp
+++ b/src/utils/mlock.cpp
@@ -5,7 +5,7 @@
* Distributed under the terms of the Botan license
*/
-#include <botan/util.h>
+#include <botan/mlock.h>
#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
#include <sys/types.h>
diff --git a/src/utils/mlock.h b/src/utils/mlock.h
new file mode 100644
index 000000000..0811e8190
--- /dev/null
+++ b/src/utils/mlock.h
@@ -0,0 +1,32 @@
+/*
+* Memory Locking Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_MLOCK_H__
+#define BOTAN_MLOCK_H__
+
+#include <botan/types.h>
+
+namespace Botan {
+
+/**
+* Lock memory into RAM if possible
+* @param addr the start of the memory block
+* @param length the length of the memory block in bytes
+* @returns true if successful, false otherwise
+*/
+BOTAN_DLL bool lock_mem(void* addr, u32bit length);
+
+/**
+* Unlock memory locked with lock_mem()
+* @param addr the start of the memory block
+* @param length the length of the memory block in bytes
+*/
+BOTAN_DLL void unlock_mem(void* addr, u32bit length);
+
+}
+
+#endif
diff --git a/src/utils/rounding.h b/src/utils/rounding.h
new file mode 100644
index 000000000..11ab90b8d
--- /dev/null
+++ b/src/utils/rounding.h
@@ -0,0 +1,35 @@
+/*
+* Integer Rounding Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_ROUNDING_H__
+#define BOTAN_ROUNDING_H__
+
+#include <botan/types.h>
+
+namespace Botan {
+
+/*
+* Round up n to multiple of align_to
+*/
+inline u32bit round_up(u32bit n, u32bit align_to)
+ {
+ if(n % align_to || n == 0)
+ n += align_to - (n % align_to);
+ return n;
+ }
+
+/*
+* Round down n to multiple of align_to
+*/
+inline u32bit round_down(u32bit n, u32bit align_to)
+ {
+ return (n - (n % align_to));
+ }
+
+}
+
+#endif
diff --git a/src/utils/util.cpp b/src/utils/util.cpp
deleted file mode 100644
index 84dfd1a14..000000000
--- a/src/utils/util.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* Utility Functions
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/util.h>
-#include <algorithm>
-#include <cmath>
-
-namespace Botan {
-
-/*
-* Round up n to multiple of align_to
-*/
-u32bit round_up(u32bit n, u32bit align_to)
- {
- if(n % align_to || n == 0)
- n += align_to - (n % align_to);
- return n;
- }
-
-/*
-* Round down n to multiple of align_to
-*/
-u32bit round_down(u32bit n, u32bit align_to)
- {
- return (n - (n % align_to));
- }
-
-/*
-* Choose the exponent size for a DL group
-*/
-u32bit dl_work_factor(u32bit bits)
- {
-#if 0
- /*
- These values were taken from RFC 3526
- */
- if(bits <= 1536)
- return 90;
- else if(bits <= 2048)
- return 110;
- else if(bits <= 3072)
- return 130;
- else if(bits <= 4096)
- return 150;
- else if(bits <= 6144)
- return 170;
- else if(bits <= 8192)
- return 190;
- return 256;
-#else
- const u32bit MIN_ESTIMATE = 64;
-
- const double log_x = bits / 1.44;
-
- const double strength =
- 2.76 * std::pow(log_x, 1.0/3.0) * std::pow(std::log(log_x), 2.0/3.0);
-
- if(strength > MIN_ESTIMATE)
- return static_cast<u32bit>(strength);
- return MIN_ESTIMATE;
-#endif
- }
-
-}
diff --git a/src/utils/util.h b/src/utils/util.h
deleted file mode 100644
index ac7867390..000000000
--- a/src/utils/util.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* Utility Functions
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_UTIL_H__
-#define BOTAN_UTIL_H__
-
-#include <botan/types.h>
-
-namespace Botan {
-
-/*
-* Time Access Functions
-*/
-BOTAN_DLL u64bit system_time();
-
-/*
-* Memory Locking Functions
-*/
-BOTAN_DLL bool lock_mem(void*, u32bit);
-BOTAN_DLL void unlock_mem(void*, u32bit);
-
-/*
-* Misc Utility Functions
-*/
-BOTAN_DLL u32bit round_up(u32bit, u32bit);
-BOTAN_DLL u32bit round_down(u32bit, u32bit);
-
-/*
-* Work Factor Estimates
-*/
-BOTAN_DLL u32bit dl_work_factor(u32bit);
-
-}
-
-#endif