Coverage Report

Created: 2026-07-25 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/botan/build/include/public/botan/pss_params.h
Line
Count
Source
1
/*
2
* (C) 2017 Daniel Neus
3
*     2023 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_PSS_PARAMS_H_
9
#define BOTAN_PSS_PARAMS_H_
10
11
#include <botan/asn1_obj.h>
12
#include <string>
13
14
namespace Botan {
15
16
/**
17
* PSS parameters type
18
*
19
* Handles encoding/decoding of RSASSA-PSS-params from RFC 3447
20
*
21
* Only MGF1 is supported, and the trailer field must 1 (ie the variant
22
* from IEEE 1363a using a hash identifier is not supported)
23
*/
24
class BOTAN_PUBLIC_API(3, 7) PSS_Params final : public ASN1_Object {
25
   public:
26
      /**
27
      * Note that the only valid strings you can pass to this function
28
      * are values returned by EMSA::name() and these may change in a
29
      * minor release.
30
      */
31
      static PSS_Params from_emsa_name(std::string_view emsa_name);
32
33
      PSS_Params(std::string_view hash_fn, size_t salt_len);
34
35
      /**
36
      * Decode an encoded RSASSA-PSS-params
37
      */
38
      PSS_Params(std::span<const uint8_t> der);
39
40
0
      const AlgorithmIdentifier& hash_algid() const { return m_hash; }
41
42
0
      const AlgorithmIdentifier& mgf_algid() const { return m_mgf; }
43
44
0
      const AlgorithmIdentifier& mgf_hash_algid() const { return m_mgf_hash; }
45
46
0
      size_t salt_length() const { return m_salt_len; }
47
48
0
      size_t trailer_field() const { return m_trailer_field; }
49
50
0
      std::string hash_function() const { return hash_algid().oid().to_formatted_string(); }
51
52
0
      std::string mgf_function() const { return mgf_algid().oid().to_formatted_string(); }
53
54
      std::vector<uint8_t> serialize() const;
55
56
      void encode_into(DER_Encoder& to) const override;
57
58
   private:
59
      // We don't currently support uninitialized PSS_Params
60
      void decode_from(BER_Decoder& from) override;
61
62
      AlgorithmIdentifier m_hash;
63
      AlgorithmIdentifier m_mgf;
64
      AlgorithmIdentifier m_mgf_hash;
65
      size_t m_salt_len;
66
      size_t m_trailer_field;
67
};
68
69
}  // namespace Botan
70
71
#endif