scclib
Stable Cloud Computing C++ Library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
scc::crypto::DerDocument Class Reference

DER document. More...

#include <der.h>

Inheritance diagram for scc::crypto::DerDocument:
Inheritance graph
[legend]
Collaboration diagram for scc::crypto::DerDocument:
Collaboration graph
[legend]

Public Member Functions

 DerDocument (const DerDocument &)=delete
 
DerDocumentoperator= (const DerDocument &)=delete
 
 DerDocument (DerDocument &&b)
 
DerDocumentoperator= (DerDocument &&b)
 
bool equal (const DerDocument &) const
 Compare binary data.
 
void dump_bin (std::vector< char > &v) const
 Dump the binary vector.
 
virtual void parse (const std::vector< char > &)
 Parse a buffer from a binary DER-formatted vector. More...
 
virtual void parse (std::istream &)
 Parse document from an input stream. More...
 
virtual void dump (std::vector< char > &)
 Dump and append to a buffer. More...
 
virtual void dump (std::ostream &)
 Dump to output stream. More...
 
std::string str (bool=false) const
 Debug string dump. More...
 
DerBaseroot ()
 Root DerBase. More...
 
BasePtr root_ptr () const
 Return the root pointer. More...
 
void clear ()
 Clear the document.
 

Static Public Member Functions

static BasePtr parse_element (const std::vector< uint8_t > &, size_t=0)
 Parse an element from a data vector. More...
 
static BasePtr parse_element (const std::vector< char > &v, size_t idx=0)
 
static void dump_element (const BasePtr &, std::vector< uint8_t > &)
 Dump an element to a data vector. More...
 
static void dump_element (const BasePtr &b, std::vector< char > &v)
 
static std::string print_element (const BasePtr &, bool=false, const std::string &=" |")
 Print an element and any sub-elements to a string. More...
 

Protected Member Functions

void parse_bin ()
 
void dump_bin ()
 

Protected Attributes

SecVecUchar m_bin
 

Friends

class X509Cert
 

Detailed Description

DER document.

Binary document using the ASN.1 DER subset.

This assumes ownership of any DerBase object set to the root element.

Specification: https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf

Examples
scclib/crypto/unittest/der.cc, and scclib/crypto/unittest/der_cert.cc.

Definition at line 823 of file der.h.

Member Function Documentation

◆ dump() [1/2]

void DerDocument::dump ( std::ostream &  s)
virtual

Dump to output stream.

Throws exception on write error.

Reimplemented in scc::crypto::PemDocument.

Definition at line 1291 of file der.cc.

◆ dump() [2/2]

void DerDocument::dump ( std::vector< char > &  vout)
virtual

Dump and append to a buffer.

Binary data is reset.

Throws exception on error.

Reimplemented in scc::crypto::PemDocument.

Definition at line 1276 of file der.cc.

◆ dump_element()

void DerDocument::dump_element ( const BasePtr &  base,
std::vector< uint8_t > &  vout 
)
static

Dump an element to a data vector.

Null element produces no data.

Data is appended to the vector.

Definition at line 1231 of file der.cc.

◆ parse() [1/2]

void DerDocument::parse ( const std::vector< char > &  v)
virtual

Parse a buffer from a binary DER-formatted vector.

Binary data is reset.

Parsing an empty vector results in an empty document.

Reimplemented in scc::crypto::PemDocument.

Definition at line 1217 of file der.cc.

◆ parse() [2/2]

void DerDocument::parse ( std::istream &  s)
virtual

Parse document from an input stream.

Throws exception on read error or parse error.

Reimplemented in scc::crypto::PemDocument.

Definition at line 1224 of file der.cc.

◆ parse_element()

BasePtr DerDocument::parse_element ( const std::vector< uint8_t > &  binv,
size_t  off = 0 
)
static

Parse an element from a data vector.

Parameters
binvBinary vector to parse.
offOffset into vector.

Parse error, empty or invalid input data throws an exception.

Parses elements and fills containers. Returns the root element parsed.

Definition at line 1171 of file der.cc.

◆ print_element()

std::string DerDocument::print_element ( const BasePtr &  base,
bool  debug = false,
const std::string &  indent = " |" 
)
static

Print an element and any sub-elements to a string.

Empty base pointer produces "<null>" output.

Parameters
baseBase element.
debugPrint debugging offset information.
indentIndentation string, printed once per sublevel.

Container elements print an indentation string, then a delimiter string, before all sub-elements

Definition at line 1336 of file der.cc.

◆ root()

DerBase & DerDocument::root ( )

Root DerBase.

Throws exception if document is empty.

Definition at line 1297 of file der.cc.

◆ root_ptr()

BasePtr scc::crypto::DerDocument::root_ptr ( ) const
inline

Return the root pointer.

May be null if document is empty.

Definition at line 936 of file der.h.

◆ str()

std::string DerDocument::str ( bool  debug = false) const

Debug string dump.

Parameters
debugPrint document and element offset and size information.

Returns <null> string if document is empty.

Definition at line 1347 of file der.cc.


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