Botan  2.8.0
Crypto and TLS for C++11
pssr.h
Go to the documentation of this file.
1 /*
2 * PSSR
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_PSSR_H_
9 #define BOTAN_PSSR_H_
10 
11 #include <botan/emsa.h>
12 #include <botan/hash.h>
13 
14 namespace Botan {
15 
16 /**
17 * PSSR (called EMSA4 in IEEE 1363 and in old versions of the library)
18 */
19 class BOTAN_PUBLIC_API(2,0) PSSR final : public EMSA
20  {
21  public:
22 
23  /**
24  * @param hash the hash function to use
25  */
26  explicit PSSR(HashFunction* hash);
27 
28  /**
29  * @param hash the hash function to use
30  * @param salt_size the size of the salt to use in bytes
31  */
32  PSSR(HashFunction* hash, size_t salt_size);
33 
34  EMSA* clone() override;
35 
36  std::string name() const override;
37 
38  AlgorithmIdentifier config_for_x509(const Private_Key& key,
39  const std::string& cert_hash_name) const override;
40  private:
41  void update(const uint8_t input[], size_t length) override;
42 
43  secure_vector<uint8_t> raw_data() override;
44 
45  secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
46  size_t output_bits,
47  RandomNumberGenerator& rng) override;
48 
49  bool verify(const secure_vector<uint8_t>& coded,
50  const secure_vector<uint8_t>& raw,
51  size_t key_bits) override;
52 
53  std::unique_ptr<HashFunction> m_hash;
54  size_t m_salt_size;
55  bool m_required_salt_len;
56  };
57 
58 /**
59 * PSSR_Raw
60 * This accepts a pre-hashed buffer
61 */
62 class BOTAN_PUBLIC_API(2,3) PSSR_Raw final : public EMSA
63  {
64  public:
65 
66  /**
67  * @param hash the hash function to use
68  */
69  explicit PSSR_Raw(HashFunction* hash);
70 
71  /**
72  * @param hash the hash function to use
73  * @param salt_size the size of the salt to use in bytes
74  */
76 
77  EMSA* clone() override;
78 
79  std::string name() const override;
80  private:
81  void update(const uint8_t input[], size_t length) override;
82 
83  secure_vector<uint8_t> raw_data() override;
84 
85  secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
86  size_t output_bits,
87  RandomNumberGenerator& rng) override;
88 
89  bool verify(const secure_vector<uint8_t>& coded,
90  const secure_vector<uint8_t>& raw,
91  size_t key_bits) override;
92 
93  std::unique_ptr<HashFunction> m_hash;
95  size_t m_salt_size;
96  bool m_required_salt_len;
97  };
98 
99 }
100 
101 #endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t salt_size
std::string name
Definition: alg_id.cpp:13
int(* update)(CTX *, const void *, CC_LONG len)
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
MechanismType hash