Show / Hide Table of Contents

PutDataCommand Constructor

PutDataCommand()

Initializes a new instance of the PutDataCommand class.

C#
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.

C#
[Obsolete("This constructor is obsolete. Use PutDataCommand(int, ReadOnlyMemory<byte>) instead", false)]
public PutDataCommand(PivDataTag tag, ReadOnlyMemory<byte> encodedData)

Parameters

Type Name Description
PivDataTag tag

The tag indicating which data to put.

ReadOnlyMemory<byte> encodedData

The data to put, encoded as defined int the User's Manual entry for GET DATA .

Exceptions

Type Condition
ArgumentException

The encodedData is not as specified for the given tag.

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(int, ReadOnlyMemory<byte>)

Initializes a new instance of the PutDataCommand class.

C#
public PutDataCommand(int dataTag, ReadOnlyMemory<byte> data)

Parameters

Type Name Description
int dataTag

The DataTag indicating where the data will be stored.

ReadOnlyMemory<byte> data

The data to put, encoded as 53 length data.

Exceptions

Type Condition
ArgumentException

The DataTag specified is not a number between 0x005F0000 and 0x005FFFFF (inclusive), or 0x00007F61.

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();
In this article
Back to top Generated by DocFX