Botan 3.9.0
Crypto and TLS for C&
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/internal/sig_padding.h>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace Botan {
17
19class HashFunction;
20
21/**
22* PSSR (called EMSA4 in IEEE 1363 and in old versions of the library)
23*/
24class PSSR final : public SignaturePaddingScheme {
25 public:
26 /**
27 * @param hash the hash function to use
28 */
29 explicit PSSR(std::unique_ptr<HashFunction> hash);
30
31 /**
32 * @param hash the hash function to use
33 * @param salt_size the size of the salt to use in bytes
34 */
35 PSSR(std::unique_ptr<HashFunction> hash, size_t salt_size);
36
37 std::string name() const override;
38
39 std::string hash_function() const override;
40
41 private:
42 void update(const uint8_t input[], size_t length) override;
43
44 std::vector<uint8_t> raw_data() override;
45
46 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
47 size_t output_bits,
48 RandomNumberGenerator& rng) override;
49
50 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
51
52 std::unique_ptr<HashFunction> m_hash;
53 size_t m_salt_size;
54 bool m_required_salt_len;
55};
56
57/**
58* PSS_Raw
59* This accepts a pre-hashed buffer
60*/
61class PSS_Raw final : public SignaturePaddingScheme {
62 public:
63 /**
64 * @param hash the hash function to use
65 */
66 explicit PSS_Raw(std::unique_ptr<HashFunction> hash);
67
68 /**
69 * @param hash the hash function to use
70 * @param salt_size the size of the salt to use in bytes
71 */
72 PSS_Raw(std::unique_ptr<HashFunction> hash, size_t salt_size);
73
74 std::string hash_function() const override;
75
76 std::string name() const override;
77
78 private:
79 void update(const uint8_t input[], size_t length) override;
80
81 std::vector<uint8_t> raw_data() override;
82
83 std::vector<uint8_t> encoding_of(std::span<const uint8_t> msg,
84 size_t output_bits,
85 RandomNumberGenerator& rng) override;
86
87 bool verify(std::span<const uint8_t> coded, std::span<const uint8_t> raw, size_t key_bits) override;
88
89 std::unique_ptr<HashFunction> m_hash;
90 std::vector<uint8_t> m_msg;
91 size_t m_salt_size;
92 bool m_required_salt_len;
93};
94
95} // namespace Botan
96
97#endif
std::string name() const override
Definition pssr.cpp:191
PSSR(std::unique_ptr< HashFunction > hash)
Definition pssr.cpp:148
std::string hash_function() const override
Definition pssr.cpp:187
std::string name() const override
Definition pssr.cpp:247
PSS_Raw(std::unique_ptr< HashFunction > hash)
Definition pssr.cpp:195
std::string hash_function() const override
Definition pssr.cpp:243
virtual std::vector< uint8_t > raw_data()=0