scclib
Stable Cloud Computing C++ Library
Public Member Functions | List of all members
scc::crypto::PemDocument Class Reference

PEM formatted DER document. More...

#include <der.h>

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

Public Member Functions

 PemDocument (unsigned chars_per_line=64)
 
 PemDocument (const std::string &label, unsigned chars_per_line=64)
 
unsigned chars_per_line () const
 
void chars_per_line (unsigned v)
 
std::string label () const
 
void label (std::string v)
 
virtual void parse (std::istream &)
 Parse document from an input stream. More...
 
virtual void parse (const std::vector< char > &)
 Parse a PEM-formatted buffer.
 
virtual void dump (std::vector< char > &)
 PEM-formatted dump to a buffer. More...
 
virtual void dump (std::ostream &)
 Dump to output stream. More...
 
- Public Member Functions inherited from scc::crypto::DerDocument
 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.
 
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.
 

Additional Inherited Members

- Static Public Member Functions inherited from scc::crypto::DerDocument
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 inherited from scc::crypto::DerDocument
void parse_bin ()
 
void dump_bin ()
 
- Protected Attributes inherited from scc::crypto::DerDocument
SecVecUchar m_bin
 

Detailed Description

PEM formatted DER document.

Base64 encoded format defined in https://tools.ietf.org/html/rfc1421

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

Definition at line 950 of file der.h.

Member Function Documentation

◆ dump() [1/2]

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

Dump to output stream.

Throws exception on dump or write error.

Reimplemented from scc::crypto::DerDocument.

Definition at line 1451 of file der.cc.

◆ dump() [2/2]

void PemDocument::dump ( std::vector< char > &  v)
virtual

PEM-formatted dump to a buffer.

Data is appended to the buffer, starting with --—BEGIN <label>--— line, and ending with --—END <label>--— line.

Writes chars per line for the output base64 data.

Exception on error, or if label is empty.

Reimplemented from scc::crypto::DerDocument.

Definition at line 1422 of file der.cc.

◆ parse()

void PemDocument::parse ( std::istream &  sst)
virtual

Parse document from an input stream.

Scans the input stream until "-----BEGIN <label>-----" line is found. Continues until "-----END <label>-----" line is found. Decodes base64-encoded DER data.

Throws exception on parse error, or if BEGIN/END block not found.

Reimplemented from scc::crypto::DerDocument.

Definition at line 1369 of file der.cc.


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