aboutsummaryrefslogtreecommitdiffstats
path: root/src/kdf/tls_prf/prf_tls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kdf/tls_prf/prf_tls.cpp')
-rw-r--r--src/kdf/tls_prf/prf_tls.cpp62
1 files changed, 33 insertions, 29 deletions
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;
- }
-
}