GetDataResponse Class
Namespace: Yubico.YubiKey.Piv.Commands Assembly: Yubico.YubiKey.dllThe response to the get data command, containing the information requested.
public sealed class GetDataResponse : PivResponse, IYubiKeyResponseWithData<ReadOnlyMemory<byte>>, IYubiKeyResponse
Remarks
This is the partner Response class to GetDataCommand.
The data returned is a byte array presented as a ReadOnlyMemory
.
It is the raw data returned by the YubiKey.
It is possible that the data requested is not on the YubiKey. For
example, suppose you request the certificate in slot 9A, but there is no
certificate in that slot yet. The YubiKey will return the Status Word
6A82
(SWConstants.FileOrApplicationNotFound
) and no data. In
that case, Status
will be NoData
and the GetData
method will throw an exception (there is no data).
It is possible the YubiKey could not return the requested data
because authentication was required (PIN or management key). If so, it
will return the Status Word 6982
(SWConstants.SecurityStatusNotSatisfied
) and no data. In that
case, Status
will be AuthenticationRequired
and the
GetData
method will throw an exception.
Your code can get the response object and check Status
and, if
Success
, call GetData
. If the Status
is anything
else, don't call GetData
.
Example:
IYubiKeyConnection connection = key.Connect(YubiKeyApplication.Piv);
GetDataCommand getDataCommand = new GetDataCommand(PivDataTag.Chuid);
GetDataResponse getDataResponse = connection.SendCommand(getDataCommand);
if (getDataResponse.Status != ResponseStatus.Success)
{
// Handle error
}
byte[] getChuid = getDataResponse.GetData();
Constructors
Name | Description |
---|---|
GetDataResponse(ResponseApdu) | Constructs a GetDataResponse based on a ResponseApdu received from the YubiKey. |
Properties
Name | Description |
---|---|
StatusCodeMap |
Methods
Name | Description |
---|---|
GetData() | Gets the data requested from the YubiKey response. |