/src/botan/build/include/botan/internal/pssr.h
Line | Count | Source (jump to first uncovered line) |
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/internal/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 PSSR final : public EMSA |
20 | | { |
21 | | public: |
22 | | |
23 | | /** |
24 | | * @param hash the hash function to use |
25 | | */ |
26 | | explicit PSSR(std::unique_ptr<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(std::unique_ptr<HashFunction> hash, size_t salt_size); |
33 | | |
34 | | std::unique_ptr<EMSA> new_object() 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 | | |
41 | 0 | bool requires_message_recovery() const override { return true; } |
42 | | private: |
43 | | void update(const uint8_t input[], size_t length) override; |
44 | | |
45 | | secure_vector<uint8_t> raw_data() override; |
46 | | |
47 | | secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg, |
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 PSSR_Raw final : public EMSA |
65 | | { |
66 | | public: |
67 | | |
68 | | /** |
69 | | * @param hash the hash function to use |
70 | | */ |
71 | | explicit PSSR_Raw(std::unique_ptr<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 | | */ |
77 | | PSSR_Raw(std::unique_ptr<HashFunction> hash, size_t salt_size); |
78 | | |
79 | | std::unique_ptr<EMSA> new_object() override; |
80 | | |
81 | | std::string name() const override; |
82 | | |
83 | 0 | bool requires_message_recovery() const override { return true; } |
84 | | private: |
85 | | void update(const uint8_t input[], size_t length) override; |
86 | | |
87 | | secure_vector<uint8_t> raw_data() override; |
88 | | |
89 | | secure_vector<uint8_t> encoding_of(const secure_vector<uint8_t>& msg, |
90 | | size_t output_bits, |
91 | | RandomNumberGenerator& rng) override; |
92 | | |
93 | | bool verify(const secure_vector<uint8_t>& coded, |
94 | | const secure_vector<uint8_t>& raw, |
95 | | size_t key_bits) override; |
96 | | |
97 | | std::unique_ptr<HashFunction> m_hash; |
98 | | secure_vector<uint8_t> m_msg; |
99 | | size_t m_salt_size; |
100 | | bool m_required_salt_len; |
101 | | }; |
102 | | |
103 | | } |
104 | | |
105 | | #endif |