Virgil Security Crypto library  1.8.2
Public Member Functions | List of all members
virgil::crypto::foundation::asn1::VirgilAsn1Writer Class Reference

This class provides methods for writing ASN.1 data structure. More...

#include <VirgilAsn1Writer.h>

Public Member Functions

 VirgilAsn1Writer ()
 Initialize internal state for the first use. More...
 
 VirgilAsn1Writer (size_t capacity)
 Initialize internal state for the first use. More...
 
 ~VirgilAsn1Writer () throw ()
 Dispose internal resources.
 
Start and Finish writing
void reset ()
 Reset all internal states and prepare to new ASN.1 writing operations.
 
void reset (size_t capacity)
 Reset all internal states and prepare to new ASN.1 writing operations. More...
 
virgil::crypto::VirgilByteArray finish ()
 Returns the result ASN.1 structure. More...
 
Write Simple ASN.1 Types
size_t writeInteger (int value)
 Write ASN.1 type: INTEGER. More...
 
size_t writeBool (bool value)
 Write ASN.1 type: BOOLEAN. More...
 
size_t writeNull ()
 Write ASN.1 type: NULL. More...
 
size_t writeOctetString (const virgil::crypto::VirgilByteArray &data)
 Write ASN.1 type: OCTET STRING. More...
 
size_t writeUTF8String (const virgil::crypto::VirgilByteArray &data)
 Write ASN.1 type: UTF8String. More...
 
size_t writeContextTag (unsigned char tag, size_t len)
 Write ASN.1 type: TAG. More...
 
size_t writeData (const virgil::crypto::VirgilByteArray &data)
 Write preformatted ASN.1 structure. More...
 
size_t writeOID (const std::string &oid)
 Write ASN.1 type: OID. More...
 
Write Structured ASN.1 Types
size_t writeSequence (size_t len)
 Write ASN.1 type: SEQUENCE. More...
 
size_t writeSet (const std::vector< virgil::crypto::VirgilByteArray > &set)
 Write ASN.1 type: SET OF ANY. More...
 

Detailed Description

This class provides methods for writing ASN.1 data structure.

Note
All "write*" methods perform writing of ASN.1 structure sequentially.
Implementation is not complete yet, only minimum set of operations are supported.

Constructor & Destructor Documentation

virgil::crypto::foundation::asn1::VirgilAsn1Writer::VirgilAsn1Writer ( )

Initialize internal state for the first use.

See also
reset method for reusing this class to create new ASN.1 stucture.
virgil::crypto::foundation::asn1::VirgilAsn1Writer::VirgilAsn1Writer ( size_t  capacity)

Initialize internal state for the first use.

Parameters
capacity- expected ASN.1 final size
See also
reset method for reusing this class to create new ASN.1 stucture.

Member Function Documentation

virgil::crypto::VirgilByteArray virgil::crypto::foundation::asn1::VirgilAsn1Writer::finish ( )

Returns the result ASN.1 structure.

Returns
ASN.1 structure that was written.
Warning
After call this method all attempts to write more data will cause exceptions.
void virgil::crypto::foundation::asn1::VirgilAsn1Writer::reset ( size_t  capacity)

Reset all internal states and prepare to new ASN.1 writing operations.

Parameters
capacity- expected ASN.1 final size
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeBool ( bool  value)

Write ASN.1 type: BOOLEAN.

Parameters
value- boolean value to be written.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeContextTag ( unsigned char  tag,
size_t  len 
)

Write ASN.1 type: TAG.

Parameters
tag- custom tag.
len- length of the taged element, use methods return value to calculate it.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeData ( const virgil::crypto::VirgilByteArray &  data)

Write preformatted ASN.1 structure.

Parameters
data- ASN.1 structure.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeInteger ( int  value)

Write ASN.1 type: INTEGER.

Parameters
value- integer value to be written.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeNull ( )

Write ASN.1 type: NULL.

Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeOctetString ( const virgil::crypto::VirgilByteArray &  data)

Write ASN.1 type: OCTET STRING.

Parameters
data- octet string to be written.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeOID ( const std::string &  oid)

Write ASN.1 type: OID.

Parameters
oid- the OID to write.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeSequence ( size_t  len)

Write ASN.1 type: SEQUENCE.

Parameters
len- sequence length in bytes.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeSet ( const std::vector< virgil::crypto::VirgilByteArray > &  set)

Write ASN.1 type: SET OF ANY.

Parameters
set- set of any data represented as byte sequence.
Returns
Written bytes.
size_t virgil::crypto::foundation::asn1::VirgilAsn1Writer::writeUTF8String ( const virgil::crypto::VirgilByteArray &  data)

Write ASN.1 type: UTF8String.

Parameters
data- UTF8 string to be written.
Returns
Written bytes.

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