Botan
1.11.15
|
00001 /* 00002 * TLS v1.0 and v1.2 PRFs 00003 * (C) 2004-2010 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_TLS_PRF_H__ 00009 #define BOTAN_TLS_PRF_H__ 00010 00011 #include <botan/kdf.h> 00012 #include <botan/mac.h> 00013 00014 namespace Botan { 00015 00016 /** 00017 * PRF used in TLS 1.0/1.1 00018 */ 00019 class BOTAN_DLL TLS_PRF : public KDF 00020 { 00021 public: 00022 std::string name() const { return "TLS-PRF"; } 00023 00024 KDF* clone() const { return new TLS_PRF; } 00025 00026 size_t kdf(byte key[], size_t key_len, 00027 const byte secret[], size_t secret_len, 00028 const byte salt[], size_t salt_len) const override; 00029 00030 TLS_PRF(); 00031 private: 00032 std::unique_ptr<MessageAuthenticationCode> m_hmac_md5; 00033 std::unique_ptr<MessageAuthenticationCode> m_hmac_sha1; 00034 }; 00035 00036 /** 00037 * PRF used in TLS 1.2 00038 */ 00039 class BOTAN_DLL TLS_12_PRF : public KDF 00040 { 00041 public: 00042 std::string name() const { return "TLS-12-PRF(" + m_mac->name() + ")"; } 00043 00044 KDF* clone() const { return new TLS_12_PRF(m_mac->clone()); } 00045 00046 size_t kdf(byte key[], size_t key_len, 00047 const byte secret[], size_t secret_len, 00048 const byte salt[], size_t salt_len) const override; 00049 00050 TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {} 00051 00052 static TLS_12_PRF* make(const Spec& spec); 00053 private: 00054 std::unique_ptr<MessageAuthenticationCode> m_mac; 00055 }; 00056 00057 } 00058 00059 #endif