From e846f62c1c9a0e1f6aed562c462561cc91406501 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 13 Oct 2010 15:14:07 +0000 Subject: More size_t. Document changes --- doc/log.txt | 7 +++++-- src/block/aes/aes.cpp | 2 +- src/block/aes/aes.h | 2 +- src/block/block_cipher.h | 12 ++++++------ src/hash/hash.h | 2 +- src/hash/skein/skein_512.cpp | 8 ++++---- src/hash/skein/skein_512.h | 2 +- src/mac/mac.h | 8 ++++---- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/doc/log.txt b/doc/log.txt index 15904cd00..382ccd8d4 100644 --- a/doc/log.txt +++ b/doc/log.txt @@ -6,10 +6,13 @@ - Add hex encoding/decoding functions that can be used without a Pipe - Add support for dynamic engine loading on Windows - Allow using PBKDF2 with empty passphrases + - Switch default PKCS #8 encryption algorithm from AES-128 to AES-256 + - Support use of HMAC(SHA-256) and CMAC(Blowfish) in passhash9 + - Use size_t instead of u32bit for length fields + - Replace BlockCipher::BLOCK_SIZE attribute with function block_size() + - Replace HashFunction::HASH_BLOCK_SIZE attribute with hash_block_size() - Changed semantics of MemoryRegion::resize and clear to match STL - Removed MemoryRegion::append, replaced by push_back and operator+= - - Support use of HMAC(SHA-256) and CMAC(Blowfish) in passhash9 - - Switch default PKCS #8 encryption algorithm from AES-128 to AES-256 - Improve support for Intel Atom processors - Fix compilation under Sun Studio diff --git a/src/block/aes/aes.cpp b/src/block/aes/aes.cpp index 1530af965..e562b8343 100644 --- a/src/block/aes/aes.cpp +++ b/src/block/aes/aes.cpp @@ -681,7 +681,7 @@ u32bit AES::S(u32bit input) /* * AES Constructor */ -AES::AES(u32bit key_size) : BlockCipher_Fixed_Block_Size(key_size), +AES::AES(size_t key_size) : BlockCipher_Fixed_Block_Size(key_size), EK(56), ME(16), DK(56), MD(16) { if(key_size != 16 && key_size != 24 && key_size != 32) diff --git a/src/block/aes/aes.h b/src/block/aes/aes.h index 6fa0ccaff..96b8e91da 100644 --- a/src/block/aes/aes.h +++ b/src/block/aes/aes.h @@ -34,7 +34,7 @@ class BOTAN_DLL AES : public BlockCipher_Fixed_Block_Size<16> * AES fixed to a particular key_size (16, 24, or 32 bytes) * @param key_size the chosen fixed key size */ - AES(u32bit key_size); + AES(size_t key_size); private: void key_schedule(const byte[], size_t); static u32bit S(u32bit); diff --git a/src/block/block_cipher.h b/src/block/block_cipher.h index e522005b9..3e14e0739 100644 --- a/src/block/block_cipher.h +++ b/src/block/block_cipher.h @@ -25,9 +25,9 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm * @param key_max the maximum key size * @param key_mod the modulo restriction on the key size */ - BlockCipher(u32bit key_min, - u32bit key_max = 0, - u32bit key_mod = 1) : + BlockCipher(size_t key_min, + size_t key_max = 0, + size_t key_mod = 1) : SymmetricAlgorithm(key_min, key_max, key_mod) {} virtual ~BlockCipher() {} @@ -119,9 +119,9 @@ template class BlockCipher_Fixed_Block_Size : public BlockCipher { public: - BlockCipher_Fixed_Block_Size(u32bit kmin, - u32bit kmax = 0, - u32bit kmod = 1) : + BlockCipher_Fixed_Block_Size(size_t kmin, + size_t kmax = 0, + size_t kmod = 1) : BlockCipher(kmin, kmax, kmod) {} enum { BLOCK_SIZE = N }; diff --git a/src/hash/hash.h b/src/hash/hash.h index 95d12806f..881e23817 100644 --- a/src/hash/hash.h +++ b/src/hash/hash.h @@ -23,7 +23,7 @@ class BOTAN_DLL HashFunction : public BufferedComputation * @param hash_len the output length * @param block_len the internal block size (if applicable) */ - HashFunction(u32bit hash_len) : BufferedComputation(hash_len) {} + HashFunction(size_t hash_len) : BufferedComputation(hash_len) {} virtual ~HashFunction() {} diff --git a/src/hash/skein/skein_512.cpp b/src/hash/skein/skein_512.cpp index cda8e3f56..37aed4357 100644 --- a/src/hash/skein/skein_512.cpp +++ b/src/hash/skein/skein_512.cpp @@ -133,14 +133,14 @@ void reset_tweak(MemoryRegion& T, void initial_block(MemoryRegion& H, MemoryRegion& T, - u32bit output_bits, + size_t output_bits, const std::string& personalization) { zeroise(H); // ASCII("SHA3") followed by version (0x0001) code byte config_str[32] = { 0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0 }; - store_le(output_bits, config_str + 8); + store_le(u32bit(output_bits), config_str + 8); reset_tweak(T, SKEIN_CONFIG, true); ubi_512(H, T, config_str, sizeof(config_str)); @@ -166,14 +166,14 @@ void initial_block(MemoryRegion& H, } -Skein_512::Skein_512(u32bit arg_output_bits, +Skein_512::Skein_512(size_t arg_output_bits, const std::string& arg_personalization) : HashFunction(arg_output_bits / 8), personalization(arg_personalization), output_bits(arg_output_bits), H(9), T(3), buffer(64), buf_pos(0) { - if(output_bits == 0 || output_bits % 8 != 0) + if(output_bits == 0 || output_bits % 8 != 0 || output_bits > 64*1024) throw Invalid_Argument("Bad output bits size for Skein-512"); initial_block(H, T, output_bits, personalization); diff --git a/src/hash/skein/skein_512.h b/src/hash/skein/skein_512.h index fce02c1f6..54cdd002c 100644 --- a/src/hash/skein/skein_512.h +++ b/src/hash/skein/skein_512.h @@ -25,7 +25,7 @@ class BOTAN_DLL Skein_512 : public HashFunction * @param personalization is a string that will paramaterize the * hash output */ - Skein_512(u32bit output_bits = 512, + Skein_512(size_t output_bits = 512, const std::string& personalization = ""); size_t hash_block_size() const { return 64; } diff --git a/src/mac/mac.h b/src/mac/mac.h index 1350c7d7a..b788e06c8 100644 --- a/src/mac/mac.h +++ b/src/mac/mac.h @@ -51,10 +51,10 @@ class BOTAN_DLL MessageAuthenticationCode : public BufferedComputation, * @param key_max the maximum key size * @param key_mod the modulo restriction on the key size */ - MessageAuthenticationCode(u32bit mac_len, - u32bit key_min, - u32bit key_max = 0, - u32bit key_mod = 1) : + MessageAuthenticationCode(size_t mac_len, + size_t key_min, + size_t key_max = 0, + size_t key_mod = 1) : BufferedComputation(mac_len), SymmetricAlgorithm(key_min, key_max, key_mod) {} -- cgit v1.2.3