Crescendo SDK
Loading...
Searching...
No Matches
CrescendoDLL.PCSC.BerTLVBuffer Class Reference

Represents a BER-TLV (Binary Encoded Representation Tag-Length-Value) data buffer for PIV (Personal Identity Verification) data object handling. More...

Public Member Functions

BerTLVBuffer AddTag (string tag, byte[]? data)
 Adds or updates a tag-value pair in the buffer.
 
 BerTLVBuffer (byte[]? data, string berTLVTag)
 Constructs a BER-TLV buffer from raw card response data.
 
byte[] ConstructDataFieldFromBerTLVBuffer ()
 Constructs complete PIV data field with tag list.
 
BerTLVBuffer RemoveTag (string tag)
 Removes a tag-value pair from the buffer.
 
byte[] ToByte ()
 Serializes the buffer to BER-TLV formatted byte array.
 

Public Attributes

Dictionary< string, byte[]> Content = new()
 Dictionary of TLV components (Tag-Length-Value entries)
 
bool IsEmpty = true
 Indicates if the buffer contains no valid TLV data.
 

Properties

string BERTLVTag = default! [get, set]
 Main BER-TLV tag identifier for the data object.
 
byte GeneralTag = 0x53 [get, set]
 General encapsulation tag (default: 0x53 for Discovery Object)
 

Detailed Description

Represents a BER-TLV (Binary Encoded Representation Tag-Length-Value) data buffer for PIV (Personal Identity Verification) data object handling.

Implements encoding/decoding of PIV data objects per NIST SP 800-73-4 specifications.

Constructor & Destructor Documentation

◆ BerTLVBuffer()

CrescendoDLL.PCSC.BerTLVBuffer.BerTLVBuffer ( byte?[]  data,
string  berTLVTag 
)
inline

Constructs a BER-TLV buffer from raw card response data.

Parameters
dataRaw BER-TLV formatted byte array (null creates empty buffer)
berTLVTagMain tag identifying the PIV data object

Parsing behavior:

  • Ignores GeneralTag occurrences during parsing
  • Stores nested tags in Content dictionary
  • Handles ASN.1 length encoding automatically

Member Function Documentation

◆ AddTag()

BerTLVBuffer CrescendoDLL.PCSC.BerTLVBuffer.AddTag ( string  tag,
byte?[]  data 
)
inline

Adds or updates a tag-value pair in the buffer.

Parameters
tag2-character hex tag identifier (e.g., "80")
dataTag value (null stores empty byte array)
Returns
Current instance for method chaining

Automatically replaces existing entries with same tag

◆ ConstructDataFieldFromBerTLVBuffer()

byte[] CrescendoDLL.PCSC.BerTLVBuffer.ConstructDataFieldFromBerTLVBuffer ( )
inline

Constructs complete PIV data field with tag list.

Returns
BER-TLV structure formatted as:

◆ RemoveTag()

BerTLVBuffer CrescendoDLL.PCSC.BerTLVBuffer.RemoveTag ( string  tag)
inline

Removes a tag-value pair from the buffer.

Parameters
tag2-character hex tag identifier
Returns
Current instance for method chaining

◆ ToByte()

byte[] CrescendoDLL.PCSC.BerTLVBuffer.ToByte ( )
inline

Serializes the buffer to BER-TLV formatted byte array.

Returns
Byte array containing:
  • GeneralTag (0x53/0x7E)
  • ASN.1 length encoding
  • Concatenated tag-length-value entries

Returns [GeneralTag, 0x00] for empty buffers

Member Data Documentation

◆ Content

Dictionary<string, byte[]> CrescendoDLL.PCSC.BerTLVBuffer.Content = new()

Dictionary of TLV components (Tag-Length-Value entries)

Key: 2-character hex string tag (e.g., "80") Value: Byte array containing tag's value

◆ IsEmpty

bool CrescendoDLL.PCSC.BerTLVBuffer.IsEmpty = true

Indicates if the buffer contains no valid TLV data.

Property Documentation

◆ BERTLVTag

string CrescendoDLL.PCSC.BerTLVBuffer.BERTLVTag = default!
getset

Main BER-TLV tag identifier for the data object.

Hexadecimal string representation of the tag (e.g., "5FC107")

◆ GeneralTag

byte CrescendoDLL.PCSC.BerTLVBuffer.GeneralTag = 0x53
getset

General encapsulation tag (default: 0x53 for Discovery Object)

Defaults to 0x53 (Discovery Object Tag). May be 0x7E (Data Object Content Tag) for other PIV data objects.