Table of Contents

Class GetSerialNumberResponse

Namespace
Yubico.YubiKey.Piv.Commands
Assembly
Yubico.YubiKey.dll

The response to the get serial number command, containing the YubiKey's serial number.

public sealed class GetSerialNumberResponse : PivResponse, IYubiKeyResponseWithData<int>, IYubiKeyResponse
Inheritance
object
GetSerialNumberResponse
Implements
Inherited Members

Remarks

This is the partner Response class to GetSerialNumberCommand.

The data returned is an int.

Example:

IYubiKeyConnection connection = key.Connect(YubiKeyApplication.Piv);
SerialCommand serialCommand = new GetSerialNumberCommand();
GetSerialNumberResponse serialResponse = connection.SendCommand(serialCommand);
if (serialResponse.Status == ResponseStatus.Success)
{
  int serialNum = serialResponse.GetData();
}

Constructors

GetSerialNumberResponse(ResponseApdu)

Constructs a GetSerialNumberResponse based on a ResponseApdu received from the YubiKey.

public GetSerialNumberResponse(ResponseApdu responseApdu)

Parameters

responseApdu ResponseApdu

The object containing the response APDU
returned by the YubiKey.

Methods

GetData()

Gets the serial number from the YubiKey response.

public int GetData()

Returns

int

The data in the response APDU, presented as an int.

Exceptions

InvalidOperationException

Thrown if Status is not equal to Success.

MalformedYubiKeyResponseException

Thrown when the ResponseApdu.Data does not meet the expectations of the parser.