|
enum | Tag {
id_mask = 0x1f
, construct_mask = 0x20
, class_mask = 0xc0
, class_application = 0x40
,
class_context = 0x80
, class_private = 0xc0
, length_multi_mask = 0x80
, length_bytes_mask = 0x7f
,
type_boolean = 1
, type_integer = 2
, type_bit_string = 3
, type_octet_string = 4
,
type_null = 5
, type_object_identifier = 6
, type_utf8_string = 12
, type_sequence = 16
,
type_set = 17
, type_printable_string = 19
, type_teletex_string = 20
, type_ia5_string = 22
,
type_utc_time = 23
, type_generalized_time = 24
, type_visible_string = 26
, type_universal_string = 28
,
type_bmp_string = 30
} |
|
|
| DerBase (uint8_t tag=0) |
| Construct a base object. More...
|
|
size_t | eloff () const |
| Offset of the element into the binary vector.
|
|
void | eloff (size_t v) |
|
size_t | elsz () const |
| Binary vector element length, not including the header.
|
|
void | elsz (size_t v) |
|
size_t | hdrsz () const |
| Header size of the element (tag, id, and length bytes).
|
|
void | hdrsz (size_t v) |
|
size_t | pre_len () const |
| The length of prefix bytes (tag/id, and length).
|
|
virtual size_t | len () const |
| Length of the data.
|
|
virtual void | parse (const std::vector< uint8_t > &v) |
| Parse raw data into the object.
|
|
virtual void | dump_pre (std::vector< char > &) const |
| Dump prefix data. More...
|
|
virtual void | dump_data (std::vector< char > &) const |
| Dump data. More...
|
|
virtual std::string | str (uint32_t=100) const |
| Print summary line to maximum width.
|
|
virtual std::string | data_str () const |
| Print vizualized data.
|
|
virtual std::string | name () const |
|
std::vector< uint8_t > & | data () |
| Underlying data.
|
|
void | get_base (std::vector< uint8_t > &v) const |
| Get raw data.
|
|
void | set_base (const std::vector< uint8_t > &v) |
| Set raw data.
|
|
void | set_base (const std::vector< char > &v) |
|
uint32_t | id () const |
| Tag id of the type. More...
|
|
void | id (uint32_t v) |
|
std::string | id_str () const |
| String version of the id.
|
|
uint8_t | type_class () const |
| Classification of the type (bits 7-8)
|
|
void | type_class (uint8_t f) |
| Set type class.
|
|
bool | uni_class () const |
| Universal class.
|
|
bool | app_class () const |
| Application class.
|
|
bool | context_class () const |
| Context class.
|
|
bool | priv_class () const |
| Private class.
|
|
std::string | class_str () const |
| String version of the classification.
|
|
bool | constructed () const |
| Constructed flag (bit 6).
|
|
void | constructed (bool cons) |
| Set constructed flag.
|
|
std::string | construct_str () const |
| String version of the construct flag.
|
|
bool | is_seq () const |
| Is this a sequence type?
|
|
bool | is_set () const |
| Is this a set type?
|
|
bool | is_contain () const |
| Is this a container type?
|
|
std::vector< BasePtr > & | contain () |
| Return container, or throw an error if this is not a container.
|
|
bool | is_integer () const |
| Is this a DerInteger?
|
|
scc::crypto::Bignum & | integer () |
| Return reference to a scc::crypto::Bignum. More...
|
|
bool | is_bit_string () const |
| Is this a DerBitString?
|
|
BitString & | bit_string () |
| Return reference to bit string.
|
|
bool | is_octet_string () const |
| Is this an octet string (8 bit chars)?
|
|
bool | is_printable_string () const |
| Is this a printable string?
|
|
bool | is_utf8_string () const |
| Is this a utf8 (ascii) string?
|
|
bool | is_ia5_string () const |
| Is this an ia5 (ascii) string?
|
|
bool | is_bmp_string () const |
| Is this a bmp (ascii) string?
|
|
bool | is_universal_string () const |
| Is this a univeral (ascii) string?
|
|
bool | is_teletex_string () const |
| Is this a teletex (ascii) string?
|
|
bool | is_visible_string () const |
| Is this a visible (ascii) string?
|
|
bool | is_string () const |
| Is this a generic ascii string?
|
|
std::string | string () |
| Return string.
|
|
void | string (const std::string &) |
| Set the string.
|
|
void | string_get (std::vector< char > &) |
| Get string vector.
|
|
void | string_get (std::vector< uint8_t > &) |
|
void | string_set (const std::vector< char > &) |
| Set string vector.
|
|
void | string_set (const std::vector< uint8_t > &) |
|
bool | is_null () const |
| Is this a null type?
|
|
bool | is_boolean () const |
| Is this a boolean type?
|
|
bool | boolean () |
| Return boolean value.
|
|
void | boolean (bool) |
| Set boolean value.
|
|
bool | is_utc_time () const |
| Is this a utc time type?
|
|
bool | is_generalized_time () const |
| Is this as generalized time type?
|
|
bool | is_time () const |
| Is this a time type?
|
|
time_t | time_epoch () |
| Epoch time. More...
|
|
std::chrono::system_clock::time_point | time_point () |
| Time point.
|
|
bool | is_object_id () const |
| Is this an object identifier?
|
|
oid_value | object_id () |
| Return the object identifier value.
|
|
void | object_id (const oid_value &) |
| Set the object identifier.
|
|
|
static BasePtr | create (int) |
| Create a base pointer, using only the tag byte.
|
|
static BasePtr | create (const std::vector< uint8_t > &, size_t) |
| Create a base pointer, with extended header bytes.
|
|
static BasePtr | context_to_explicit (const BasePtr &) |
| Change a context element to explicit. More...
|
|
static BasePtr | explicit_to_context (const BasePtr &BasePtr, uint32_t) |
| Convert explicit to context. More...
|
|
static BasePtr | context_to_implicit (const BasePtr &, uint32_t) |
| Change a context element to implicit. More...
|
|
static BasePtr | implicit_to_context (const BasePtr &BasePtr, uint32_t) |
| Convert implicit to context. More...
|
|
ASN.1 base.
All objects can be manipulated using unique_ptr to Base object.
- Examples
- scclib/crypto/unittest/der.cc.
Definition at line 174 of file der.h.
BasePtr DerBase::context_to_explicit |
( |
const BasePtr & |
ctx | ) |
|
|
static |
Change a context element to explicit.
- Parameters
-
ctx | Original context element. Data from this element is parsed to create a new element. |
The ASN.1 spec says that explicit elements must be context-class and constructed. This api throws an exception otherwise.
The data is used to construct a new element, which is returned.
Definition at line 1048 of file der.cc.
BasePtr DerBase::context_to_implicit |
( |
const BasePtr & |
ctx, |
|
|
uint32_t |
id |
|
) |
| |
|
static |
Change a context element to implicit.
- Parameters
-
ctx | Original element. |
id | The type id (type_* from DerBase::Tag) |
The ASN.1 spec says that implicit elements must be context-class. This api throws an exception otherwise.
A universal element is created with the same construct flag as the original element.
A new element is constructed by changing the tag to the input tag provided. If the input tag is constructed, the input element must be as well.
Definition at line 1072 of file der.cc.
BasePtr DerBase::implicit_to_context |
( |
const BasePtr & |
BasePtr, |
|
|
uint32_t |
id |
|
) |
| |
|
static |
Convert implicit to context.
- Parameters
-
orig | The element to be converted to context. |
id | Id to be applied to the returned context element. |
Output will be a context-class element with the input id, and data the same as the input element. If the input element is constructed, the output element will also be set constructed.
Definition at line 1090 of file der.cc.