aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/logs/log-17.txt23
-rw-r--r--include/config.h2
-rw-r--r--include/defalloc.h1
-rw-r--r--include/exceptn.h8
-rw-r--r--include/mem_pool.h4
-rw-r--r--include/out_buf.h13
-rw-r--r--include/parsing.h1
-rw-r--r--include/pipe.h8
-rw-r--r--include/selftest.h (renamed from include/fips140.h)12
-rw-r--r--misc/config/buildh.in2
-rw-r--r--modules/alg_amd64/asm_macr.h15
-rw-r--r--modules/alg_amd64/mp_mulop.S23
-rw-r--r--modules/alg_amd64/sha160.cpp4
-rw-r--r--modules/alg_amd64/sha1core.S20
-rw-r--r--modules/alloc_mmap/mmap_mem.h1
-rw-r--r--readme.txt13
-rw-r--r--src/big_code.cpp7
-rw-r--r--src/config.cpp16
-rw-r--r--src/exceptn.cpp10
-rw-r--r--src/libstate.cpp6
-rw-r--r--src/mem_pool.cpp22
-rw-r--r--src/modules.cpp13
-rw-r--r--src/out_buf.cpp16
-rw-r--r--src/parsing.cpp28
-rw-r--r--src/pipe.cpp20
-rw-r--r--src/pipe_rw.cpp3
-rw-r--r--src/pk_core.cpp22
-rw-r--r--src/pkcs8.cpp3
-rw-r--r--src/policy.cpp3
-rw-r--r--src/selftest.cpp (renamed from src/fips140.cpp)14
30 files changed, 126 insertions, 207 deletions
diff --git a/doc/logs/log-17.txt b/doc/logs/log-17.txt
index eab4bd180..b2de3e258 100644
--- a/doc/logs/log-17.txt
+++ b/doc/logs/log-17.txt
@@ -1,16 +1,15 @@
-* 1.7.5
-
- - Remove the Named_Mutex_Holder. Probably only used internally, it
- was known to take up too much time for what it was doing, for a
- very small gain in readability.
-
- - New typedef Pipe::message_id
-
- - Add a new constructor for DataSource_Stream taking an istream
-
- - Remove the Named_Mutex_Holder
- - Use a typedef in Pipe to represent the message number
+* 1.7.5, April 13, 2008
+ - The API of X509_CA::sign_request was altered to avoid race conditions
+ - New type Pipe::message_id to represent the Pipe message number
+ - Remove the Named_Mutex_Holder for a small performance gain
+ - Removed several unused or rarely used functions from Config
+ - Ignore spaces inside of a decimal string in BigInt::decode
+ - Allow using a std::istream to initialize a DataSource_Stream object
+ - Fix compilation problem in zlib compression module
+ - The chunk sized used by Pooling_Allocator is now a compile time setting
+ - The size of random blinding factors is now a compile time setting
+ - The install target no longer tries to set a particular owner/group
* 1.7.4, March 10, 2008
- Use unaligned memory read/writes on systems that allow it, for performance
diff --git a/include/config.h b/include/config.h
index 67766dcb7..86344cc86 100644
--- a/include/config.h
+++ b/include/config.h
@@ -31,9 +31,7 @@ class Config
const std::string&, bool = true);
std::string option(const std::string&) const;
- u32bit option_as_u32bit(const std::string&) const;
u32bit option_as_time(const std::string&) const;
- std::vector<std::string> option_as_list(const std::string&) const;
void set_option(const std::string, const std::string&);
diff --git a/include/defalloc.h b/include/defalloc.h
index 69c162ac4..6d25909ff 100644
--- a/include/defalloc.h
+++ b/include/defalloc.h
@@ -28,7 +28,6 @@ class Malloc_Allocator : public Allocator
class Locking_Allocator : public Pooling_Allocator
{
public:
- Locking_Allocator() : Pooling_Allocator(64*1024, true) {}
std::string type() const { return "locking"; }
private:
void* alloc_block(u32bit);
diff --git a/include/exceptn.h b/include/exceptn.h
index 1381782cf..5b0106105 100644
--- a/include/exceptn.h
+++ b/include/exceptn.h
@@ -60,14 +60,6 @@ struct Invalid_IV_Length : public Invalid_Argument
};
/*************************************************
-* Invalid_Message_Number Exception *
-*************************************************/
-struct Invalid_Message_Number : public Invalid_Argument
- {
- Invalid_Message_Number(const std::string&, u32bit);
- };
-
-/*************************************************
* Invalid_State Exception *
*************************************************/
struct Invalid_State : public Exception
diff --git a/include/mem_pool.h b/include/mem_pool.h
index 9d6d8d31d..a39e88f07 100644
--- a/include/mem_pool.h
+++ b/include/mem_pool.h
@@ -25,7 +25,7 @@ class Pooling_Allocator : public Allocator
void destroy();
- Pooling_Allocator(u32bit, bool);
+ Pooling_Allocator();
~Pooling_Allocator();
private:
void get_more_core(u32bit);
@@ -61,7 +61,7 @@ class Pooling_Allocator : public Allocator
byte* buffer, *buffer_end;
};
- const u32bit PREF_SIZE;
+ static const u32bit PREF_SIZE = BOTAN_MEM_POOL_CHUNK_SIZE;
std::vector<Memory_Block> blocks;
std::vector<Memory_Block>::iterator last_used;
diff --git a/include/out_buf.h b/include/out_buf.h
index 8965e3895..1e169b9bc 100644
--- a/include/out_buf.h
+++ b/include/out_buf.h
@@ -7,6 +7,7 @@
#define BOTAN_OUTPUT_BUFFER_H__
#include <botan/types.h>
+#include <botan/pipe.h>
#include <deque>
namespace Botan {
@@ -17,22 +18,22 @@ namespace Botan {
class Output_Buffers
{
public:
- u32bit read(byte[], u32bit, u32bit);
- u32bit peek(byte[], u32bit, u32bit, u32bit) const;
- u32bit remaining(u32bit) const;
+ u32bit read(byte[], u32bit, Pipe::message_id);
+ u32bit peek(byte[], u32bit, u32bit, Pipe::message_id) const;
+ u32bit remaining(Pipe::message_id) const;
void add(class SecureQueue*);
void retire();
- u32bit message_count() const;
+ Pipe::message_id message_count() const;
Output_Buffers();
~Output_Buffers();
private:
- class SecureQueue* get(u32bit) const;
+ class SecureQueue* get(Pipe::message_id) const;
std::deque<SecureQueue*> buffers;
- u32bit offset;
+ Pipe::message_id offset;
};
}
diff --git a/include/parsing.h b/include/parsing.h
index 93eb8c279..9c9128d33 100644
--- a/include/parsing.h
+++ b/include/parsing.h
@@ -19,7 +19,6 @@ std::vector<std::string> parse_algorithm_name(const std::string&);
std::vector<std::string> split_on(const std::string&, char);
std::vector<u32bit> parse_asn1_oid(const std::string&);
bool x500_name_cmp(const std::string&, const std::string&);
-u32bit parse_expr(const std::string&);
/*************************************************
* String/Integer Conversions *
diff --git a/include/pipe.h b/include/pipe.h
index 20fdc6a41..89f1ac4db 100644
--- a/include/pipe.h
+++ b/include/pipe.h
@@ -20,6 +20,12 @@ class Pipe : public DataSource
public:
typedef u32bit message_id;
+ class Invalid_Message_Number : public Invalid_Argument
+ {
+ public:
+ Invalid_Message_Number(const std::string&, message_id);
+ };
+
static const message_id LAST_MESSAGE, DEFAULT_MESSAGE;
void write(const byte[], u32bit);
@@ -48,7 +54,7 @@ class Pipe : public DataSource
message_id default_msg() const { return default_read; }
void set_default_msg(message_id);
- u32bit message_count() const;
+ message_id message_count() const;
bool end_of_data() const;
void start_msg();
diff --git a/include/fips140.h b/include/selftest.h
index b0cae081e..1283b3dd4 100644
--- a/include/fips140.h
+++ b/include/selftest.h
@@ -1,24 +1,20 @@
/*************************************************
-* FIPS 140 Header File *
+* Startup Self Test Header File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
-#ifndef BOTAN_FIPS140_H__
-#define BOTAN_FIPS140_H__
+#ifndef BOTAN_SELF_TEST_H__
+#define BOTAN_SELF_TEST_H__
#include <botan/base.h>
namespace Botan {
-namespace FIPS140 {
-
/*************************************************
-* FIPS 140-2 Self Tests *
+* Self Tests *
*************************************************/
bool passes_self_tests();
}
-}
-
#endif
diff --git a/misc/config/buildh.in b/misc/config/buildh.in
index 2816eface..46743aac9 100644
--- a/misc/config/buildh.in
+++ b/misc/config/buildh.in
@@ -12,6 +12,8 @@
#define BOTAN_MP_WORD_BITS @{var:mp_bits}
#define BOTAN_DEFAULT_BUFFER_SIZE 4096
+#define BOTAN_MEM_POOL_CHUNK_SIZE 64*1024
+#define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64
#define BOTAN_KARAT_MUL_THRESHOLD 12
#define BOTAN_KARAT_SQR_THRESHOLD 12
diff --git a/modules/alg_amd64/asm_macr.h b/modules/alg_amd64/asm_macr.h
index 380d05b02..4ac98bd03 100644
--- a/modules/alg_amd64/asm_macr.h
+++ b/modules/alg_amd64/asm_macr.h
@@ -29,21 +29,6 @@ func_name:
ret
/*************************************************
-* Loop Control *
-*************************************************/
-#define START_LOOP(LABEL) \
- ALIGN; \
- LABEL##_LOOP:
-
-#define LOOP_UNTIL_EQ(REG, NUM, LABEL) \
- cmp IMM(NUM), REG; \
- jne LABEL##_LOOP
-
-#define LOOP_UNTIL_LT(REG, NUM, LABEL) \
- cmp IMM(NUM), REG; \
- jge LABEL##_LOOP
-
-/*************************************************
* Conditional Jumps *
*************************************************/
#define JUMP_IF_ZERO(REG, LABEL) \
diff --git a/modules/alg_amd64/mp_mulop.S b/modules/alg_amd64/mp_mulop.S
index f1a2a2e75..983a34a82 100644
--- a/modules/alg_amd64/mp_mulop.S
+++ b/modules/alg_amd64/mp_mulop.S
@@ -1,6 +1,6 @@
/*************************************************
* Multiply/Add Algorithm Source File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#include <botan/asm_macr.h>
@@ -24,8 +24,8 @@ START_FUNCTION(bigint_mul_add_words)
ASSIGN(LOOP_CTR, X_SIZE)
- JUMP_IF_ZERO(LOOP_CTR, .DONE)
- JUMP_IF_LT(LOOP_CTR, 8, .MULADD1_LOOP)
+ JUMP_IF_ZERO(LOOP_CTR, .L_MULADD_DONE)
+ JUMP_IF_LT(LOOP_CTR, 8, .LOOP_MULADD1)
#define MULADD_OP(N) \
ASSIGN(MUL_LO, ARRAY8(X_ARR, N)) ; \
@@ -38,7 +38,8 @@ START_FUNCTION(bigint_mul_add_words)
ADD_LAST_CARRY(CARRY) ; \
ASSIGN(ARRAY8(Z_ARR, N), Z_WORD)
-START_LOOP(.MULADD8)
+ALIGN
+.LOOP_MULADD8:
MULADD_OP(0)
MULADD_OP(1)
MULADD_OP(2)
@@ -51,18 +52,22 @@ START_LOOP(.MULADD8)
SUB_IMM(LOOP_CTR, 8)
ADD_IMM(Z_ARR, 64)
ADD_IMM(X_ARR, 64)
-LOOP_UNTIL_LT(LOOP_CTR, 8, .MULADD8)
+ cmp IMM(8), LOOP_CTR
+ jge .LOOP_MULADD8
- JUMP_IF_ZERO(LOOP_CTR, .DONE)
+ JUMP_IF_ZERO(LOOP_CTR, .L_MULADD_DONE)
-START_LOOP(.MULADD1)
+ALIGN
+.LOOP_MULADD1:
MULADD_OP(0)
SUB_IMM(LOOP_CTR, 1)
ADD_IMM(Z_ARR, 8)
ADD_IMM(X_ARR, 8)
-LOOP_UNTIL_EQ(LOOP_CTR, 0, .MULADD1)
-.DONE:
+ cmp IMM(0), LOOP_CTR
+ jne .LOOP_MULADD1
+
+.L_MULADD_DONE:
RETURN_VALUE_IS(CARRY)
END_FUNCTION(bigint_mul_add_words)
diff --git a/modules/alg_amd64/sha160.cpp b/modules/alg_amd64/sha160.cpp
index 180f050c9..97ec9d522 100644
--- a/modules/alg_amd64/sha160.cpp
+++ b/modules/alg_amd64/sha160.cpp
@@ -8,14 +8,14 @@
namespace Botan {
-extern "C" void sha160_core(u32bit[5], const byte[64], u32bit[80]);
+extern "C" void botan_asm_sha160_core(u32bit[5], const byte[64], u32bit[80]);
/*************************************************
* SHA-160 Compression Function *
*************************************************/
void SHA_160::hash(const byte input[])
{
- sha160_core(digest, input, W);
+ botan_asm_sha160_core(digest, input, W);
}
/*************************************************
diff --git a/modules/alg_amd64/sha1core.S b/modules/alg_amd64/sha1core.S
index c3f530d70..f145f8517 100644
--- a/modules/alg_amd64/sha1core.S
+++ b/modules/alg_amd64/sha1core.S
@@ -7,7 +7,7 @@
START_LISTING(sha1core.S)
-START_FUNCTION(sha160_core)
+START_FUNCTION(botan_asm_sha160_core)
#define DIGEST_ARR %rdi
#define INPUT %rsi
@@ -22,7 +22,8 @@ START_FUNCTION(sha160_core)
ZEROIZE(LOOP_CTR)
-START_LOOP(.LOAD_INPUT)
+ALIGN;
+.LOOP_LOAD_INPUT:
addl $8, %eax
movq ARRAY8(INPUT, 0), %r8
@@ -47,16 +48,20 @@ START_LOOP(.LOAD_INPUT)
addq $32, W
addq $32, INPUT
-LOOP_UNTIL_EQ(LOOP_CTR, 16, .LOAD_INPUT)
+
+ cmp IMM(16), LOOP_CTR
+ jne .LOOP_LOAD_INPUT
/*
- #define A %r8d
+#define A %r8d
#define B %r9d
#define C %r10d
#define D %r11d
#define E %ecx
*/
-START_LOOP(.EXPANSION)
+
+ALIGN;
+.LOOP_EXPANSION:
addl $4, LOOP_CTR
ZEROIZE(A)
@@ -91,7 +96,8 @@ START_LOOP(.EXPANSION)
ASSIGN(ARRAY4(W, 3), A)
addq $16, W
-LOOP_UNTIL_EQ(LOOP_CTR, 80, .EXPANSION)
+ cmp IMM(80), LOOP_CTR
+ jne .LOOP_EXPANSION
subq $320, W
@@ -249,4 +255,4 @@ LOOP_UNTIL_EQ(LOOP_CTR, 80, .EXPANSION)
ADD(ARRAY4(DIGEST_ARR, 3), B)
ADD(ARRAY4(DIGEST_ARR, 4), C)
-END_FUNCTION(sha160_core)
+END_FUNCTION(botan_asm_sha160_core)
diff --git a/modules/alloc_mmap/mmap_mem.h b/modules/alloc_mmap/mmap_mem.h
index 315f55b2e..ddf999014 100644
--- a/modules/alloc_mmap/mmap_mem.h
+++ b/modules/alloc_mmap/mmap_mem.h
@@ -16,7 +16,6 @@ namespace Botan {
class MemoryMapping_Allocator : public Pooling_Allocator
{
public:
- MemoryMapping_Allocator() : Pooling_Allocator(64*1024, false) {}
std::string type() const { return "mmap"; }
private:
void* alloc_block(u32bit);
diff --git a/readme.txt b/readme.txt
index c6eef310b..5f164b614 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,15 +1,14 @@
-Botan 1.7.4
+Botan 1.7.5 (prerelease)
http://botan.randombit.net/
Please note that this is an experimental / development version of
Botan. Feedback and critical analysis is highly appreciated. There may
-be bugs (as always). If this sounds scary, it's recommended you use
-the latest stable (1.6) release.
+be bugs (as always). APIs may be changed with little or no notice. If
+this sounds scary, it's recommended you use the latest stable release
+instead.
-You can file bugs at http://www.randombit.net/bugzilla
+You can file bugs at http://www.randombit.net/bugzilla or by sending
+mail to the botan-devel mailing list.
For more information, see info.txt, the API manual, and the tutorial,
all of which can be found in the doc/ directory.
-
-Jack
diff --git a/src/big_code.cpp b/src/big_code.cpp
index 4755e3cc1..824cbb63e 100644
--- a/src/big_code.cpp
+++ b/src/big_code.cpp
@@ -124,6 +124,13 @@ BigInt BigInt::decode(const byte buf[], u32bit length, Base base)
const u32bit RADIX = ((base == Decimal) ? 10 : 8);
for(u32bit j = 0; j != length; ++j)
{
+ if(Charset::is_space(buf[j]))
+ continue;
+
+ if(!Charset::is_digit(buf[j]))
+ throw Invalid_Argument("BigInt::decode: "
+ "Invalid character in decimal input");
+
byte x = Charset::char2digit(buf[j]);
if(x >= RADIX)
{
diff --git a/src/config.cpp b/src/config.cpp
index bc950dcff..bcca49bdf 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -122,22 +122,6 @@ std::string Config::option(const std::string& key) const
}
/*************************************************
-* Get the config setting as a list of strings *
-*************************************************/
-std::vector<std::string> Config::option_as_list(const std::string& key) const
- {
- return split_on(option(key), ':');
- }
-
-/*************************************************
-* Get the config setting as a u32bit *
-*************************************************/
-u32bit Config::option_as_u32bit(const std::string& key) const
- {
- return parse_expr(option(key));
- }
-
-/*************************************************
* Get the config setting as a time *
*************************************************/
u32bit Config::option_as_time(const std::string& key) const
diff --git a/src/exceptn.cpp b/src/exceptn.cpp
index 07e6bb419..29357afa5 100644
--- a/src/exceptn.cpp
+++ b/src/exceptn.cpp
@@ -34,16 +34,6 @@ Invalid_IV_Length::Invalid_IV_Length(const std::string& mode, u32bit bad_len)
}
/*************************************************
-* Constructor for Invalid_Message_Number *
-*************************************************/
-Invalid_Message_Number::Invalid_Message_Number(const std::string& where,
- u32bit message_no)
- {
- set_msg("Pipe::" + where + ": Invalid message number " +
- to_string(message_no));
- }
-
-/*************************************************
* Constructor for Algorithm_Not_Found *
*************************************************/
Algorithm_Not_Found::Algorithm_Not_Found(const std::string& name)
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 260d37bf5..db2d124a8 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -11,7 +11,7 @@
#include <botan/mutex.h>
#include <botan/charset.h>
#include <botan/x931_rng.h>
-#include <botan/fips140.h>
+#include <botan/selftest.h>
#include <algorithm>
namespace Botan {
@@ -289,8 +289,8 @@ void Library_State::initialize(const InitializerOptions& args,
if(args.fips_mode() || args.self_test())
{
- if(!FIPS140::passes_self_tests())
- throw Self_Test_Failure("FIPS-140 startup tests");
+ if(!passes_self_tests())
+ throw Self_Test_Failure("Initialization self-tests");
}
}
diff --git a/src/mem_pool.cpp b/src/mem_pool.cpp
index df4237106..7ab121ffb 100644
--- a/src/mem_pool.cpp
+++ b/src/mem_pool.cpp
@@ -13,25 +13,6 @@
namespace Botan {
-namespace {
-
-/*************************************************
-* Decide how much memory to allocate at once *
-*************************************************/
-u32bit choose_pref_size(u32bit provided)
- {
- if(provided)
- return provided;
-
- u32bit result = global_config().option_as_u32bit("base/memory_chunk");
- if(result)
- return result;
-
- return 16*1024;
- }
-
-}
-
/*************************************************
* Memory_Block Constructor *
*************************************************/
@@ -113,8 +94,7 @@ void Pooling_Allocator::Memory_Block::free(void* ptr, u32bit blocks) throw()
/*************************************************
* Pooling_Allocator Constructor *
*************************************************/
-Pooling_Allocator::Pooling_Allocator(u32bit p_size, bool) :
- PREF_SIZE(choose_pref_size(p_size))
+Pooling_Allocator::Pooling_Allocator()
{
mutex = global_state().get_mutex();
last_used = blocks.begin();
diff --git a/src/modules.cpp b/src/modules.cpp
index ffce244d1..b69e6c5f7 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -151,12 +151,17 @@ std::vector<EntropySource*> Builtin_Modules::entropy_sources() const
#endif
#if defined(BOTAN_EXT_ENTROPY_SRC_EGD)
- sources.push_back(new EGD_EntropySource(split_on("/var/run/egd-pool:/dev/egd-pool", ':')));
+ sources.push_back(
+ new EGD_EntropySource(split_on("/var/run/egd-pool:/dev/egd-pool", ':'))
+ );
#endif
#if defined(BOTAN_EXT_ENTROPY_SRC_DEVICE)
sources.push_back(
- new Device_EntropySource(split_on("/dev/random:/dev/srandom:/dev/urandom", ':')));
+ new Device_EntropySource(
+ split_on("/dev/random:/dev/srandom:/dev/urandom", ':')
+ )
+ );
#endif
#if defined(BOTAN_EXT_ENTROPY_SRC_CAPI)
@@ -168,7 +173,9 @@ std::vector<EntropySource*> Builtin_Modules::entropy_sources() const
#endif
#if defined(BOTAN_EXT_ENTROPY_SRC_UNIX)
- sources.push_back(new Unix_EntropySource(split_on("/bin:/sbin:/usr/bin:/usr/sbin", ':')));
+ sources.push_back(
+ new Unix_EntropySource(split_on("/bin:/sbin:/usr/bin:/usr/sbin", ':'))
+ );
#endif
#if defined(BOTAN_EXT_ENTROPY_SRC_BEOS)
diff --git a/src/out_buf.cpp b/src/out_buf.cpp
index 2586d65c2..392592705 100644
--- a/src/out_buf.cpp
+++ b/src/out_buf.cpp
@@ -11,7 +11,8 @@ namespace Botan {
/*************************************************
* Read data from a message *
*************************************************/
-u32bit Output_Buffers::read(byte output[], u32bit length, u32bit msg)
+u32bit Output_Buffers::read(byte output[], u32bit length,
+ Pipe::message_id msg)
{
SecureQueue* q = get(msg);
if(q)
@@ -23,7 +24,8 @@ u32bit Output_Buffers::read(byte output[], u32bit length, u32bit msg)
* Peek at data in a message *
*************************************************/
u32bit Output_Buffers::peek(byte output[], u32bit length,
- u32bit stream_offset, u32bit msg) const
+ u32bit stream_offset,
+ Pipe::message_id msg) const
{
SecureQueue* q = get(msg);
if(q)
@@ -34,7 +36,7 @@ u32bit Output_Buffers::peek(byte output[], u32bit length,
/*************************************************
* Check available bytes in a message *
*************************************************/
-u32bit Output_Buffers::remaining(u32bit msg) const
+u32bit Output_Buffers::remaining(Pipe::message_id msg) const
{
SecureQueue* q = get(msg);
if(q)
@@ -67,7 +69,7 @@ void Output_Buffers::retire()
{
delete buffers[0];
buffers.pop_front();
- ++offset;
+ offset = offset + Pipe::message_id(1);
}
else
break;
@@ -77,7 +79,7 @@ void Output_Buffers::retire()
/*************************************************
* Get a particular output queue *
*************************************************/
-SecureQueue* Output_Buffers::get(u32bit msg) const
+SecureQueue* Output_Buffers::get(Pipe::message_id msg) const
{
if(msg < offset)
return 0;
@@ -90,9 +92,9 @@ SecureQueue* Output_Buffers::get(u32bit msg) const
/*************************************************
* Return the total number of messages *
*************************************************/
-u32bit Output_Buffers::message_count() const
+Pipe::message_id Output_Buffers::message_count() const
{
- return (buffers.size() + offset);
+ return (offset + buffers.size());
}
/*************************************************
diff --git a/src/parsing.cpp b/src/parsing.cpp
index 3cb61cb44..59c0e3324 100644
--- a/src/parsing.cpp
+++ b/src/parsing.cpp
@@ -211,34 +211,6 @@ bool x500_name_cmp(const std::string& name1, const std::string& name2)
}
/*************************************************
-* Parse and compute an arithmetic expression *
-*************************************************/
-u32bit parse_expr(const std::string& expr)
- {
- const bool have_add = (expr.find('+') != std::string::npos);
- const bool have_mul = (expr.find('*') != std::string::npos);
-
- if(have_add)
- {
- std::vector<std::string> sub_expr = split_on(expr, '+');
- u32bit result = 0;
- for(u32bit j = 0; j != sub_expr.size(); ++j)
- result += parse_expr(sub_expr[j]);
- return result;
- }
- else if(have_mul)
- {
- std::vector<std::string> sub_expr = split_on(expr, '*');
- u32bit result = 1;
- for(u32bit j = 0; j != sub_expr.size(); ++j)
- result *= parse_expr(sub_expr[j]);
- return result;
- }
- else
- return to_u32bit(expr);
- }
-
-/*************************************************
* Convert a decimal-dotted string to binary IP *
*************************************************/
u32bit string_to_ipv4(const std::string& str)
diff --git a/src/pipe.cpp b/src/pipe.cpp
index b740e049d..228dc3a22 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -6,9 +6,20 @@
#include <botan/pipe.h>
#include <botan/out_buf.h>
#include <botan/secqueue.h>
+#include <botan/parsing.h>
namespace Botan {
+/*************************************************
+* Constructor for Invalid_Message_Number *
+*************************************************/
+Pipe::Invalid_Message_Number::Invalid_Message_Number(const std::string& where,
+ message_id msg)
+ {
+ set_msg("Pipe::" + where + ": Invalid message number " +
+ to_string(msg));
+ }
+
namespace {
/*************************************************
@@ -276,7 +287,7 @@ void Pipe::pop()
/*************************************************
* Return the number of messages in this Pipe *
*************************************************/
-u32bit Pipe::message_count() const
+Pipe::message_id Pipe::message_count() const
{
return outputs->message_count();
}
@@ -284,7 +295,10 @@ u32bit Pipe::message_count() const
/*************************************************
* Static Member Variables *
*************************************************/
-const Pipe::message_id Pipe::LAST_MESSAGE = static_cast<Pipe::message_id>(-2);
-const Pipe::message_id Pipe::DEFAULT_MESSAGE = static_cast<Pipe::message_id>(-1);
+const Pipe::message_id Pipe::LAST_MESSAGE =
+ static_cast<Pipe::message_id>(-2);
+
+const Pipe::message_id Pipe::DEFAULT_MESSAGE =
+ static_cast<Pipe::message_id>(-1);
}
diff --git a/src/pipe_rw.cpp b/src/pipe_rw.cpp
index 46fce2fd9..58d7dd1ad 100644
--- a/src/pipe_rw.cpp
+++ b/src/pipe_rw.cpp
@@ -12,7 +12,8 @@ namespace Botan {
/*************************************************
* Look up the canonical ID for a queue *
*************************************************/
-Pipe::message_id Pipe::get_message_no(const std::string& func_name, message_id msg) const
+Pipe::message_id Pipe::get_message_no(const std::string& func_name,
+ message_id msg) const
{
if(msg == DEFAULT_MESSAGE)
msg = default_msg();
diff --git a/src/pk_core.cpp b/src/pk_core.cpp
index 14b55543e..42abe7196 100644
--- a/src/pk_core.cpp
+++ b/src/pk_core.cpp
@@ -7,24 +7,14 @@
#include <botan/numthry.h>
#include <botan/engine.h>
#include <botan/config.h>
+#include <botan/parsing.h>
#include <algorithm>
namespace Botan {
namespace {
-/*************************************************
-* Return a new blinding factor *
-*************************************************/
-BigInt blinding_factor(u32bit modulus_size)
- {
- const u32bit BLINDING_BITS =
- global_config().option_as_u32bit("pk/blinder_size");
-
- if(BLINDING_BITS == 0)
- return 0;
- return random_integer(std::min(modulus_size - 1, BLINDING_BITS));
- }
+const u32bit BLINDING_BITS = BOTAN_PRIVATE_KEY_OP_BLINDING_BITS;
}
@@ -39,7 +29,7 @@ IF_Core::IF_Core(const BigInt& e, const BigInt& n, const BigInt& d,
if(d != 0)
{
- BigInt k = blinding_factor(n.bits());
+ BigInt k = random_integer(std::min(n.bits()-1, BLINDING_BITS));
if(k != 0)
blinder = Blinder(power_mod(k, e, n), inverse_mod(k, n), n);
}
@@ -188,9 +178,9 @@ ELG_Core::ELG_Core(const DL_Group& group, const BigInt& y, const BigInt& x)
if(x != 0)
{
const BigInt& p = group.get_p();
- p_bytes = group.get_p().bytes();
+ p_bytes = p.bytes();
- BigInt k = blinding_factor(p.bits());
+ BigInt k = random_integer(std::min(p.bits()-1, BLINDING_BITS));
if(k != 0)
blinder = Blinder(k, power_mod(k, x, p), p);
}
@@ -252,7 +242,7 @@ DH_Core::DH_Core(const DL_Group& group, const BigInt& x)
op = Engine_Core::dh_op(group, x);
const BigInt& p = group.get_p();
- BigInt k = blinding_factor(p.bits());
+ BigInt k = random_integer(std::min(p.bits()-1, BLINDING_BITS));
if(k != 0)
blinder = Blinder(k, power_mod(inverse_mod(k, p), x, p), p);
}
diff --git a/src/pkcs8.cpp b/src/pkcs8.cpp
index c99be316c..b3366acd2 100644
--- a/src/pkcs8.cpp
+++ b/src/pkcs8.cpp
@@ -77,8 +77,7 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
if(!is_encrypted)
key = key_data;
- const u32bit MAX_TRIES =
- global_config().option_as_u32bit("base/pkcs8_tries");
+ const u32bit MAX_TRIES = 3;
u32bit tries = 0;
while(true)
diff --git a/src/policy.cpp b/src/policy.cpp
index 1c4eaa7c1..306a6bb31 100644
--- a/src/policy.cpp
+++ b/src/policy.cpp
@@ -212,13 +212,10 @@ void set_default_aliases(Config& config)
*************************************************/
void set_default_config(Config& config)
{
- config.set_option("base/memory_chunk", "64*1024");
- config.set_option("base/pkcs8_tries", "3");
config.set_option("base/default_pbe",
"PBE-PKCS5v20(SHA-1,TripleDES/CBC)");
config.set_option("base/default_allocator", "malloc");
- config.set_option("pk/blinder_size", "64");
config.set_option("pk/test/public", "basic");
config.set_option("pk/test/private", "basic");
config.set_option("pk/test/private_gen", "all");
diff --git a/src/fips140.cpp b/src/selftest.cpp
index 486afa072..3c8185ce0 100644
--- a/src/fips140.cpp
+++ b/src/selftest.cpp
@@ -1,15 +1,13 @@
/*************************************************
-* FIPS-140 Self Tests Source File *
+* Startup Self Tests Source File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
-#include <botan/fips140.h>
+#include <botan/selftest.h>
#include <botan/lookup.h>
namespace Botan {
-namespace FIPS140 {
-
namespace {
/*************************************************
@@ -150,12 +148,6 @@ bool passes_self_tests()
"BA0AA3F3D9AE3C1C7A3B1696A0B68CF7",
"0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"
"0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B");
-
- mac_kat("X9.19-MAC",
- "31311C3931383237333634351C1C35383134333237361C1C3B3132333435"
- "36373839303132333435363D3939313231303030303F1C30303031323530"
- "301C393738363533343132343837363932331C", "C209CCB78EE1B606",
- "0123456789ABCDEFFEDCBA9876543210");
}
catch(std::exception)
{
@@ -166,5 +158,3 @@ bool passes_self_tests()
}
}
-
-}