Botan  2.15.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 
15 
16 namespace Botan {
17 
18 /**
19 * PSSR (called EMSA4 in IEEE 1363 and in old versions of the library)
20 */
21 class BOTAN_PUBLIC_API(2,0) PSSR final : public EMSA
22  {
23  public:
24 
25  /**
26  * @param hash the hash function to use
27  */
28  explicit PSSR(HashFunction* hash);
29 
30  /**
31  * @param hash the hash function to use
32  * @param salt_size the size of the salt to use in bytes
33  */
34  PSSR(HashFunction* hash, size_t salt_size);
35 
36  EMSA* clone() override;
37 
38  std::string name() const override;
39 
41  const std::string& cert_hash_name) const override;
42  private:
43  void update(const uint8_t input[], size_t length) override;
44 
46 
48  size_t output_bits,
49  RandomNumberGenerator& rng) override;
50 
51  bool verify(const secure_vector<uint8_t>& coded,
52  const secure_vector<uint8_t>& raw,
53  size_t key_bits) override;
54 
55  std::unique_ptr<HashFunction> m_hash;
56  size_t m_salt_size;
57  bool m_required_salt_len;
58  };
59 
60 /**
61 * PSSR_Raw
62 * This accepts a pre-hashed buffer
63 */
64 class BOTAN_PUBLIC_API(2,3) PSSR_Raw final : public EMSA
65  {
66  public:
67 
68  /**
69  * @param hash the hash function to use
70  */
71  explicit PSSR_Raw(HashFunction* hash);
72 
73  /**
74  * @param hash the hash function to use
75  * @param salt_size the size of the salt to use in bytes
76  */
78 
79  EMSA* clone() override;
80 
81  std::string name() const override;
82  private:
83  void update(const uint8_t input[], size_t length) override;
84 
86 
88  size_t output_bits,
89  RandomNumberGenerator& rng) override;
90 
91  bool verify(const secure_vector<uint8_t>& coded,
92  const secure_vector<uint8_t>& raw,
93  size_t key_bits) override;
94 
95  std::unique_ptr<HashFunction> m_hash;
97  size_t m_salt_size;
98  bool m_required_salt_len;
99  };
100 
101 }
102 
103 #endif
virtual AlgorithmIdentifier config_for_x509(const Private_Key &key, const std::string &cert_hash_name) const
Definition: emsa.cpp:38
virtual std::string name() const =0
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
virtual EMSA * clone()=0
virtual void update(const uint8_t input[], size_t length)=0
size_t salt_size
virtual bool verify(const secure_vector< uint8_t > &coded, const secure_vector< uint8_t > &raw, size_t key_bits)=0
Definition: alg_id.cpp:13
virtual secure_vector< uint8_t > raw_data()=0
virtual secure_vector< uint8_t > encoding_of(const secure_vector< uint8_t > &msg, size_t output_bits, RandomNumberGenerator &rng)=0
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:145
MechanismType hash