Botan 3.5.0
Crypto and TLS for C&
Botan::AlgorithmIdentifier Class Referencefinal

#include <asn1_obj.h>

Inheritance diagram for Botan::AlgorithmIdentifier:
Botan::ASN1_Object

Public Types

enum  Encoding_Option { USE_NULL_PARAM , USE_EMPTY_PARAM }
 

Public Member Functions

 AlgorithmIdentifier ()=default
 
 AlgorithmIdentifier (const OID &oid, const std::vector< uint8_t > &params)
 
 AlgorithmIdentifier (const OID &oid, Encoding_Option enc)
 
 AlgorithmIdentifier (std::string_view oid_name, const std::vector< uint8_t > &params)
 
 AlgorithmIdentifier (std::string_view oid_name, Encoding_Option enc)
 
std::vector< uint8_t > BER_encode () const
 
void decode_from (BER_Decoder &) override
 
bool empty () const
 
void encode_into (DER_Encoder &) const override
 
const OIDget_oid () const
 
const std::vector< uint8_t > & get_parameters () const
 
const OIDoid () const
 
const std::vector< uint8_t > & parameters () const
 
bool parameters_are_empty () const
 
bool parameters_are_null () const
 
bool parameters_are_null_or_empty () const
 

Detailed Description

Algorithm Identifier

Definition at line 449 of file asn1_obj.h.

Member Enumeration Documentation

◆ Encoding_Option

Enumerator
USE_NULL_PARAM 
USE_EMPTY_PARAM 

Definition at line 451 of file asn1_obj.h.

Constructor & Destructor Documentation

◆ AlgorithmIdentifier() [1/5]

Botan::AlgorithmIdentifier::AlgorithmIdentifier ( )
default

◆ AlgorithmIdentifier() [2/5]

Botan::AlgorithmIdentifier::AlgorithmIdentifier ( const OID & oid,
Encoding_Option enc )

Definition at line 30 of file alg_id.cpp.

30 : m_oid(oid), m_parameters() {
31 const uint8_t DER_NULL[] = {0x05, 0x00};
32
33 if(option == USE_NULL_PARAM) {
34 m_parameters.assign(DER_NULL, DER_NULL + 2);
35 }
36}
const OID & oid() const
Definition asn1_obj.h:464

References USE_NULL_PARAM.

◆ AlgorithmIdentifier() [3/5]

Botan::AlgorithmIdentifier::AlgorithmIdentifier ( std::string_view oid_name,
Encoding_Option enc )

Definition at line 41 of file alg_id.cpp.

41 :
42 m_oid(OID::from_string(oid)), m_parameters() {
43 const uint8_t DER_NULL[] = {0x05, 0x00};
44
45 if(option == USE_NULL_PARAM) {
46 m_parameters.assign(DER_NULL, DER_NULL + 2);
47 }
48}
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:86

References USE_NULL_PARAM.

◆ AlgorithmIdentifier() [4/5]

Botan::AlgorithmIdentifier::AlgorithmIdentifier ( const OID & oid,
const std::vector< uint8_t > & params )

Definition at line 18 of file alg_id.cpp.

18 :
19 m_oid(oid), m_parameters(param) {}

◆ AlgorithmIdentifier() [5/5]

Botan::AlgorithmIdentifier::AlgorithmIdentifier ( std::string_view oid_name,
const std::vector< uint8_t > & params )

Definition at line 24 of file alg_id.cpp.

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 Botan::PSS_Params::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::AlgorithmIdentifier::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 83 of file alg_id.cpp.

83 {
84 codec.start_sequence().decode(m_oid).raw_bytes(m_parameters).end_cons();
85}

References Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::BER_Decoder::raw_bytes(), and Botan::BER_Decoder::start_sequence().

◆ empty()

bool Botan::AlgorithmIdentifier::empty ( ) const
inline

Definition at line 480 of file asn1_obj.h.

480{ return m_oid.empty() && m_parameters.empty(); }
bool empty() const
Definition asn1_obj.h:266

◆ encode_into()

void Botan::AlgorithmIdentifier::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 76 of file alg_id.cpp.

76 {
77 codec.start_sequence().encode(oid()).raw_bytes(parameters()).end_cons();
78}
const std::vector< uint8_t > & parameters() const
Definition asn1_obj.h:466

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), oid(), parameters(), Botan::DER_Encoder::raw_bytes(), and Botan::DER_Encoder::start_sequence().

◆ get_oid()

const OID & Botan::AlgorithmIdentifier::get_oid ( ) const
inline

Definition at line 468 of file asn1_obj.h.

468{ return m_oid; }

◆ get_parameters()

const std::vector< uint8_t > & Botan::AlgorithmIdentifier::get_parameters ( ) const
inline

Definition at line 470 of file asn1_obj.h.

470 {
471 return m_parameters;
472 }

◆ oid()

◆ parameters()

const std::vector< uint8_t > & Botan::AlgorithmIdentifier::parameters ( ) const
inline

◆ parameters_are_empty()

bool Botan::AlgorithmIdentifier::parameters_are_empty ( ) const
inline

Definition at line 476 of file asn1_obj.h.

476{ return m_parameters.empty(); }

Referenced by Botan::PK_Ops::Verification_with_Hash::Verification_with_Hash().

◆ parameters_are_null()

bool Botan::AlgorithmIdentifier::parameters_are_null ( ) const

Definition at line 50 of file alg_id.cpp.

50 {
51 return (m_parameters.size() == 2 && (m_parameters[0] == 0x05) && (m_parameters[1] == 0x00));
52}

Referenced by Botan::PK_Ops::Verification_with_Hash::Verification_with_Hash().

◆ parameters_are_null_or_empty()

bool Botan::AlgorithmIdentifier::parameters_are_null_or_empty ( ) const
inline

Definition at line 478 of file asn1_obj.h.

bool parameters_are_empty() const
Definition asn1_obj.h:476
bool parameters_are_null() const
Definition alg_id.cpp:50

Referenced by Botan::operator==().


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