# # # patch "ChangeLog" # from [92a3d6cb0d0db6abe22dc5eb32cabaac62ba5024] # to [d30b3ff6deee322a54b20f00b4111ea1a55f8775] # # patch "botan/emsa1.cpp" # from [1dd0e80f0dc5bfbd718e2edc2e6de80fa482b50c] # to [e12d485d4f2484e6b53cd52288486cb56419b26c] # # patch "botan/emsa2.cpp" # from [a4d8301f23805ba4bb2554591dfc20e373bce4ca] # to [39f86a2ed053f0ddb8a0e0fb032ea9007149d27b] # # patch "botan/emsa3.cpp" # from [367b509f38995bb4978b8f514239c97989fb63b3] # to [0712cedbf4b4da5381aa6ec751798e527bac5239] # # patch "botan/emsa4.cpp" # from [a45dd0f15cdb2cb8f81d8493b44248f206bf44f2] # to [37c2f6432f8c13d345aedd7e5155aa3f4fb75e39] # # patch "botan/kdf.cpp" # from [875f93344551fe6e76ca4c86660937d2ec190c60] # to [961788f9806afb6dfd141703c9c9eb7f99ecf64c] # # patch "botan/keypair.cpp" # from [b989bff406ff022391d3484840d085d4060715de] # to [2c64955c5e28515d0029e50937107dd9a91e3b48] # # patch "botan/pk_util.cpp" # from [63673b6371f30e1bc06a7ff8e06ab6b9d998bf8b] # to [8237a1130cf67101cdc62f6f63c5378a27ff240b] # ============================================================ --- ChangeLog 92a3d6cb0d0db6abe22dc5eb32cabaac62ba5024 +++ ChangeLog d30b3ff6deee322a54b20f00b4111ea1a55f8775 @@ -1,3 +1,7 @@ +2006-10-25 Matt Johnston + + * botan/: pull in changes from net.randombit.botan head. + 2006-10-24 Nathaniel Smith * cmd_automate.cc (automate stdio): Do not run randomly through ============================================================ --- botan/emsa1.cpp 1dd0e80f0dc5bfbd718e2edc2e6de80fa482b50c +++ botan/emsa1.cpp e12d485d4f2484e6b53cd52288486cb56419b26c @@ -31,7 +31,7 @@ SecureVector EMSA1::encoding_of(co u32bit output_bits) { if(msg.size() != hash->OUTPUT_LENGTH) - throw Invalid_Argument("EMSA1::encoding_of: Invalid size for input"); + throw Encoding_Error("EMSA1::encoding_of: Invalid size for input"); if(8*msg.size() <= output_bits) return msg; ============================================================ --- botan/emsa2.cpp a4d8301f23805ba4bb2554591dfc20e373bce4ca +++ botan/emsa2.cpp 39f86a2ed053f0ddb8a0e0fb032ea9007149d27b @@ -34,9 +34,9 @@ SecureVector EMSA2::encoding_of(co u32bit output_length = (output_bits + 1) / 8; if(msg.size() != hash->OUTPUT_LENGTH) - throw Invalid_Argument("EMSA2::encoding_of: Bad input length"); + throw Encoding_Error("EMSA2::encoding_of: Bad input length"); if(output_length < hash->OUTPUT_LENGTH + 4) - throw Invalid_Argument("EMSA2::encoding_of: Output length is too small"); + throw Encoding_Error("EMSA2::encoding_of: Output length is too small"); bool empty = true; for(u32bit j = 0; j != hash->OUTPUT_LENGTH; ++j) @@ -62,7 +62,7 @@ EMSA2::EMSA2(const std::string& hash_nam { hash_id = ieee1363_hash_id(hash_name); if(hash_id == 0) - throw Invalid_Argument("EMSA2 cannot be used with " + hash->name()); + throw Encoding_Error("EMSA2 cannot be used with " + hash->name()); hash = get_hash(hash_name); empty_hash = hash->final(); } ============================================================ --- botan/emsa3.cpp 367b509f38995bb4978b8f514239c97989fb63b3 +++ botan/emsa3.cpp 0712cedbf4b4da5381aa6ec751798e527bac5239 @@ -32,11 +32,11 @@ SecureVector EMSA3::encoding_of(co u32bit output_bits) { if(msg.size() != hash->OUTPUT_LENGTH) - throw Invalid_Argument("EMSA3::encoding_of: Bad input length"); + throw Encoding_Error("EMSA3::encoding_of: Bad input length"); u32bit output_length = output_bits / 8; if(output_length < hash_id.size() + hash->OUTPUT_LENGTH + 10) - throw Invalid_Argument("EMSA3::pad: Output length is too small"); + throw Encoding_Error("EMSA3::pad: Output length is too small"); SecureVector T(output_length); const u32bit P_LENGTH = output_length - hash->OUTPUT_LENGTH - ============================================================ --- botan/emsa4.cpp a45dd0f15cdb2cb8f81d8493b44248f206bf44f2 +++ botan/emsa4.cpp 37c2f6432f8c13d345aedd7e5155aa3f4fb75e39 @@ -36,9 +36,9 @@ SecureVector EMSA4::encoding_of(co const u32bit HASH_SIZE = hash->OUTPUT_LENGTH; if(msg.size() != HASH_SIZE) - throw Invalid_Argument("EMSA4::encoding_of: Bad input length"); + throw Encoding_Error("EMSA4::encoding_of: Bad input length"); if(output_bits < 8*HASH_SIZE + 8*SALT_SIZE + 9) - throw Invalid_Argument("EMSA4::encoding_of: Output length is too small"); + throw Encoding_Error("EMSA4::encoding_of: Output length is too small"); const u32bit output_length = (output_bits + 7) / 8; ============================================================ --- botan/kdf.cpp 875f93344551fe6e76ca4c86660937d2ec190c60 +++ botan/kdf.cpp 961788f9806afb6dfd141703c9c9eb7f99ecf64c @@ -12,6 +12,60 @@ namespace Botan { namespace Botan { /************************************************* +* Derive a key * +*************************************************/ +SecureVector KDF::derive_key(u32bit key_len, + const MemoryRegion& secret, + const std::string& salt) const + { + return derive_key(key_len, secret, secret.size(), + (const byte*)salt.c_str(), salt.length()); + } + +/************************************************* +* Derive a key * +*************************************************/ +SecureVector KDF::derive_key(u32bit key_len, + const MemoryRegion& secret, + const byte salt[], u32bit salt_len) const + { + return derive_key(key_len, secret.begin(), secret.size(), + salt, salt_len); + } + +/************************************************* +* Derive a key * +*************************************************/ +SecureVector KDF::derive_key(u32bit key_len, + const MemoryRegion& secret, + const MemoryRegion& salt) const + { + return derive_key(key_len, secret.begin(), secret.size(), + salt.begin(), salt.size()); + } + +/************************************************* +* Derive a key * +*************************************************/ +SecureVector KDF::derive_key(u32bit key_len, + const byte secret[], u32bit secret_len, + const std::string& salt) const + { + return derive_key(key_len, secret, secret_len, + (const byte*)salt.c_str(), salt.length()); + } + +/************************************************* +* Derive a key * +*************************************************/ +SecureVector KDF::derive_key(u32bit key_len, + const byte secret[], u32bit secret_len, + const byte salt[], u32bit salt_len) const + { + return derive(key_len, secret, secret_len, salt, salt_len); + } + +/************************************************* * KDF1 Key Derivation Mechanism * *************************************************/ SecureVector KDF1::derive(u32bit, ============================================================ --- botan/keypair.cpp b989bff406ff022391d3484840d085d4060715de +++ botan/keypair.cpp 2c64955c5e28515d0029e50937107dd9a91e3b48 @@ -17,6 +17,9 @@ void check_key(PK_Encryptor* encryptor, *************************************************/ void check_key(PK_Encryptor* encryptor, PK_Decryptor* decryptor) { + if(encryptor->maximum_input_size() == 0) + return; + std::auto_ptr enc(encryptor); std::auto_ptr dec(decryptor); @@ -43,8 +46,16 @@ void check_key(PK_Signer* signer, PK_Ver SecureVector message(16); Global_RNG::randomize(message, message.size()); - SecureVector signature = sig->sign_message(message); + SecureVector signature; + try { + signature = sig->sign_message(message); + } + catch(Encoding_Error) + { + return; + } + if(!ver->verify_message(message, signature)) throw Self_Test_Failure("Signature key pair consistency failure"); ============================================================ --- botan/pk_util.cpp 63673b6371f30e1bc06a7ff8e06ab6b9d998bf8b +++ botan/pk_util.cpp 8237a1130cf67101cdc62f6f63c5378a27ff240b @@ -59,58 +59,4 @@ bool EMSA::verify(const MemoryRegion KDF::derive_key(u32bit key_len, - const MemoryRegion& secret, - const std::string& salt) const - { - return derive_key(key_len, secret, secret.size(), - (const byte*)salt.c_str(), salt.length()); - } - -/************************************************* -* Derive a key * -*************************************************/ -SecureVector KDF::derive_key(u32bit key_len, - const MemoryRegion& secret, - const byte salt[], u32bit salt_len) const - { - return derive_key(key_len, secret.begin(), secret.size(), - salt, salt_len); - } - -/************************************************* -* Derive a key * -*************************************************/ -SecureVector KDF::derive_key(u32bit key_len, - const MemoryRegion& secret, - const MemoryRegion& salt) const - { - return derive_key(key_len, secret.begin(), secret.size(), - salt.begin(), salt.size()); - } - -/************************************************* -* Derive a key * -*************************************************/ -SecureVector KDF::derive_key(u32bit key_len, - const byte secret[], u32bit secret_len, - const std::string& salt) const - { - return derive_key(key_len, secret, secret_len, - (const byte*)salt.c_str(), salt.length()); - } - -/************************************************* -* Derive a key * -*************************************************/ -SecureVector KDF::derive_key(u32bit key_len, - const byte secret[], u32bit secret_len, - const byte salt[], u32bit salt_len) const - { - return derive(key_len, secret, secret_len, salt, salt_len); - } - }