PutDataCommand Constructor
PutDataCommand()
Initializes a new instance of the PutDataCommand
class.
public PutDataCommand()
Remarks
This constructor is provided for those developers who want to use the object initializer pattern. For example:
var command = new PutDataCommand()
{
DataTag = (int)PivDataTag.Authentication;
Data = GetEncodedCertificate();
};
There is no default Tag or EncodedData, hence, for this command to be valid, the Tag and EncodedData must be specified. So if you create an object using this constructor, you must set the Tag and EncodedData properties at some time before using it. Otherwise you will get an exception when you do use it.
PutDataCommand(PivDataTag, ReadOnlyMemory<Byte>)
Warning
This constructor is obsolete, use PutDataCommand()
or
PutDataCommand(int, ReadOnlyMemory<byte>)
instead.
Initializes a new instance of the PutDataCommand
class. This
command takes in a tag indicating which data element to put, and the
encoded data to load onto the YubiKey.
public PutDataCommand(PivDataTag tag, ReadOnlyMemory<byte> encodedData)
Parameters
Type | Name | Description |
---|---|---|
PivDataTag | tag | The tag indicating which data to put. |
System.ReadOnlyMemory<System.Byte> | encodedData | The data to put, encoded as defined int the User's Manual entry for GET DATA . |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The encodedData is not as specified for the given |
Remarks
Note that this constructor requires using a PIV-defined DataTag and will verify that the data follows the PIV-specified format for the given DataTag. To use any DataTag (PIV-defined, Yubico-defined, or one of the allowed undefined values), and/or any encoded data, use one of the other constructors.
PutDataCommand(Int32, ReadOnlyMemory<Byte>)
Initializes a new instance of the PutDataCommand
class.
public PutDataCommand(int dataTag, ReadOnlyMemory<byte> data)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | dataTag | The DataTag indicating where the data will be stored. |
System.ReadOnlyMemory<System.Byte> | data | The data to put, encoded as |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The DataTag specified is not a number between |
Remarks
Note that this constructor requires using a DataTag that is a number
from 0x005F0000
to 0x005FFFFF
inclusive. The data can
be anything but it must be encoded as 53 length data
To encode, you can use the TlvWriter
class.
var tlvWriter = new TlvWriter();
tlvWriter.WriteValue(0x53, dataToStore);
byte[] encoding = tlvWriter.Encode();