Botan 3.7.1
Crypto and TLS for C&
pss_params.h
Go to the documentation of this file.
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
14namespace 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*/
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 const AlgorithmIdentifier& hash_algid() const { return m_hash; }
41
42 const AlgorithmIdentifier& mgf_algid() const { return m_mgf; }
43
44 const AlgorithmIdentifier& mgf_hash_algid() const { return m_mgf_hash; }
45
46 size_t salt_length() const { return m_salt_len; }
47
48 size_t trailer_field() const { return m_trailer_field; }
49
50 std::string hash_function() const { return hash_algid().oid().to_formatted_string(); }
51
52 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
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
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:19
size_t trailer_field() const
Definition pss_params.h:48
size_t salt_length() const
Definition pss_params.h:46
const AlgorithmIdentifier & hash_algid() const
Definition pss_params.h:40
const AlgorithmIdentifier & mgf_algid() const
Definition pss_params.h:42
std::string mgf_function() const
Definition pss_params.h:52
std::string hash_function() const
Definition pss_params.h:50
const AlgorithmIdentifier & mgf_hash_algid() const
Definition pss_params.h:44
int(* final)(unsigned char *, CTX *)