Coverage Report

Created: 2026-04-08 06:11

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 SignaturePaddingScheme::name() and
29
      * these may change in a minor release.
30
      */
31
      static PSS_Params from_padding_name(std::string_view padding_name);
32
33
      /**
34
      * Note that the only valid strings you can pass to this function
35
      * are values returned by SignaturePaddingScheme::name() and
36
      * these may change in a minor release.
37
      */
38
      BOTAN_DEPRECATED("Use PSS_Params::from_padding_name")
39
0
      static PSS_Params from_emsa_name(std::string_view padding_name) {
40
0
         return PSS_Params::from_padding_name(padding_name);
41
0
      }
42
43
      PSS_Params(std::string_view hash_fn, size_t salt_len);
44
45
      /**
46
      * Decode an encoded RSASSA-PSS-params
47
      */
48
      BOTAN_FUTURE_EXPLICIT PSS_Params(std::span<const uint8_t> der);
49
50
44
      const AlgorithmIdentifier& hash_algid() const { return m_hash; }
51
52
22
      const AlgorithmIdentifier& mgf_algid() const { return m_mgf; }
53
54
22
      const AlgorithmIdentifier& mgf_hash_algid() const { return m_mgf_hash; }
55
56
14
      size_t salt_length() const { return m_salt_len; }
57
58
14
      size_t trailer_field() const { return m_trailer_field; }
59
60
22
      std::string hash_function() const { return hash_algid().oid().to_formatted_string(); }
61
62
22
      std::string mgf_function() const { return mgf_algid().oid().to_formatted_string(); }
63
64
      std::vector<uint8_t> serialize() const;
65
66
      void encode_into(DER_Encoder& to) const override;
67
68
   private:
69
      // We don't currently support uninitialized PSS_Params
70
      void decode_from(BER_Decoder& from) override;
71
72
      AlgorithmIdentifier m_hash;
73
      AlgorithmIdentifier m_mgf;
74
      AlgorithmIdentifier m_mgf_hash;
75
      size_t m_salt_len;
76
      size_t m_trailer_field;
77
};
78
79
}  // namespace Botan
80
81
#endif