aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--checks/cvc_tests.cpp2
-rw-r--r--src/alloc/mem_pool/mem_pool.cpp2
-rw-r--r--src/alloc/system_alloc/defalloc.cpp2
-rw-r--r--src/benchmark/benchmark.cpp1
-rw-r--r--src/cert/cvc/cvc_ca.cpp1
-rw-r--r--src/cert/cvc/cvc_self.cpp2
-rw-r--r--src/cert/x509/crl_ent.cpp2
-rw-r--r--src/cert/x509/x509_ca.cpp2
-rw-r--r--src/cert/x509/x509opt.cpp4
-rw-r--r--src/cert/x509/x509stor.cpp2
-rw-r--r--src/engine/openssl/ossl_bc.cpp34
-rw-r--r--src/engine/openssl/ossl_md.cpp24
-rw-r--r--src/math/bigint/bigint.cpp2
-rw-r--r--src/math/numbertheory/mp_numth.cpp2
-rw-r--r--src/modes/mode_pad/mode_pad.cpp1
-rw-r--r--src/pubkey/dh/dh.cpp2
-rw-r--r--src/pubkey/dl_group/dl_group.cpp2
-rw-r--r--src/pubkey/ecc_key/ecc_key.cpp1
-rw-r--r--src/pubkey/ecdsa/ecdsa.cpp1
-rw-r--r--src/pubkey/eckaeg/eckaeg.cpp1
-rw-r--r--src/pubkey/elgamal/elgamal.cpp2
-rw-r--r--src/pubkey/info.txt2
-rw-r--r--src/pubkey/workfactor.cpp (renamed from src/utils/util.cpp)23
-rw-r--r--src/pubkey/workfactor.h22
-rw-r--r--src/rng/hmac_rng/hmac_rng.cpp1
-rw-r--r--src/rng/randpool/randpool.cpp2
-rw-r--r--src/timer/gettimeofday/tm_unix.cpp1
-rw-r--r--src/timer/posix_rt/tm_posix.cpp1
-rw-r--r--src/timer/timer.cpp1
-rw-r--r--src/timer/timer.h5
-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.h39
35 files changed, 163 insertions, 99 deletions
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index cde8c8b2c..369da4a8c 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -27,7 +27,7 @@
#include <botan/look_pk.h>
#include <botan/cvc_self.h>
#include <botan/cvc_cert.h>
-#include <botan/util.h>
+#include <botan/timer.h>
#include <botan/cvc_ado.h>
#define TEST_DATA_DIR "checks/ecc_testdata"
diff --git a/src/alloc/mem_pool/mem_pool.cpp b/src/alloc/mem_pool/mem_pool.cpp
index a3858add6..9917793e5 100644
--- a/src/alloc/mem_pool/mem_pool.cpp
+++ b/src/alloc/mem_pool/mem_pool.cpp
@@ -8,7 +8,7 @@
*/
#include <botan/mem_pool.h>
-#include <botan/util.h>
+#include <botan/rounding.h>
#include <botan/mem_ops.h>
#include <algorithm>
#include <exception>
diff --git a/src/alloc/system_alloc/defalloc.cpp b/src/alloc/system_alloc/defalloc.cpp
index 8791c74e4..b1b338d71 100644
--- a/src/alloc/system_alloc/defalloc.cpp
+++ b/src/alloc/system_alloc/defalloc.cpp
@@ -7,7 +7,7 @@
#include <botan/defalloc.h>
#include <botan/libstate.h>
-#include <botan/util.h>
+#include <botan/mlock.h>
#include <cstdlib>
#include <cstring>
diff --git a/src/benchmark/benchmark.cpp b/src/benchmark/benchmark.cpp
index ff7519c09..4381ee998 100644
--- a/src/benchmark/benchmark.cpp
+++ b/src/benchmark/benchmark.cpp
@@ -11,7 +11,6 @@
#include <botan/stream_cipher.h>
#include <botan/hash.h>
#include <botan/mac.h>
-#include <botan/util.h>
#include <memory>
#include <vector>
#include <chrono>
diff --git a/src/cert/cvc/cvc_ca.cpp b/src/cert/cvc/cvc_ca.cpp
index 20cea9104..b51c1f4ff 100644
--- a/src/cert/cvc/cvc_ca.cpp
+++ b/src/cert/cvc/cvc_ca.cpp
@@ -1,7 +1,6 @@
#include <botan/cvc_ca.h>
#include <botan/cvc_cert.h>
#include <botan/der_enc.h>
-#include <botan/util.h>
#include <botan/oids.h>
namespace Botan {
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index 6a81c40ec..46bf145fc 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -14,7 +14,7 @@
#include <botan/look_pk.h>
#include <botan/cvc_req.h>
#include <botan/cvc_ado.h>
-#include <botan/util.h>
+#include <botan/timer.h>
#include <sstream>
namespace Botan {
diff --git a/src/cert/x509/crl_ent.cpp b/src/cert/x509/crl_ent.cpp
index afea8cf6b..a8a989c24 100644
--- a/src/cert/x509/crl_ent.cpp
+++ b/src/cert/x509/crl_ent.cpp
@@ -11,7 +11,7 @@
#include <botan/ber_dec.h>
#include <botan/bigint.h>
#include <botan/oids.h>
-#include <botan/util.h>
+#include <botan/timer.h>
namespace Botan {
diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp
index 05cdce411..c3ab2a739 100644
--- a/src/cert/x509/x509_ca.cpp
+++ b/src/cert/x509/x509_ca.cpp
@@ -13,7 +13,7 @@
#include <botan/bigint.h>
#include <botan/parsing.h>
#include <botan/oids.h>
-#include <botan/util.h>
+#include <botan/timer.h>
#include <algorithm>
#include <typeinfo>
#include <iterator>
diff --git a/src/cert/x509/x509opt.cpp b/src/cert/x509/x509opt.cpp
index de9d589a3..988ab2cfa 100644
--- a/src/cert/x509/x509opt.cpp
+++ b/src/cert/x509/x509opt.cpp
@@ -6,9 +6,9 @@
*/
#include <botan/x509self.h>
-#include <botan/util.h>
-#include <botan/parsing.h>
#include <botan/oids.h>
+#include <botan/parsing.h>
+#include <botan/timer.h>
#include <ctime>
namespace Botan {
diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp
index f91da890b..9c6dced25 100644
--- a/src/cert/x509/x509stor.cpp
+++ b/src/cert/x509/x509stor.cpp
@@ -10,7 +10,7 @@
#include <botan/pubkey.h>
#include <botan/look_pk.h>
#include <botan/oids.h>
-#include <botan/util.h>
+#include <botan/timer.h>
#include <algorithm>
#include <memory>
diff --git a/src/engine/openssl/ossl_bc.cpp b/src/engine/openssl/ossl_bc.cpp
index 4d3761adb..dd6bb38db 100644
--- a/src/engine/openssl/ossl_bc.cpp
+++ b/src/engine/openssl/ossl_bc.cpp
@@ -27,8 +27,8 @@ class EVP_BlockCipher : public BlockCipher
~EVP_BlockCipher();
private:
- void enc(const byte[], byte[]) const;
- void dec(const byte[], byte[]) const;
+ void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
void key_schedule(const byte[], u32bit);
std::string cipher_name;
mutable EVP_CIPHER_CTX encrypt, decrypt;
@@ -90,19 +90,21 @@ EVP_BlockCipher::~EVP_BlockCipher()
/*
* Encrypt a block
*/
-void EVP_BlockCipher::enc(const byte in[], byte out[]) const
+void EVP_BlockCipher::encrypt_n(const byte in[], byte out[],
+ u32bit blocks) const
{
int out_len = 0;
- EVP_EncryptUpdate(&encrypt, out, &out_len, in, BLOCK_SIZE);
+ EVP_EncryptUpdate(&encrypt, out, &out_len, in, blocks * BLOCK_SIZE);
}
/*
* Decrypt a block
*/
-void EVP_BlockCipher::dec(const byte in[], byte out[]) const
+void EVP_BlockCipher::decrypt_n(const byte in[], byte out[],
+ u32bit blocks) const
{
int out_len = 0;
- EVP_DecryptUpdate(&decrypt, out, &out_len, in, BLOCK_SIZE);
+ EVP_DecryptUpdate(&decrypt, out, &out_len, in, blocks * BLOCK_SIZE);
}
/*
@@ -174,7 +176,7 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request,
if(request.algo_name() == NAME && request.arg_count() == 0) \
return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD);
-#if 0
+#if 0 && !defined(OPENSSL_NO_AES)
/*
Using OpenSSL's AES causes crashes inside EVP on x86-64 with OpenSSL 0.9.8g
cause is unknown
@@ -184,12 +186,30 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request,
HANDLE_EVP_CIPHER("AES-256", EVP_aes_256_ecb());
#endif
+#if !defined(OPENSSL_NO_DES)
HANDLE_EVP_CIPHER("DES", EVP_des_ecb());
HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8);
+#endif
+#if !defined(OPENSSL_NO_BF)
HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1);
+#endif
+
+#if !defined(OPENSSL_NO_CAST)
HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1);
+#endif
+
+#if !defined(OPENSSL_NO_RC2)
HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1);
+#endif
+
+#if !defined(OPENSSL_NO_IDEA)
+ HANDLE_EVP_CIPHER("IDEA", EVP_idea_ecb());
+#endif
+
+#if !defined(OPENSSL_NO_SEED)
+ HANDLE_EVP_CIPHER("SEED", EVP_seed_ecb());
+#endif
#undef HANDLE_EVP_CIPHER
#undef HANDLE_EVP_CIPHER_KEYLEN
diff --git a/src/engine/openssl/ossl_md.cpp b/src/engine/openssl/ossl_md.cpp
index 7c8fb678c..42975c8a3 100644
--- a/src/engine/openssl/ossl_md.cpp
+++ b/src/engine/openssl/ossl_md.cpp
@@ -95,27 +95,41 @@ EVP_HashFunction::~EVP_HashFunction()
HashFunction* OpenSSL_Engine::find_hash(const SCAN_Name& request,
Algorithm_Factory&) const
{
-#ifndef OPENSSL_NO_SHA
+#if !defined(OPENSSL_NO_SHA)
if(request.algo_name() == "SHA-160")
return new EVP_HashFunction(EVP_sha1(), "SHA-160");
#endif
-#ifndef OPENSSL_NO_MD2
+#if !defined(OPENSSL_NO_SHA256)
+ if(request.algo_name() == "SHA-224")
+ return new EVP_HashFunction(EVP_sha224(), "SHA-224");
+ if(request.algo_name() == "SHA-256")
+ return new EVP_HashFunction(EVP_sha256(), "SHA-256");
+#endif
+
+#if !defined(OPENSSL_NO_SHA512)
+ if(request.algo_name() == "SHA-384")
+ return new EVP_HashFunction(EVP_sha384(), "SHA-384");
+ if(request.algo_name() == "SHA-512")
+ return new EVP_HashFunction(EVP_sha512(), "SHA-512");
+#endif
+
+#if !defined(OPENSSL_NO_MD2)
if(request.algo_name() == "MD2")
return new EVP_HashFunction(EVP_md2(), "MD2");
#endif
-#ifndef OPENSSL_NO_MD4
+#if !defined(OPENSSL_NO_MD4)
if(request.algo_name() == "MD4")
return new EVP_HashFunction(EVP_md4(), "MD4");
#endif
-#ifndef OPENSSL_NO_MD5
+#if !defined(OPENSSL_NO_MD5)
if(request.algo_name() == "MD5")
return new EVP_HashFunction(EVP_md5(), "MD5");
#endif
-#ifndef OPENSSL_NO_RIPEMD
+#if !defined(OPENSSL_NO_RIPEMD)
if(request.algo_name() == "RIPEMD-160")
return new EVP_HashFunction(EVP_ripemd160(), "RIPEMD-160");
#endif
diff --git a/src/math/bigint/bigint.cpp b/src/math/bigint/bigint.cpp
index 926bedc02..63bdc3605 100644
--- a/src/math/bigint/bigint.cpp
+++ b/src/math/bigint/bigint.cpp
@@ -9,7 +9,7 @@
#include <botan/mp_core.h>
#include <botan/loadstor.h>
#include <botan/parsing.h>
-#include <botan/util.h>
+#include <botan/rounding.h>
namespace Botan {
diff --git a/src/math/numbertheory/mp_numth.cpp b/src/math/numbertheory/mp_numth.cpp
index 45a398440..2cb36b8a3 100644
--- a/src/math/numbertheory/mp_numth.cpp
+++ b/src/math/numbertheory/mp_numth.cpp
@@ -7,7 +7,7 @@
#include <botan/numthry.h>
#include <botan/mp_core.h>
-#include <botan/util.h>
+#include <botan/rounding.h>
#include <algorithm>
namespace Botan {
diff --git a/src/modes/mode_pad/mode_pad.cpp b/src/modes/mode_pad/mode_pad.cpp
index b8badd7a7..2204c28b5 100644
--- a/src/modes/mode_pad/mode_pad.cpp
+++ b/src/modes/mode_pad/mode_pad.cpp
@@ -7,7 +7,6 @@
#include <botan/mode_pad.h>
#include <botan/exceptn.h>
-#include <botan/util.h>
namespace Botan {
diff --git a/src/pubkey/dh/dh.cpp b/src/pubkey/dh/dh.cpp
index 0c9d02f0e..149bc5882 100644
--- a/src/pubkey/dh/dh.cpp
+++ b/src/pubkey/dh/dh.cpp
@@ -7,7 +7,7 @@
#include <botan/dh.h>
#include <botan/numthry.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
namespace Botan {
diff --git a/src/pubkey/dl_group/dl_group.cpp b/src/pubkey/dl_group/dl_group.cpp
index 81c5d5e1d..13ea03016 100644
--- a/src/pubkey/dl_group/dl_group.cpp
+++ b/src/pubkey/dl_group/dl_group.cpp
@@ -12,7 +12,7 @@
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/pipe.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
#include <botan/pem.h>
namespace Botan {
diff --git a/src/pubkey/ecc_key/ecc_key.cpp b/src/pubkey/ecc_key/ecc_key.cpp
index 6c7d02c74..8d9e89f1e 100644
--- a/src/pubkey/ecc_key/ecc_key.cpp
+++ b/src/pubkey/ecc_key/ecc_key.cpp
@@ -10,7 +10,6 @@
#include <botan/ecc_key.h>
#include <botan/x509_key.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/ecdsa/ecdsa.cpp b/src/pubkey/ecdsa/ecdsa.cpp
index 3e3bbf38a..4cabf5e5b 100644
--- a/src/pubkey/ecdsa/ecdsa.cpp
+++ b/src/pubkey/ecdsa/ecdsa.cpp
@@ -9,7 +9,6 @@
#include <botan/ecdsa.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/eckaeg/eckaeg.cpp b/src/pubkey/eckaeg/eckaeg.cpp
index 5787f062d..a2dec5279 100644
--- a/src/pubkey/eckaeg/eckaeg.cpp
+++ b/src/pubkey/eckaeg/eckaeg.cpp
@@ -9,7 +9,6 @@
#include <botan/eckaeg.h>
#include <botan/numthry.h>
-#include <botan/util.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/secmem.h>
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp
index 1f79df57a..8c07c5735 100644
--- a/src/pubkey/elgamal/elgamal.cpp
+++ b/src/pubkey/elgamal/elgamal.cpp
@@ -9,7 +9,7 @@
#include <botan/numthry.h>
#include <botan/keypair.h>
#include <botan/look_pk.h>
-#include <botan/util.h>
+#include <botan/workfactor.h>
namespace Botan {
diff --git a/src/pubkey/info.txt b/src/pubkey/info.txt
index ee8da5b9d..63af86c47 100644
--- a/src/pubkey/info.txt
+++ b/src/pubkey/info.txt
@@ -15,6 +15,8 @@ pubkey.cpp
pubkey.h
pubkey_enums.cpp
pubkey_enums.h
+workfactor.cpp
+workfactor.h
</add>
<requires>
diff --git a/src/utils/util.cpp b/src/pubkey/workfactor.cpp
index 84dfd1a14..e40b7919c 100644
--- a/src/utils/util.cpp
+++ b/src/pubkey/workfactor.cpp
@@ -1,35 +1,17 @@
/*
-* Utility Functions
+* Public Key Work Factor Functions
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
-#include <botan/util.h>
+#include <botan/workfactor.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)
@@ -65,4 +47,5 @@ u32bit dl_work_factor(u32bit bits)
#endif
}
+
}
diff --git a/src/pubkey/workfactor.h b/src/pubkey/workfactor.h
new file mode 100644
index 000000000..653f697e3
--- /dev/null
+++ b/src/pubkey/workfactor.h
@@ -0,0 +1,22 @@
+/*
+* Public Key Work Factor Functions
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_WORKFACTOR_H__
+#define BOTAN_WORKFACTOR_H__
+
+#include <botan/types.h>
+
+namespace Botan {
+
+/*
+* Work Factor Estimates
+*/
+BOTAN_DLL u32bit dl_work_factor(u32bit prime_group_size);
+
+}
+
+#endif
diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp
index 113489db3..8444b1083 100644
--- a/src/rng/hmac_rng/hmac_rng.cpp
+++ b/src/rng/hmac_rng/hmac_rng.cpp
@@ -8,7 +8,6 @@
#include <botan/hmac_rng.h>
#include <botan/loadstor.h>
#include <botan/xor_buf.h>
-#include <botan/util.h>
#include <botan/stl_util.h>
#include <algorithm>
diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp
index 77a5228c6..fe83f4361 100644
--- a/src/rng/randpool/randpool.cpp
+++ b/src/rng/randpool/randpool.cpp
@@ -8,7 +8,7 @@
#include <botan/randpool.h>
#include <botan/loadstor.h>
#include <botan/xor_buf.h>
-#include <botan/util.h>
+#include <botan/timer.h>
#include <botan/stl_util.h>
#include <algorithm>
diff --git a/src/timer/gettimeofday/tm_unix.cpp b/src/timer/gettimeofday/tm_unix.cpp
index e32df7166..9d8ac4a04 100644
--- a/src/timer/gettimeofday/tm_unix.cpp
+++ b/src/timer/gettimeofday/tm_unix.cpp
@@ -6,7 +6,6 @@
*/
#include <botan/tm_unix.h>
-#include <botan/util.h>
#include <sys/time.h>
namespace Botan {
diff --git a/src/timer/posix_rt/tm_posix.cpp b/src/timer/posix_rt/tm_posix.cpp
index d356384ab..96182025c 100644
--- a/src/timer/posix_rt/tm_posix.cpp
+++ b/src/timer/posix_rt/tm_posix.cpp
@@ -6,7 +6,6 @@
*/
#include <botan/tm_posix.h>
-#include <botan/util.h>
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309
diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp
index 035c217f9..e3e3c5a16 100644
--- a/src/timer/timer.cpp
+++ b/src/timer/timer.cpp
@@ -7,7 +7,6 @@
#include <botan/timer.h>
#include <botan/loadstor.h>
-#include <botan/util.h>
#include <ctime>
namespace Botan {
diff --git a/src/timer/timer.h b/src/timer/timer.h
index b6e8ef448..3bbe85a5e 100644
--- a/src/timer/timer.h
+++ b/src/timer/timer.h
@@ -12,6 +12,11 @@
namespace Botan {
+/*
+* Time Access Functions
+*/
+BOTAN_DLL u64bit system_time();
+
/**
* Timer Interface
*/
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.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