diff options
Diffstat (limited to 'src/kdf/ssl_prf')
-rw-r--r-- | src/kdf/ssl_prf/info.txt | 2 | ||||
-rw-r--r-- | src/kdf/ssl_prf/prf_ssl3.cpp | 29 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/kdf/ssl_prf/info.txt b/src/kdf/ssl_prf/info.txt index 8c85745c2..890789988 100644 --- a/src/kdf/ssl_prf/info.txt +++ b/src/kdf/ssl_prf/info.txt @@ -6,6 +6,8 @@ load_on auto <requires> kdf +md5 +sha1 </requires> <add> diff --git a/src/kdf/ssl_prf/prf_ssl3.cpp b/src/kdf/ssl_prf/prf_ssl3.cpp index b241bf60f..29c29ba7e 100644 --- a/src/kdf/ssl_prf/prf_ssl3.cpp +++ b/src/kdf/ssl_prf/prf_ssl3.cpp @@ -4,7 +4,8 @@ *************************************************/ #include <botan/prf_ssl3.h> -#include <botan/lookup.h> +#include <botan/sha160.h> +#include <botan/md5.h> #include <memory> namespace Botan { @@ -15,24 +16,24 @@ namespace { * Return the next inner hash * *************************************************/ OctetString next_hash(u32bit where, u32bit want, - HashFunction* md5, HashFunction* sha1, + HashFunction& md5, HashFunction& sha1, const byte secret[], u32bit secret_len, const byte seed[], u32bit seed_len) { - if(want > md5->OUTPUT_LENGTH) + if(want > md5.OUTPUT_LENGTH) throw Internal_Error("SSL3_PRF:next_hash: want is too big"); const byte ASCII_A_CHAR = 0x41; for(u32bit j = 0; j != where + 1; j++) - sha1->update(ASCII_A_CHAR + where); - sha1->update(secret, secret_len); - sha1->update(seed, seed_len); - SecureVector<byte> sha1_hash = sha1->final(); + sha1.update(ASCII_A_CHAR + where); + sha1.update(secret, secret_len); + sha1.update(seed, seed_len); + SecureVector<byte> sha1_hash = sha1.final(); - md5->update(secret, secret_len); - md5->update(sha1_hash); - SecureVector<byte> md5_hash = md5->final(); + md5.update(secret, secret_len); + md5.update(sha1_hash); + SecureVector<byte> md5_hash = md5.final(); return OctetString(md5_hash, want); } @@ -49,17 +50,17 @@ SecureVector<byte> SSL3_PRF::derive(u32bit key_len, if(key_len > 416) throw Internal_Error("SSL3_PRF: Requested key length is too large"); - std::auto_ptr<HashFunction> md5(get_hash("MD5")); - std::auto_ptr<HashFunction> sha1(get_hash("SHA-1")); + MD5 md5; + SHA_160 sha1; OctetString output; int counter = 0; while(key_len) { - const u32bit produce = std::min(key_len, md5->OUTPUT_LENGTH); + const u32bit produce = std::min(key_len, md5.OUTPUT_LENGTH); - output = output + next_hash(counter++, produce, md5.get(), sha1.get(), + output = output + next_hash(counter++, produce, md5, sha1, secret, secret_len, seed, seed_len); key_len -= produce; |