Botan 1.10.17
kdf.h
Go to the documentation of this file.
1/*
2* KDF/MGF
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_KDF_BASE_H__
9#define BOTAN_KDF_BASE_H__
10
11#include <botan/algo_base.h>
12#include <botan/secmem.h>
13#include <botan/types.h>
14
15namespace Botan {
16
17/**
18* Key Derivation Function
19*/
20class BOTAN_DLL KDF : public Algorithm
21 {
22 public:
23 /**
24 * Derive a key
25 * @param key_len the desired output length in bytes
26 * @param secret the secret input
27 * @param salt a diversifier
28 */
29 SecureVector<byte> derive_key(size_t key_len,
30 const MemoryRegion<byte>& secret,
31 const std::string& salt = "") const;
32
33 /**
34 * Derive a key
35 * @param key_len the desired output length in bytes
36 * @param secret the secret input
37 * @param salt a diversifier
38 */
39 SecureVector<byte> derive_key(size_t key_len,
40 const MemoryRegion<byte>& secret,
41 const MemoryRegion<byte>& salt) const;
42
43 /**
44 * Derive a key
45 * @param key_len the desired output length in bytes
46 * @param secret the secret input
47 * @param salt a diversifier
48 * @param salt_len size of salt in bytes
49 */
50 SecureVector<byte> derive_key(size_t key_len,
51 const MemoryRegion<byte>& secret,
52 const byte salt[],
53 size_t salt_len) const;
54
55 /**
56 * Derive a key
57 * @param key_len the desired output length in bytes
58 * @param secret the secret input
59 * @param secret_len size of secret in bytes
60 * @param salt a diversifier
61 */
62 SecureVector<byte> derive_key(size_t key_len,
63 const byte secret[],
64 size_t secret_len,
65 const std::string& salt = "") const;
66
67 /**
68 * Derive a key
69 * @param key_len the desired output length in bytes
70 * @param secret the secret input
71 * @param secret_len size of secret in bytes
72 * @param salt a diversifier
73 * @param salt_len size of salt in bytes
74 */
75 SecureVector<byte> derive_key(size_t key_len,
76 const byte secret[],
77 size_t secret_len,
78 const byte salt[],
79 size_t salt_len) const;
80
81 void clear() {}
82
83 virtual KDF* clone() const = 0;
84 private:
85 virtual SecureVector<byte>
86 derive(size_t key_len,
87 const byte secret[], size_t secret_len,
88 const byte salt[], size_t salt_len) const = 0;
89 };
90
91/**
92* Mask Generation Function
93*/
94class BOTAN_DLL MGF
95 {
96 public:
97 virtual void mask(const byte in[], size_t in_len,
98 byte out[], size_t out_len) const = 0;
99
100 virtual ~MGF() {}
101 };
102
103}
104
105#endif
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition kdf.cpp:15
virtual KDF * clone() const =0
void clear()
Definition kdf.h:81
virtual void mask(const byte in[], size_t in_len, byte out[], size_t out_len) const =0
virtual ~MGF()
Definition kdf.h:100