Botan  2.4.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 { return new PSSR(m_hash->clone(), m_SALT_SIZE); }
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  };
56 
57 /**
58 * PSSR_Raw
59 * This accepts a pre-hashed buffer
60 */
61 class BOTAN_DLL PSSR_Raw final : public EMSA
62  {
63  public:
64 
65  /**
66  * @param hash the hash function to use
67  */
68  explicit PSSR_Raw(HashFunction* hash);
69 
70  /**
71  * @param hash the hash function to use
72  * @param salt_size the size of the salt to use in bytes
73  */
74  PSSR_Raw(HashFunction* hash, size_t salt_size);
75 
76  EMSA* clone() override { return new PSSR_Raw(m_hash->clone(), m_SALT_SIZE); }
77 
78  std::string name() const override;
79  private:
80  void update(const uint8_t input[], size_t length) override;
81 
82  secure_vector<uint8_t> raw_data() override;
83 
84  secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg,
85  size_t output_bits,
86  RandomNumberGenerator& rng) override;
87 
88  bool verify(const secure_vector<uint8_t>& coded,
89  const secure_vector<uint8_t>& raw,
90  size_t key_bits) override;
91 
92  std::unique_ptr<HashFunction> m_hash;
93  size_t m_SALT_SIZE;
95  };
96 
97 }
98 
99 #endif
EMSA * clone() override
Definition: pssr.h:34
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t salt_size
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
EMSA * clone() override
Definition: pssr.h:76
MechanismType hash