Botan 2.19.1
Crypto and TLS for C&
prf_tls.h
Go to the documentation of this file.
1/*
2* TLS v1.0 and v1.2 PRFs
3* (C) 2004-2010 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_TLS_PRF_H_
9#define BOTAN_TLS_PRF_H_
10
11#include <botan/kdf.h>
12#include <botan/mac.h>
13
15
16namespace Botan {
17
18/**
19* PRF used in TLS 1.0/1.1
20*/
21class BOTAN_PUBLIC_API(2,0) TLS_PRF final : public KDF
22 {
23 public:
24 std::string name() const override { return "TLS-PRF"; }
25
26 KDF* clone() const override { return new TLS_PRF; }
27
28 size_t kdf(uint8_t key[], size_t key_len,
29 const uint8_t secret[], size_t secret_len,
30 const uint8_t salt[], size_t salt_len,
31 const uint8_t label[], size_t label_len) const override;
32
33 TLS_PRF(std::unique_ptr<MessageAuthenticationCode> hmac_md5,
34 std::unique_ptr<MessageAuthenticationCode> hmac_sha1) :
35 m_hmac_md5(std::move(hmac_md5)),
36 m_hmac_sha1(std::move(hmac_sha1))
37 {}
38
39 TLS_PRF();
40 private:
41 std::unique_ptr<MessageAuthenticationCode> m_hmac_md5;
42 std::unique_ptr<MessageAuthenticationCode> m_hmac_sha1;
43 };
44
45/**
46* PRF used in TLS 1.2
47*/
49 {
50 public:
51 std::string name() const override { return "TLS-12-PRF(" + m_mac->name() + ")"; }
52
53 KDF* clone() const override { return new TLS_12_PRF(m_mac->clone()); }
54
55 size_t kdf(uint8_t key[], size_t key_len,
56 const uint8_t secret[], size_t secret_len,
57 const uint8_t salt[], size_t salt_len,
58 const uint8_t label[], size_t label_len) const override;
59
60 /**
61 * @param mac MAC algorithm to use
62 */
63 explicit TLS_12_PRF(MessageAuthenticationCode* mac) : m_mac(mac) {}
64 private:
65 std::unique_ptr<MessageAuthenticationCode> m_mac;
66 };
67
68}
69
70#endif
Definition: kdf.h:21
virtual size_t kdf(uint8_t key[], size_t key_len, const uint8_t secret[], size_t secret_len, const uint8_t salt[], size_t salt_len, const uint8_t label[], size_t label_len) const =0
std::string name() const override
Definition: prf_tls.h:51
TLS_12_PRF(MessageAuthenticationCode *mac)
Definition: prf_tls.h:63
KDF * clone() const override
Definition: prf_tls.h:53
TLS_PRF(std::unique_ptr< MessageAuthenticationCode > hmac_md5, std::unique_ptr< MessageAuthenticationCode > hmac_sha1)
Definition: prf_tls.h:33
KDF * clone() const override
Definition: prf_tls.h:26
std::string name() const override
Definition: prf_tls.h:24
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
Definition: bigint.h:1143
size_t salt_len
Definition: x509_obj.cpp:25