Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::OCSP::CertID Class Referencefinal

`#include <ocsp_types.h>`

Inheritance diagram for Botan::OCSP::CertID:

## Public Member Functions
| CertID ()=default
| CertID (const X509_Certificate &issuer, const BigInt &subject_serial)
void | decode_from (class BER_Decoder &from) override
void | encode_into (class DER_Encoder &to) const override
bool | is_id_for (const X509_Certificate &issuer, const X509_Certificate &subject) const
const std::vector< uint8_t > & | issuer_key_hash () const

## Detailed Description

Definition at line 19 of file ocsp_types.h.

## Constructor & Destructor Documentation

Botan::OCSP::CertID::CertID | ( |  | ) |
| default

Botan::OCSP::CertID::CertID | ( | const X509_Certificate & | issuer,
|  | const BigInt & | subject_serial
| ) |  |

Definition at line 19 of file ocsp_types.cpp.

References Botan::HashFunction::create(), hash, Botan::X509_Certificate::raw_subject_dn(), Botan::X509_Certificate::subject_public_key_bitstring(), Botan::unlock(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.

21 {
22 /*
23 In practice it seems some responders, including, notably,
24 ocsp.verisign.com, will reject anything but SHA-1 here
25 */
26 std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-160"));
27
28 m_hash_id = AlgorithmIdentifier(hash->name(), AlgorithmIdentifier::USE_NULL_PARAM);
29 m_issuer_key_hash = unlock(hash->process(issuer.subject_public_key_bitstring()));
30 m_issuer_dn_hash = unlock(hash->process(issuer.raw_subject_dn()));
31 m_subject_serial = subject_serial;
32 }
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:93
Botan::unlock
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:125
Botan::AlgorithmIdentifier::USE_NULL_PARAM
Definition: alg_id.h:23
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

## Member Function Documentation

void Botan::OCSP::CertID::decode_from | ( | class BER_Decoder & | from | ) |
| override virtual

Decode whatever this object is from from

Parameters

  from | the BER_Decoder that will be read from

Implements Botan::ASN1_Object.

Definition at line 68 of file ocsp_types.cpp.

References Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::BER_Decoder::start_cons().

69 {
70 from.start_cons(SEQUENCE)
71 .decode(m_hash_id)
72 .decode(m_issuer_dn_hash, OCTET_STRING)
73 .decode(m_issuer_key_hash, OCTET_STRING)
74 .decode(m_subject_serial)
75 .end_cons();
76
77 }
Botan::OCTET_STRING
Definition: asn1_obj.h:35
Botan::SEQUENCE
Definition: asn1_obj.h:39

void Botan::OCSP::CertID::encode_into | ( | class DER_Encoder & | to | ) | const
| override virtual

Encode whatever this object is into to

Parameters

  to | the DER_Encoder that will be written to

Implements Botan::ASN1_Object.

Definition at line 58 of file ocsp_types.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

59 {
60 to.start_cons(SEQUENCE)
61 .encode(m_hash_id)
62 .encode(m_issuer_dn_hash, OCTET_STRING)
63 .encode(m_issuer_key_hash, OCTET_STRING)
64 .encode(m_subject_serial)
65 .end_cons();
66 }
Botan::OCTET_STRING
Definition: asn1_obj.h:35
Botan::SEQUENCE
Definition: asn1_obj.h:39

bool Botan::OCSP::CertID::is_id_for | ( | const X509_Certificate & | issuer,
|  | const X509_Certificate & | subject
| ) |  | const

Definition at line 34 of file ocsp_types.cpp.

References Botan::HashFunction::create(), Botan::BigInt::decode(), hash, Botan::OIDS::lookup(), Botan::AlgorithmIdentifier::oid, Botan::X509_Certificate::raw_issuer_dn(), Botan::X509_Certificate::serial_number(), Botan::X509_Certificate::subject_public_key_bitstring(), and Botan::unlock().

36 {
37 try
38 {
39 if(BigInt::decode(subject.serial_number()) != m_subject_serial)
40 return false;
41
42 std::unique_ptr<HashFunction> hash(HashFunction::create(OIDS::lookup(m_hash_id.oid)));
43
44 if(m_issuer_dn_hash != unlock(hash->process(subject.raw_issuer_dn())))
45 return false;
46
47 if(m_issuer_key_hash != unlock(hash->process(issuer.subject_public_key_bitstring())))
48 return false;
49 }
50 catch(...)
51 {
52 return false;
53 }
54
55 return true;
56 }
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18
Botan::AlgorithmIdentifier::oid
OID oid
Definition: alg_id.h:36
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:93
Botan::unlock
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:125
hash
MechanismType hash
Definition: p11_mechanism.cpp:63
Botan::BigInt::decode
static BigInt decode(const uint8_t buf[], size_t length, Base base=Binary)
Definition: big_code.cpp:114

const std::vector<uint8_t>& Botan::OCSP::CertID::issuer_key_hash | ( |  | ) | const
| inline

Definition at line 34 of file ocsp_types.h.

34 { return m_issuer_key_hash; }

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

- src/lib/x509/ocsp_types.h
- src/lib/x509/ocsp_types.cpp