Botan 3.6.1
Crypto and TLS for C&
Botan::PSS_Params Class Referencefinal

#include <pss_params.h>

Inheritance diagram for Botan::PSS_Params:
Botan::ASN1_Object

Public Member Functions

std::vector< uint8_t > BER_encode () const
 
void decode_from (BER_Decoder &from) override
 
void encode_into (DER_Encoder &to) const override
 
const AlgorithmIdentifierhash_algid () const
 
std::string hash_function () const
 
const AlgorithmIdentifiermgf_algid () const
 
std::string mgf_function () const
 
const AlgorithmIdentifiermgf_hash_algid () const
 
template<typename Alloc >
 PSS_Params (const std::vector< uint8_t, Alloc > &vec)
 
 PSS_Params (const uint8_t der[], size_t der_len)
 
 PSS_Params (std::string_view hash_fn, size_t salt_len)
 
size_t salt_length () const
 
std::vector< uint8_t > serialize () const
 
size_t trailer_field () const
 

Static Public Member Functions

static PSS_Params from_emsa_name (std::string_view emsa_name)
 

Detailed Description

Definition at line 16 of file pss_params.h.

Constructor & Destructor Documentation

◆ PSS_Params() [1/3]

Botan::PSS_Params::PSS_Params ( std::string_view hash_fn,
size_t salt_len )

Definition at line 31 of file pss_params.cpp.

31 :
33 m_mgf("MGF1", m_hash.BER_encode()),
34 m_mgf_hash(m_hash),
35 m_salt_len(salt_len) {}
std::vector< uint8_t > BER_encode() const
Definition asn1_obj.cpp:19

Referenced by from_emsa_name().

◆ PSS_Params() [2/3]

Botan::PSS_Params::PSS_Params ( const uint8_t der[],
size_t der_len )

Definition at line 37 of file pss_params.cpp.

37 {
38 BER_Decoder decoder(der, der_len);
39 this->decode_from(decoder);
40}
void decode_from(BER_Decoder &from) override

References decode_from().

◆ PSS_Params() [3/3]

template<typename Alloc >
Botan::PSS_Params::PSS_Params ( const std::vector< uint8_t, Alloc > & vec)
inline

Definition at line 25 of file pss_params.h.

25: PSS_Params(vec.data(), vec.size()) {}
PSS_Params(std::string_view hash_fn, size_t salt_len)

Member Function Documentation

◆ BER_encode()

std::vector< uint8_t > Botan::ASN1_Object::BER_encode ( ) const
inherited

Return the encoding of this object. This is a convenience method when just one object needs to be serialized. Use DER_Encoder for complicated encodings.

Definition at line 19 of file asn1_obj.cpp.

19 {
20 std::vector<uint8_t> output;
21 DER_Encoder der(output);
22 this->encode_into(der);
23 return output;
24}
virtual void encode_into(DER_Encoder &to) const =0

References Botan::ASN1_Object::encode_into().

Referenced by decode_from(), Botan::Certificate_Store_In_SQL::find_all_certs(), Botan::Certificate_Store_In_SQL::find_cert(), Botan::X509_Certificate::fingerprint(), Botan::Certificate_Store_In_SQL::insert_cert(), Botan::X509_Object::PEM_encode(), and Botan::Certificate_Store_In_SQL::revoke_cert().

◆ decode_from()

void Botan::PSS_Params::decode_from ( BER_Decoder & from)
overridevirtual

Decode whatever this object is from from

Parameters
fromthe BER_Decoder that will be read from

Implements Botan::ASN1_Object.

Definition at line 67 of file pss_params.cpp.

67 {
68 const AlgorithmIdentifier default_hash("SHA-1", AlgorithmIdentifier::USE_NULL_PARAM);
69 const AlgorithmIdentifier default_mgf("MGF1", default_hash.BER_encode());
70 const size_t default_salt_len = 20;
71 const size_t default_trailer = 1;
72
73 from.start_sequence()
74 .decode_optional(m_hash, ASN1_Type(0), ASN1_Class::ExplicitContextSpecific, default_hash)
75 .decode_optional(m_mgf, ASN1_Type(1), ASN1_Class::ExplicitContextSpecific, default_mgf)
76 .decode_optional(m_salt_len, ASN1_Type(2), ASN1_Class::ExplicitContextSpecific, default_salt_len)
77 .decode_optional(m_trailer_field, ASN1_Type(3), ASN1_Class::ExplicitContextSpecific, default_trailer)
78 .end_cons();
79
80 BER_Decoder(m_mgf.parameters()).decode(m_mgf_hash);
81}
const std::vector< uint8_t > & parameters() const
Definition asn1_obj.h:466
ASN1_Type
Definition asn1_obj.h:44

References Botan::ASN1_Object::BER_encode(), Botan::BER_Decoder::decode(), Botan::BER_Decoder::decode_optional(), Botan::BER_Decoder::end_cons(), Botan::ExplicitContextSpecific, Botan::AlgorithmIdentifier::parameters(), Botan::BER_Decoder::start_sequence(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.

Referenced by PSS_Params().

◆ encode_into()

void Botan::PSS_Params::encode_into ( DER_Encoder & to) const
overridevirtual

Encode whatever this object is into to

Parameters
tothe DER_Encoder that will be written to

Implements Botan::ASN1_Object.

Definition at line 48 of file pss_params.cpp.

48 {
49 const size_t trailer_field = 1;
50
51 to.start_sequence()
52 .start_context_specific(0)
53 .encode(m_hash)
54 .end_cons()
55 .start_context_specific(1)
56 .encode(m_mgf)
57 .end_cons()
58 .start_context_specific(2)
59 .encode(m_salt_len)
60 .end_cons()
61 .start_context_specific(3)
62 .encode(trailer_field)
63 .end_cons()
64 .end_cons();
65}
size_t trailer_field() const
Definition pss_params.h:35

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::start_context_specific(), Botan::DER_Encoder::start_sequence(), and trailer_field().

◆ from_emsa_name()

PSS_Params Botan::PSS_Params::from_emsa_name ( std::string_view emsa_name)
static

Definition at line 18 of file pss_params.cpp.

18 {
19 SCAN_Name scanner(emsa_name);
20
21 if((scanner.algo_name() != "EMSA4" && scanner.algo_name() != "PSSR") || scanner.arg_count() != 3) {
22 throw Invalid_Argument(fmt("PSS_Params::from_emsa_name unexpected param '{}'", emsa_name));
23 }
24
25 const std::string hash_fn = scanner.arg(0);
26 BOTAN_ASSERT_NOMSG(scanner.arg(1) == "MGF1");
27 const size_t salt_len = scanner.arg_as_integer(2);
28 return PSS_Params(hash_fn, salt_len);
29}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), BOTAN_ASSERT_NOMSG, Botan::fmt(), and PSS_Params().

◆ hash_algid()

const AlgorithmIdentifier & Botan::PSS_Params::hash_algid ( ) const
inline

Definition at line 27 of file pss_params.h.

27{ return m_hash; }

Referenced by hash_function().

◆ hash_function()

std::string Botan::PSS_Params::hash_function ( ) const
inline

Definition at line 37 of file pss_params.h.

37{ return hash_algid().oid().to_formatted_string(); }
const OID & oid() const
Definition asn1_obj.h:464
std::string to_formatted_string() const
Definition asn1_oid.cpp:139
const AlgorithmIdentifier & hash_algid() const
Definition pss_params.h:27

References hash_algid(), Botan::AlgorithmIdentifier::oid(), and Botan::OID::to_formatted_string().

◆ mgf_algid()

const AlgorithmIdentifier & Botan::PSS_Params::mgf_algid ( ) const
inline

Definition at line 29 of file pss_params.h.

29{ return m_mgf; }

Referenced by mgf_function().

◆ mgf_function()

std::string Botan::PSS_Params::mgf_function ( ) const
inline

Definition at line 39 of file pss_params.h.

39{ return mgf_algid().oid().to_formatted_string(); }
const AlgorithmIdentifier & mgf_algid() const
Definition pss_params.h:29

References mgf_algid(), Botan::AlgorithmIdentifier::oid(), and Botan::OID::to_formatted_string().

◆ mgf_hash_algid()

const AlgorithmIdentifier & Botan::PSS_Params::mgf_hash_algid ( ) const
inline

Definition at line 31 of file pss_params.h.

31{ return m_mgf_hash; }

◆ salt_length()

size_t Botan::PSS_Params::salt_length ( ) const
inline

Definition at line 33 of file pss_params.h.

33{ return m_salt_len; }

◆ serialize()

std::vector< uint8_t > Botan::PSS_Params::serialize ( ) const

Definition at line 42 of file pss_params.cpp.

42 {
43 std::vector<uint8_t> output;
44 DER_Encoder(output).encode(*this);
45 return output;
46}

References Botan::DER_Encoder::encode().

◆ trailer_field()

size_t Botan::PSS_Params::trailer_field ( ) const
inline

Definition at line 35 of file pss_params.h.

35{ return m_trailer_field; }

Referenced by encode_into().


The documentation for this class was generated from the following files: