Coverage Report

Created: 2025-11-11 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Botan-3.4.0/build/include/internal/botan/internal/pssr.h
Line
Count
Source
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/hash.h>
12
#include <botan/internal/emsa.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
   public:
21
      /**
22
      * @param hash the hash function to use
23
      */
24
      explicit PSSR(std::unique_ptr<HashFunction> hash);
25
26
      /**
27
      * @param hash the hash function to use
28
      * @param salt_size the size of the salt to use in bytes
29
      */
30
      PSSR(std::unique_ptr<HashFunction> hash, size_t salt_size);
31
32
      std::string name() const override;
33
34
0
      std::string hash_function() const override { return m_hash->name(); }
35
36
   private:
37
      void update(const uint8_t input[], size_t length) override;
38
39
      std::vector<uint8_t> raw_data() override;
40
41
      std::vector<uint8_t> encoding_of(const std::vector<uint8_t>& msg,
42
                                       size_t output_bits,
43
                                       RandomNumberGenerator& rng) override;
44
45
      bool verify(const std::vector<uint8_t>& coded, const std::vector<uint8_t>& raw, size_t key_bits) override;
46
47
      std::unique_ptr<HashFunction> m_hash;
48
      size_t m_salt_size;
49
      bool m_required_salt_len;
50
};
51
52
/**
53
* PSSR_Raw
54
* This accepts a pre-hashed buffer
55
*/
56
class PSSR_Raw final : public EMSA {
57
   public:
58
      /**
59
      * @param hash the hash function to use
60
      */
61
      explicit PSSR_Raw(std::unique_ptr<HashFunction> hash);
62
63
      /**
64
      * @param hash the hash function to use
65
      * @param salt_size the size of the salt to use in bytes
66
      */
67
      PSSR_Raw(std::unique_ptr<HashFunction> hash, size_t salt_size);
68
69
0
      std::string hash_function() const override { return m_hash->name(); }
70
71
      std::string name() const override;
72
73
   private:
74
      void update(const uint8_t input[], size_t length) override;
75
76
      std::vector<uint8_t> raw_data() override;
77
78
      std::vector<uint8_t> encoding_of(const std::vector<uint8_t>& msg,
79
                                       size_t output_bits,
80
                                       RandomNumberGenerator& rng) override;
81
82
      bool verify(const std::vector<uint8_t>& coded, const std::vector<uint8_t>& raw, size_t key_bits) override;
83
84
      std::unique_ptr<HashFunction> m_hash;
85
      std::vector<uint8_t> m_msg;
86
      size_t m_salt_size;
87
      bool m_required_salt_len;
88
};
89
90
}  // namespace Botan
91
92
#endif