diff options
author | lloyd <[email protected]> | 2010-10-13 02:45:00 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-13 02:45:00 +0000 |
commit | 63121e1e169616f724bf79b8aac1a2b4423c8904 (patch) | |
tree | 2375d5b5daaad8990b2cee951d137f2e7638e79b /src | |
parent | 879d062c2b93e32362e338d1c6f9b1eda0f88493 (diff) |
Use output_length() instead of OUTPUT_LENGTH pseudo-property
Diffstat (limited to 'src')
42 files changed, 97 insertions, 97 deletions
diff --git a/src/block/lion/lion.cpp b/src/block/lion/lion.cpp index daf00da81..0b3e7762a 100644 --- a/src/block/lion/lion.cpp +++ b/src/block/lion/lion.cpp @@ -109,9 +109,9 @@ void Lion::clear() * Lion Constructor */ Lion::Lion(HashFunction* hash_in, StreamCipher* sc_in, size_t block_len) : - BlockCipher(std::max<size_t>(2*hash_in->OUTPUT_LENGTH + 1, block_len), - 2, 2*hash_in->OUTPUT_LENGTH, 2), - LEFT_SIZE(hash_in->OUTPUT_LENGTH), + BlockCipher(std::max<size_t>(2*hash_in->output_length() + 1, block_len), + 2, 2*hash_in->output_length(), 2), + LEFT_SIZE(hash_in->output_length()), RIGHT_SIZE(BLOCK_SIZE - LEFT_SIZE), hash(hash_in), cipher(sc_in) diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp index 383e9131b..ecc0fadfd 100644 --- a/src/block/lubyrack/lubyrack.cpp +++ b/src/block/lubyrack/lubyrack.cpp @@ -15,7 +15,7 @@ namespace Botan { */ void LubyRackoff::encrypt_n(const byte in[], byte out[], size_t blocks) const { - const size_t len = hash->OUTPUT_LENGTH; + const size_t len = hash->output_length(); SecureVector<byte> buffer_vec(len); byte* buffer = &buffer_vec[0]; @@ -52,7 +52,7 @@ void LubyRackoff::encrypt_n(const byte in[], byte out[], size_t blocks) const */ void LubyRackoff::decrypt_n(const byte in[], byte out[], size_t blocks) const { - const size_t len = hash->OUTPUT_LENGTH; + const size_t len = hash->output_length(); SecureVector<byte> buffer_vec(len); byte* buffer = &buffer_vec[0]; @@ -123,7 +123,7 @@ std::string LubyRackoff::name() const * Luby-Rackoff Constructor */ LubyRackoff::LubyRackoff(HashFunction* h) : - BlockCipher(2 * (h ? h->OUTPUT_LENGTH: 0), + BlockCipher(2 * (h ? h->output_length(): 0), 2, 32, 2), hash(h) { diff --git a/src/cert/x509ca/x509_ca.cpp b/src/cert/x509ca/x509_ca.cpp index 4379488e9..c9523c6c8 100644 --- a/src/cert/x509ca/x509_ca.cpp +++ b/src/cert/x509ca/x509_ca.cpp @@ -227,7 +227,7 @@ PK_Signer* choose_sig_format(const Private_Key& key, if(!proto_hash) throw Algorithm_Not_Found(hash_fn); - if(key.max_input_bits() < proto_hash->OUTPUT_LENGTH*8) + if(key.max_input_bits() < proto_hash->output_length()*8) throw Invalid_Argument("Key is too small for chosen hash function"); if(algo_name == "RSA") diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp index e5c245873..f6f2344fd 100644 --- a/src/constructs/tss/tss.cpp +++ b/src/constructs/tss/tss.cpp @@ -207,7 +207,7 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares) std::auto_ptr<HashFunction> hash(get_rtss_hash_by_id(hash_id)); - if(shares[0].size() != secret_len + hash->OUTPUT_LENGTH + RTSS_HEADER_SIZE + 1) + if(shares[0].size() != secret_len + hash->output_length() + RTSS_HEADER_SIZE + 1) throw Decoding_Error("Bad RTSS length field in header"); std::vector<byte> V(shares.size()); @@ -244,14 +244,14 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares) secret.push_back(r); } - if(secret.size() != secret_len + hash->OUTPUT_LENGTH) + if(secret.size() != secret_len + hash->output_length()) throw Decoding_Error("Bad length in RTSS output"); hash->update(&secret[0], secret_len); SecureVector<byte> hash_check = hash->final(); if(!same_mem(&hash_check[0], - &secret[secret_len], hash->OUTPUT_LENGTH)) + &secret[secret_len], hash->output_length())) throw Decoding_Error("RTSS hash check failed"); return SecureVector<byte>(&secret[0], secret_len); diff --git a/src/filters/modes/eax/eax.cpp b/src/filters/modes/eax/eax.cpp index bc281aab3..bd8633ad7 100644 --- a/src/filters/modes/eax/eax.cpp +++ b/src/filters/modes/eax/eax.cpp @@ -44,7 +44,7 @@ EAX_Base::EAX_Base(BlockCipher* cipher, size_t tag_size) : cmac = new CMAC(cipher->clone()); ctr = new CTR_BE(cipher); // takes ownership - if(tag_size % 8 != 0 || TAG_SIZE == 0 || TAG_SIZE > cmac->OUTPUT_LENGTH) + if(tag_size % 8 != 0 || TAG_SIZE == 0 || TAG_SIZE > cmac->output_length()) throw Invalid_Argument(name() + ": Bad tag size " + to_string(tag_size)); } diff --git a/src/hash/bmw/bmw_512.cpp b/src/hash/bmw/bmw_512.cpp index a69d23bff..3999cb95c 100644 --- a/src/hash/bmw/bmw_512.cpp +++ b/src/hash/bmw/bmw_512.cpp @@ -168,7 +168,7 @@ void BMW_512::copy_out(byte output[]) BMW_512_compress(final, &H[0], &Q[0]); - for(size_t i = 0; i != OUTPUT_LENGTH; i += 8) + for(size_t i = 0; i != output_length(); i += 8) store_le(final[8 + i/8], output + i); } diff --git a/src/hash/comb4p/comb4p.cpp b/src/hash/comb4p/comb4p.cpp index 681e20685..c4cd1cc79 100644 --- a/src/hash/comb4p/comb4p.cpp +++ b/src/hash/comb4p/comb4p.cpp @@ -48,14 +48,14 @@ void comb4p_round(MemoryRegion<byte>& out, } Comb4P::Comb4P(HashFunction* h1, HashFunction* h2) : - HashFunction(h1->OUTPUT_LENGTH + h2->OUTPUT_LENGTH, + HashFunction(h1->output_length() + h2->output_length(), comb4p_block_size(h1, h2)), hash1(h1), hash2(h2) { if(hash1->name() == hash2->name()) throw std::invalid_argument("Comb4P: Must use two distinct hashes"); - if(hash1->OUTPUT_LENGTH != hash2->OUTPUT_LENGTH) + if(hash1->output_length() != hash2->output_length()) throw std::invalid_argument("Comb4P: Incompatible hashes " + hash1->name() + " and " + hash2->name()); diff --git a/src/hash/has160/has160.cpp b/src/hash/has160/has160.cpp index 4f8db53f7..72246a845 100644 --- a/src/hash/has160/has160.cpp +++ b/src/hash/has160/has160.cpp @@ -144,7 +144,7 @@ void HAS_160::compress_n(const byte input[], size_t blocks) */ void HAS_160::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_le(digest[i/4], output + i); } diff --git a/src/hash/md2/md2.cpp b/src/hash/md2/md2.cpp index 5d8f5f15c..f2d6d800b 100644 --- a/src/hash/md2/md2.cpp +++ b/src/hash/md2/md2.cpp @@ -94,7 +94,7 @@ void MD2::final_result(byte output[]) hash(&buffer[0]); hash(&checksum[0]); - copy_mem(output, &X[0], OUTPUT_LENGTH); + copy_mem(output, &X[0], output_length()); clear(); } diff --git a/src/hash/md4/md4.cpp b/src/hash/md4/md4.cpp index 3f9259deb..2b24d10fd 100644 --- a/src/hash/md4/md4.cpp +++ b/src/hash/md4/md4.cpp @@ -94,7 +94,7 @@ void MD4::compress_n(const byte input[], size_t blocks) */ void MD4::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_le(digest[i/4], output + i); } diff --git a/src/hash/md5/md5.cpp b/src/hash/md5/md5.cpp index 69ab89e63..9a5f95ca8 100644 --- a/src/hash/md5/md5.cpp +++ b/src/hash/md5/md5.cpp @@ -116,7 +116,7 @@ void MD5::compress_n(const byte input[], size_t blocks) */ void MD5::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_le(digest[i/4], output + i); } diff --git a/src/hash/mdx_hash/mdx_hash.cpp b/src/hash/mdx_hash/mdx_hash.cpp index cea66044b..9bf6b573a 100644 --- a/src/hash/mdx_hash/mdx_hash.cpp +++ b/src/hash/mdx_hash/mdx_hash.cpp @@ -20,7 +20,7 @@ MDx_HashFunction::MDx_HashFunction(size_t hash_len, size_t block_len, HashFunction(hash_len, block_len), buffer(block_len), BIG_BYTE_ENDIAN(byte_end), BIG_BIT_ENDIAN(bit_end), COUNT_SIZE(cnt_size) { - if(COUNT_SIZE >= OUTPUT_LENGTH || COUNT_SIZE >= HASH_BLOCK_SIZE) + if(COUNT_SIZE >= output_length() || COUNT_SIZE >= HASH_BLOCK_SIZE) throw Invalid_Argument("MDx_HashFunction: COUNT_SIZE is too big"); count = position = 0; } diff --git a/src/hash/par_hash/par_hash.cpp b/src/hash/par_hash/par_hash.cpp index 794166327..aef5f8247 100644 --- a/src/hash/par_hash/par_hash.cpp +++ b/src/hash/par_hash/par_hash.cpp @@ -19,7 +19,7 @@ size_t sum_of_hash_lengths(const std::vector<HashFunction*>& hashes) size_t sum = 0; for(size_t i = 0; i != hashes.size(); ++i) - sum += hashes[i]->OUTPUT_LENGTH; + sum += hashes[i]->output_length(); return sum; } @@ -44,7 +44,7 @@ void Parallel::final_result(byte hash[]) for(size_t i = 0; i != hashes.size(); ++i) { hashes[i]->final(hash + offset); - offset += hashes[i]->OUTPUT_LENGTH; + offset += hashes[i]->output_length(); } } diff --git a/src/hash/rmd128/rmd128.cpp b/src/hash/rmd128/rmd128.cpp index 61737a4a0..edbe9fa84 100644 --- a/src/hash/rmd128/rmd128.cpp +++ b/src/hash/rmd128/rmd128.cpp @@ -156,7 +156,7 @@ void RIPEMD_128::compress_n(const byte input[], size_t blocks) */ void RIPEMD_128::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_le(digest[i/4], output + i); } diff --git a/src/hash/rmd160/rmd160.cpp b/src/hash/rmd160/rmd160.cpp index 255f3f95a..c3ae7119b 100644 --- a/src/hash/rmd160/rmd160.cpp +++ b/src/hash/rmd160/rmd160.cpp @@ -189,7 +189,7 @@ void RIPEMD_160::compress_n(const byte input[], size_t blocks) */ void RIPEMD_160::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_le(digest[i/4], output + i); } diff --git a/src/hash/sha1/sha160.cpp b/src/hash/sha1/sha160.cpp index 6c98b21d2..4778e5765 100644 --- a/src/hash/sha1/sha160.cpp +++ b/src/hash/sha1/sha160.cpp @@ -134,7 +134,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks) */ void SHA_160::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_be(digest[i/4], output + i); } diff --git a/src/hash/sha2_32/sha2_32.cpp b/src/hash/sha2_32/sha2_32.cpp index 6bbf6dec9..4e5f2b38c 100644 --- a/src/hash/sha2_32/sha2_32.cpp +++ b/src/hash/sha2_32/sha2_32.cpp @@ -171,7 +171,7 @@ void SHA_224::compress_n(const byte input[], size_t blocks) */ void SHA_224::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_be(digest[i/4], output + i); } @@ -205,7 +205,7 @@ void SHA_256::compress_n(const byte input[], size_t blocks) */ void SHA_256::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 4) + for(size_t i = 0; i != output_length(); i += 4) store_be(digest[i/4], output + i); } diff --git a/src/hash/sha2_64/sha2_64.cpp b/src/hash/sha2_64/sha2_64.cpp index 96e672819..3c1df9be6 100644 --- a/src/hash/sha2_64/sha2_64.cpp +++ b/src/hash/sha2_64/sha2_64.cpp @@ -178,7 +178,7 @@ void SHA_384::compress_n(const byte input[], size_t blocks) */ void SHA_384::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 8) + for(size_t i = 0; i != output_length(); i += 8) store_be(digest[i/8], output + i); } @@ -212,7 +212,7 @@ void SHA_512::compress_n(const byte input[], size_t blocks) */ void SHA_512::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 8) + for(size_t i = 0; i != output_length(); i += 8) store_be(digest[i/8], output + i); } diff --git a/src/hash/tiger/tiger.cpp b/src/hash/tiger/tiger.cpp index fa5effd80..67baf8d19 100644 --- a/src/hash/tiger/tiger.cpp +++ b/src/hash/tiger/tiger.cpp @@ -75,7 +75,7 @@ void Tiger::compress_n(const byte input[], size_t blocks) */ void Tiger::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; ++i) + for(size_t i = 0; i != output_length(); ++i) output[i] = get_byte(7 - (i % 8), digest[i/8]); } @@ -160,7 +160,7 @@ void Tiger::clear() */ std::string Tiger::name() const { - return "Tiger(" + to_string(OUTPUT_LENGTH) + "," + to_string(PASS) + ")"; + return "Tiger(" + to_string(output_length()) + "," + to_string(PASS) + ")"; } /* @@ -172,9 +172,9 @@ Tiger::Tiger(size_t hashlen, size_t pass) : digest(3), PASS(pass) { - if(OUTPUT_LENGTH != 16 && OUTPUT_LENGTH != 20 && OUTPUT_LENGTH != 24) + if(output_length() != 16 && output_length() != 20 && output_length() != 24) throw Invalid_Argument("Tiger: Illegal hash output size: " + - to_string(OUTPUT_LENGTH)); + to_string(output_length())); if(PASS < 3) throw Invalid_Argument("Tiger: Invalid number of passes: " + to_string(PASS)); diff --git a/src/hash/tiger/tiger.h b/src/hash/tiger/tiger.h index 7305ddb46..7d753c237 100644 --- a/src/hash/tiger/tiger.h +++ b/src/hash/tiger/tiger.h @@ -23,7 +23,7 @@ class BOTAN_DLL Tiger : public MDx_HashFunction HashFunction* clone() const { - return new Tiger(OUTPUT_LENGTH, PASS); + return new Tiger(output_length(), PASS); } /** diff --git a/src/hash/whirlpool/whrlpool.cpp b/src/hash/whirlpool/whrlpool.cpp index fdbdf5d0f..bff4b27ad 100644 --- a/src/hash/whirlpool/whrlpool.cpp +++ b/src/hash/whirlpool/whrlpool.cpp @@ -129,7 +129,7 @@ void Whirlpool::compress_n(const byte in[], size_t blocks) */ void Whirlpool::copy_out(byte output[]) { - for(size_t i = 0; i != OUTPUT_LENGTH; i += 8) + for(size_t i = 0; i != output_length(); i += 8) store_be(digest[i/8], output + i); } diff --git a/src/kdf/ssl_prf/prf_ssl3.cpp b/src/kdf/ssl_prf/prf_ssl3.cpp index 27afd9744..4f7325bde 100644 --- a/src/kdf/ssl_prf/prf_ssl3.cpp +++ b/src/kdf/ssl_prf/prf_ssl3.cpp @@ -25,7 +25,7 @@ OctetString next_hash(size_t where, size_t want, const byte secret[], size_t secret_len, const byte seed[], size_t seed_len) { - BOTAN_ASSERT(want <= md5.OUTPUT_LENGTH, "Desired output too large"); + BOTAN_ASSERT(want <= md5.output_length(), "Desired output too large"); const byte ASCII_A_CHAR = 0x41; @@ -62,7 +62,7 @@ SecureVector<byte> SSL3_PRF::derive(size_t key_len, int counter = 0; while(key_len) { - const size_t produce = std::min<size_t>(key_len, md5.OUTPUT_LENGTH); + const size_t produce = std::min<size_t>(key_len, md5.output_length()); output = output + next_hash(counter++, produce, md5, sha1, secret, secret_len, seed, seed_len); diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp index 97e952b0a..872997c28 100644 --- a/src/kdf/tls_prf/prf_tls.cpp +++ b/src/kdf/tls_prf/prf_tls.cpp @@ -32,7 +32,7 @@ void P_hash(MemoryRegion<byte>& output, while(offset != output.size()) { const size_t this_block_len = - std::min<size_t>(mac->OUTPUT_LENGTH, output.size() - offset); + std::min<size_t>(mac->output_length(), output.size() - offset); A = mac->process(A); diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp index 586c335e6..c701ad8e3 100644 --- a/src/libstate/lookup.cpp +++ b/src/libstate/lookup.cpp @@ -46,17 +46,17 @@ u32bit block_size_of(const std::string& name) } /* -* Query the OUTPUT_LENGTH of a hash or MAC +* Query the output_length() of a hash or MAC */ u32bit output_length_of(const std::string& name) { Algorithm_Factory& af = global_state().algorithm_factory(); if(const HashFunction* hash = af.prototype_hash_function(name)) - return hash->OUTPUT_LENGTH; + return hash->output_length(); if(const MessageAuthenticationCode* mac = af.prototype_mac(name)) - return mac->OUTPUT_LENGTH; + return mac->output_length(); throw Algorithm_Not_Found(name); } diff --git a/src/mac/cbc_mac/cbc_mac.cpp b/src/mac/cbc_mac/cbc_mac.cpp index 2a5a6c10f..3eaa115b8 100644 --- a/src/mac/cbc_mac/cbc_mac.cpp +++ b/src/mac/cbc_mac/cbc_mac.cpp @@ -16,22 +16,22 @@ namespace Botan { */ void CBC_MAC::add_data(const byte input[], size_t length) { - size_t xored = std::min(OUTPUT_LENGTH - position, length); + size_t xored = std::min(output_length() - position, length); xor_buf(&state[position], input, xored); position += xored; - if(position < OUTPUT_LENGTH) + if(position < output_length()) return; e->encrypt(state); input += xored; length -= xored; - while(length >= OUTPUT_LENGTH) + while(length >= output_length()) { - xor_buf(state, input, OUTPUT_LENGTH); + xor_buf(state, input, output_length()); e->encrypt(state); - input += OUTPUT_LENGTH; - length -= OUTPUT_LENGTH; + input += output_length(); + length -= output_length(); } xor_buf(state, input, length); diff --git a/src/mac/cmac/cmac.cpp b/src/mac/cmac/cmac.cpp index 05f487ad1..a4a9394ae 100644 --- a/src/mac/cmac/cmac.cpp +++ b/src/mac/cmac/cmac.cpp @@ -40,18 +40,18 @@ SecureVector<byte> CMAC::poly_double(const MemoryRegion<byte>& in, void CMAC::add_data(const byte input[], size_t length) { buffer.copy(position, input, length); - if(position + length > OUTPUT_LENGTH) + if(position + length > output_length()) { - xor_buf(state, buffer, OUTPUT_LENGTH); + xor_buf(state, buffer, output_length()); e->encrypt(state); - input += (OUTPUT_LENGTH - position); - length -= (OUTPUT_LENGTH - position); - while(length > OUTPUT_LENGTH) + input += (output_length() - position); + length -= (output_length() - position); + while(length > output_length()) { - xor_buf(state, input, OUTPUT_LENGTH); + xor_buf(state, input, output_length()); e->encrypt(state); - input += OUTPUT_LENGTH; - length -= OUTPUT_LENGTH; + input += output_length(); + length -= output_length(); } buffer.copy(input, length); position = 0; @@ -66,19 +66,19 @@ void CMAC::final_result(byte mac[]) { xor_buf(state, buffer, position); - if(position == OUTPUT_LENGTH) + if(position == output_length()) { - xor_buf(state, B, OUTPUT_LENGTH); + xor_buf(state, B, output_length()); } else { state[position] ^= 0x80; - xor_buf(state, P, OUTPUT_LENGTH); + xor_buf(state, P, output_length()); } e->encrypt(state); - for(size_t i = 0; i != OUTPUT_LENGTH; ++i) + for(size_t i = 0; i != output_length(); ++i) mac[i] = state[i]; zeroise(state); @@ -144,10 +144,10 @@ CMAC::CMAC(BlockCipher* e_in) : else throw Invalid_Argument("CMAC cannot use the cipher " + e->name()); - state.resize(OUTPUT_LENGTH); - buffer.resize(OUTPUT_LENGTH); - B.resize(OUTPUT_LENGTH); - P.resize(OUTPUT_LENGTH); + state.resize(output_length()); + buffer.resize(output_length()); + B.resize(output_length()); + P.resize(output_length()); position = 0; } diff --git a/src/mac/hmac/hmac.cpp b/src/mac/hmac/hmac.cpp index dfd800426..90da24eaf 100644 --- a/src/mac/hmac/hmac.cpp +++ b/src/mac/hmac/hmac.cpp @@ -26,7 +26,7 @@ void HMAC::final_result(byte mac[]) { hash->final(mac); hash->update(o_key); - hash->update(mac, OUTPUT_LENGTH); + hash->update(mac, output_length()); hash->final(mac); hash->update(i_key); } @@ -85,7 +85,7 @@ MessageAuthenticationCode* HMAC::clone() const * HMAC Constructor */ HMAC::HMAC(HashFunction* hash_in) : - MessageAuthenticationCode(hash_in->OUTPUT_LENGTH, + MessageAuthenticationCode(hash_in->output_length(), 0, 2*hash_in->HASH_BLOCK_SIZE), hash(hash_in) { diff --git a/src/mac/ssl3mac/ssl3_mac.cpp b/src/mac/ssl3mac/ssl3_mac.cpp index ac71be43c..e29770bde 100644 --- a/src/mac/ssl3mac/ssl3_mac.cpp +++ b/src/mac/ssl3mac/ssl3_mac.cpp @@ -24,7 +24,7 @@ void SSL3_MAC::final_result(byte mac[]) { hash->final(mac); hash->update(o_key); - hash->update(mac, OUTPUT_LENGTH); + hash->update(mac, output_length()); hash->final(mac); hash->update(i_key); } @@ -73,8 +73,8 @@ MessageAuthenticationCode* SSL3_MAC::clone() const * SSL3-MAC Constructor */ SSL3_MAC::SSL3_MAC(HashFunction* hash_in) : - MessageAuthenticationCode(hash_in->OUTPUT_LENGTH, - hash_in->OUTPUT_LENGTH), + MessageAuthenticationCode(hash_in->output_length(), + hash_in->output_length()), hash(hash_in) { if(hash->HASH_BLOCK_SIZE == 0) diff --git a/src/math/numbertheory/dsa_gen.cpp b/src/math/numbertheory/dsa_gen.cpp index fcae7c619..670f103da 100644 --- a/src/math/numbertheory/dsa_gen.cpp +++ b/src/math/numbertheory/dsa_gen.cpp @@ -57,7 +57,7 @@ bool generate_dsa_primes(RandomNumberGenerator& rng, std::auto_ptr<HashFunction> hash( af.make_hash_function("SHA-" + to_string(qbits))); - const size_t HASH_SIZE = hash->OUTPUT_LENGTH; + const size_t HASH_SIZE = hash->output_length(); class Seed { diff --git a/src/pbkdf/pbkdf1/pbkdf1.cpp b/src/pbkdf/pbkdf1/pbkdf1.cpp index 017153557..16de435e9 100644 --- a/src/pbkdf/pbkdf1/pbkdf1.cpp +++ b/src/pbkdf/pbkdf1/pbkdf1.cpp @@ -21,7 +21,7 @@ OctetString PKCS5_PBKDF1::derive_key(size_t key_len, if(iterations == 0) throw Invalid_Argument("PKCS5_PBKDF1: Invalid iteration count"); - if(key_len > hash->OUTPUT_LENGTH) + if(key_len > hash->output_length()) throw Invalid_Argument("PKCS5_PBKDF1: Requested output length too long"); hash->update(passphrase); diff --git a/src/pbkdf/pbkdf2/pbkdf2.cpp b/src/pbkdf/pbkdf2/pbkdf2.cpp index 5002f2ad6..7e4d1cd8a 100644 --- a/src/pbkdf/pbkdf2/pbkdf2.cpp +++ b/src/pbkdf/pbkdf2/pbkdf2.cpp @@ -37,12 +37,12 @@ OctetString PKCS5_PBKDF2::derive_key(size_t key_len, byte* T = &key[0]; - SecureVector<byte> U(mac->OUTPUT_LENGTH); + SecureVector<byte> U(mac->output_length()); u32bit counter = 1; while(key_len) { - size_t T_size = std::min<size_t>(mac->OUTPUT_LENGTH, key_len); + size_t T_size = std::min<size_t>(mac->output_length(), key_len); mac->update(salt, salt_size); mac->update_be(counter); diff --git a/src/pbkdf/pgps2k/pgp_s2k.cpp b/src/pbkdf/pgps2k/pgp_s2k.cpp index 98e05073e..9cec7304c 100644 --- a/src/pbkdf/pgps2k/pgp_s2k.cpp +++ b/src/pbkdf/pgps2k/pgp_s2k.cpp @@ -46,8 +46,8 @@ OctetString OpenPGP_S2K::derive_key(size_t key_len, } hash_buf = hash->final(); - key.copy(generated, &hash_buf[0], hash->OUTPUT_LENGTH); - generated += hash->OUTPUT_LENGTH; + key.copy(generated, &hash_buf[0], hash->output_length()); + generated += hash->output_length(); ++pass; } diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp index 4ad47f41a..63347e6a8 100644 --- a/src/pk_pad/eme1/eme1.cpp +++ b/src/pk_pad/eme1/eme1.cpp @@ -114,7 +114,7 @@ size_t EME1::maximum_input_size(size_t keybits) const * EME1 Constructor */ EME1::EME1(HashFunction* hash, const std::string& P) : - HASH_LENGTH(hash->OUTPUT_LENGTH) + HASH_LENGTH(hash->output_length()) { Phash = hash->process(P); mgf = new MGF1(hash); diff --git a/src/pk_pad/emsa1/emsa1.cpp b/src/pk_pad/emsa1/emsa1.cpp index 691f4b7e7..ba861898a 100644 --- a/src/pk_pad/emsa1/emsa1.cpp +++ b/src/pk_pad/emsa1/emsa1.cpp @@ -63,7 +63,7 @@ SecureVector<byte> EMSA1::encoding_of(const MemoryRegion<byte>& msg, size_t output_bits, RandomNumberGenerator&) { - if(msg.size() != hash->OUTPUT_LENGTH) + if(msg.size() != hash->output_length()) throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); return emsa1_encoding(msg, output_bits); } @@ -75,7 +75,7 @@ bool EMSA1::verify(const MemoryRegion<byte>& coded, const MemoryRegion<byte>& raw, size_t key_bits) { try { - if(raw.size() != hash->OUTPUT_LENGTH) + if(raw.size() != hash->output_length()) throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); SecureVector<byte> our_coding = emsa1_encoding(raw, key_bits); diff --git a/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp index a19ecfe58..bbcc5aae7 100644 --- a/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp +++ b/src/pk_pad/emsa1_bsi/emsa1_bsi.cpp @@ -17,7 +17,7 @@ SecureVector<byte> EMSA1_BSI::encoding_of(const MemoryRegion<byte>& msg, size_t output_bits, RandomNumberGenerator&) { - if(msg.size() != hash_ptr()->OUTPUT_LENGTH) + if(msg.size() != hash_ptr()->output_length()) throw Encoding_Error("EMSA1_BSI::encoding_of: Invalid size for input"); if(8*msg.size() <= output_bits) diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp index cf6578154..a381a82f6 100644 --- a/src/pk_pad/emsa3/emsa3.cpp +++ b/src/pk_pad/emsa3/emsa3.cpp @@ -60,7 +60,7 @@ SecureVector<byte> EMSA3::encoding_of(const MemoryRegion<byte>& msg, size_t output_bits, RandomNumberGenerator&) { - if(msg.size() != hash->OUTPUT_LENGTH) + if(msg.size() != hash->output_length()) throw Encoding_Error("EMSA3::encoding_of: Bad input length"); return emsa3_encoding(msg, output_bits, @@ -74,7 +74,7 @@ bool EMSA3::verify(const MemoryRegion<byte>& coded, const MemoryRegion<byte>& raw, size_t key_bits) { - if(raw.size() != hash->OUTPUT_LENGTH) + if(raw.size() != hash->output_length()) return false; try diff --git a/src/pk_pad/emsa4/emsa4.cpp b/src/pk_pad/emsa4/emsa4.cpp index 968a34111..ef88e1953 100644 --- a/src/pk_pad/emsa4/emsa4.cpp +++ b/src/pk_pad/emsa4/emsa4.cpp @@ -34,7 +34,7 @@ SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg, size_t output_bits, RandomNumberGenerator& rng) { - const size_t HASH_SIZE = hash->OUTPUT_LENGTH; + const size_t HASH_SIZE = hash->output_length(); if(msg.size() != HASH_SIZE) throw Encoding_Error("EMSA4::encoding_of: Bad input length"); @@ -69,7 +69,7 @@ SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg, bool EMSA4::verify(const MemoryRegion<byte>& const_coded, const MemoryRegion<byte>& raw, size_t key_bits) { - const size_t HASH_SIZE = hash->OUTPUT_LENGTH; + const size_t HASH_SIZE = hash->output_length(); const size_t KEY_BYTES = (key_bits + 7) / 8; if(key_bits < 8*HASH_SIZE + 9) @@ -125,7 +125,7 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded, * EMSA4 Constructor */ EMSA4::EMSA4(HashFunction* h) : - SALT_SIZE(h->OUTPUT_LENGTH), hash(h) + SALT_SIZE(h->output_length()), hash(h) { mgf = new MGF1(hash->clone()); } diff --git a/src/pubkey/dlies/dlies.cpp b/src/pubkey/dlies/dlies.cpp index 7b890b5ef..2b3f65d06 100644 --- a/src/pubkey/dlies/dlies.cpp +++ b/src/pubkey/dlies/dlies.cpp @@ -42,7 +42,7 @@ SecureVector<byte> DLIES_Encryptor::enc(const byte in[], size_t length, if(other_key.empty()) throw Invalid_State("DLIES: The other key was never set"); - SecureVector<byte> out(my_key.size() + length + mac->OUTPUT_LENGTH); + SecureVector<byte> out(my_key.size() + length + mac->output_length()); out.copy(&my_key[0], my_key.size()); out.copy(my_key.size(), in, length); @@ -110,14 +110,14 @@ DLIES_Decryptor::~DLIES_Decryptor() */ SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], size_t length) const { - if(length < my_key.size() + mac->OUTPUT_LENGTH) + if(length < my_key.size() + mac->output_length()) throw Decoding_Error("DLIES decryption: ciphertext is too short"); - const size_t CIPHER_LEN = length - my_key.size() - mac->OUTPUT_LENGTH; + const size_t CIPHER_LEN = length - my_key.size() - mac->output_length(); SecureVector<byte> v(msg, my_key.size()); SecureVector<byte> C(msg + my_key.size(), CIPHER_LEN); - SecureVector<byte> T(msg + my_key.size() + CIPHER_LEN, mac->OUTPUT_LENGTH); + SecureVector<byte> T(msg + my_key.size() + CIPHER_LEN, mac->output_length()); SecureVector<byte> vz(msg, my_key.size()); vz += ka.derive_key(0, v).bits_of(); diff --git a/src/rng/hmac_rng/hmac_rng.cpp b/src/rng/hmac_rng/hmac_rng.cpp index a3456d9e0..7912e58af 100644 --- a/src/rng/hmac_rng/hmac_rng.cpp +++ b/src/rng/hmac_rng/hmac_rng.cpp @@ -167,14 +167,14 @@ HMAC_RNG::HMAC_RNG(MessageAuthenticationCode* extractor_mac, MessageAuthenticationCode* prf_mac) : extractor(extractor_mac), prf(prf_mac) { - if(!prf->valid_keylength(extractor->OUTPUT_LENGTH) || - !extractor->valid_keylength(prf->OUTPUT_LENGTH)) + if(!prf->valid_keylength(extractor->output_length()) || + !extractor->valid_keylength(prf->output_length())) throw Invalid_Argument("HMAC_RNG: Bad algo combination " + extractor->name() + " and " + prf->name()); // First PRF inputs are all zero, as specified in section 2 - K.resize(prf->OUTPUT_LENGTH); + K.resize(prf->output_length()); counter = 0; user_input_len = 0; @@ -193,7 +193,7 @@ HMAC_RNG::HMAC_RNG(MessageAuthenticationCode* extractor_mac, the estimated entropy counter is high enough. That variable is only set when a reseeding is performed. */ - MemoryVector<byte> prf_key(extractor->OUTPUT_LENGTH); + MemoryVector<byte> prf_key(extractor->output_length()); prf->set_key(prf_key); /* diff --git a/src/rng/randpool/randpool.cpp b/src/rng/randpool/randpool.cpp index d99ae5463..e66081a07 100644 --- a/src/rng/randpool/randpool.cpp +++ b/src/rng/randpool/randpool.cpp @@ -176,7 +176,7 @@ Randpool::Randpool(BlockCipher* cipher_in, mac(mac_in) { const size_t BLOCK_SIZE = cipher->BLOCK_SIZE; - const size_t OUTPUT_LENGTH = mac->OUTPUT_LENGTH; + const size_t OUTPUT_LENGTH = mac->output_length(); if(OUTPUT_LENGTH < BLOCK_SIZE || !cipher->valid_keylength(OUTPUT_LENGTH) || diff --git a/src/utils/buf_comp/buf_comp.h b/src/utils/buf_comp/buf_comp.h index c1c2583c3..a64d807dd 100644 --- a/src/utils/buf_comp/buf_comp.h +++ b/src/utils/buf_comp/buf_comp.h @@ -21,9 +21,9 @@ namespace Botan { class BOTAN_DLL BufferedComputation { public: - /** * The length of the output of this function in bytes. + * @deprecated Use output_length() */ const size_t OUTPUT_LENGTH; @@ -78,7 +78,7 @@ class BOTAN_DLL BufferedComputation * Complete the computation and retrieve the * final result. * @param out The byte array to be filled with the result. - * Must be of length OUTPUT_LENGTH. + * Must be of length output_length() */ void final(byte out[]) { final_result(out); } @@ -89,7 +89,7 @@ class BOTAN_DLL BufferedComputation */ SecureVector<byte> final() { - SecureVector<byte> output(OUTPUT_LENGTH); + SecureVector<byte> output(output_length()); final_result(&output[0]); return output; } @@ -149,7 +149,7 @@ class BOTAN_DLL BufferedComputation /** * Write the final output to out - * @param out is an output buffer of OUTPUT_LENGTH + * @param out is an output buffer of output_length() */ virtual void final_result(byte out[]) = 0; }; diff --git a/src/wrap/python/core.cpp b/src/wrap/python/core.cpp index b1be3b71f..7dac7be7f 100644 --- a/src/wrap/python/core.cpp +++ b/src/wrap/python/core.cpp @@ -102,7 +102,7 @@ class Py_HashFunction u32bit output_length() const { - return hash->OUTPUT_LENGTH; + return hash->output_length(); } private: @@ -123,7 +123,7 @@ class Py_MAC ~Py_MAC() { delete mac; } - u32bit output_length() const { return mac->OUTPUT_LENGTH; } + u32bit output_length() const { return mac->output_length(); } std::string name() const { return mac->name(); } |