2using System.Collections.Generic;
14 private bool _useSingleByteOffset;
22 [Obsolete(
"Single byte offset no longer supported with future versions of OSDP")]
31 _ =>
throw new ArgumentOutOfRangeException()
37 _useSingleByteOffset =
true;
46 public GetPIVData(
byte[] objectId,
byte elementId, ushort dataOffset)
48 if (objectId.Length != 3)
50 throw new ArgumentException(
"Object ID byte length must be 3", nameof(objectId));
78 if (data.Length < 5 || data.Length > 6)
80 throw new ArgumentException(
"Invalid data length, must either be 5 or 6 bytes", nameof(data));
83 var isSingleByteOffset = data.Length == 5;
84 ushort offset = isSingleByteOffset ? data[4] :
85 Message.ConvertBytesToUnsignedShort(data.Slice(4, 2));
87 return new GetPIVData(data.Slice(0, 3).ToArray(), data[3], offset)
89 _useSingleByteOffset = isSingleByteOffset
105 var data =
new List<byte>();
112 return data.ToArray();
118 var sb =
new StringBuilder();
119 sb.AppendLine($
" Object ID: {BitConverter.ToString(ObjectId)}");
120 sb.AppendLine($
" Element ID: {ElementId}");
121 sb.AppendLine($
"Data Offset: {DataOffset}");
122 return sb.ToString();
A base message class for sending or replying.
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload of a PD command message.
ushort DataOffset
Gets the data offset.
static GetPIVData ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
GetPIVData(ObjectId objectId, byte elementId, byte dataOffset)
Initializes a new instance of the GetPIVData class.
byte ElementId
Gets the element identifier.
GetPIVData(byte[] objectId, byte elementId, ushort dataOffset)
Initializes a new instance of the GetPIVData class.
byte[] ObjectId
Gets the object identifier.
override string ToString()
override byte[] BuildData()
override ReadOnlySpan< byte > SecurityControlBlock()
override CommandType CommandType
@ CertificateForPIVAuthentication
The certificate for piv authentication.
@ CertificateForCardAuthentication
The certificate for card authentication.
@ CardholderUniqueIdentifier
The cardholder unique identifier.
@ CardholderFingerprintTemplate
The cardholder fingerprint template.