diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hash/gost_3411/info.txt | 4 | ||||
-rw-r--r-- | src/kdf/tls_prf/info.txt | 3 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.cpp | 62 | ||||
-rw-r--r-- | src/kdf/tls_prf/prf_tls.h | 5 |
4 files changed, 39 insertions, 35 deletions
diff --git a/src/hash/gost_3411/info.txt b/src/hash/gost_3411/info.txt index ef2879823..65b9475e1 100644 --- a/src/hash/gost_3411/info.txt +++ b/src/hash/gost_3411/info.txt @@ -8,3 +8,7 @@ load_on auto gost_3411.cpp gost_3411.h </add> + +<requires> +gost_28147 +</requires> diff --git a/src/kdf/tls_prf/info.txt b/src/kdf/tls_prf/info.txt index 58c1ed029..c775c90ba 100644 --- a/src/kdf/tls_prf/info.txt +++ b/src/kdf/tls_prf/info.txt @@ -5,9 +5,10 @@ define TLS_V10_PRF load_on auto <requires> +hmac kdf -sha1 md5 +sha1 </requires> <add> diff --git a/src/kdf/tls_prf/prf_tls.cpp b/src/kdf/tls_prf/prf_tls.cpp index a04c9045d..7c638b994 100644 --- a/src/kdf/tls_prf/prf_tls.cpp +++ b/src/kdf/tls_prf/prf_tls.cpp @@ -13,6 +13,39 @@ namespace Botan { +namespace { + +/* +* TLS PRF P_hash function +*/ +SecureVector<byte> P_hash(MessageAuthenticationCode* mac, + u32bit len, + const byte secret[], u32bit secret_len, + const byte seed[], u32bit seed_len) + { + SecureVector<byte> out; + + mac->set_key(secret, secret_len); + + SecureVector<byte> A(seed, seed_len); + while(len) + { + const u32bit this_block_len = std::min(mac->OUTPUT_LENGTH, len); + + A = mac->process(A); + + mac->update(A); + mac->update(seed, seed_len); + SecureVector<byte> block = mac->final(); + + out.append(block, this_block_len); + len -= this_block_len; + } + return out; + } + +} + /* * TLS PRF Constructor and Destructor */ @@ -49,33 +82,4 @@ SecureVector<byte> TLS_PRF::derive(u32bit key_len, return key1; } -/* -* TLS PRF P_hash function -*/ -SecureVector<byte> TLS_PRF::P_hash(MessageAuthenticationCode* mac, - u32bit len, - const byte secret[], u32bit secret_len, - const byte seed[], u32bit seed_len) - { - SecureVector<byte> out; - - mac->set_key(secret, secret_len); - - SecureVector<byte> A(seed, seed_len); - while(len) - { - const u32bit this_block_len = std::min(mac->OUTPUT_LENGTH, len); - - A = mac->process(A); - - mac->update(A); - mac->update(seed, seed_len); - SecureVector<byte> block = mac->final(); - - out.append(block, this_block_len); - len -= this_block_len; - } - return out; - } - } diff --git a/src/kdf/tls_prf/prf_tls.h b/src/kdf/tls_prf/prf_tls.h index 6b81c155f..d21279588 100644 --- a/src/kdf/tls_prf/prf_tls.h +++ b/src/kdf/tls_prf/prf_tls.h @@ -25,11 +25,6 @@ class BOTAN_DLL TLS_PRF : public KDF TLS_PRF(); ~TLS_PRF(); private: - static SecureVector<byte> P_hash(MessageAuthenticationCode*, - u32bit, - const byte[], u32bit, - const byte[], u32bit); - MessageAuthenticationCode* hmac_md5; MessageAuthenticationCode* hmac_sha1; }; |