Class RegisterCommand
Creates a U2F registration on the device.
public sealed class RegisterCommand : U2fBufferCommand, IYubiKeyCommand<RegisterResponse>
- Inheritance
-
objectRegisterCommand
- Implements
- Inherited Members
Remarks
The partner Response class is RegisterResponse.
This command will generally initially return a ConditionsNotSatisfied and will not return success until the user confirms presence by touching the device. Clients should repeatedly send the command as long as they receive this status.
Example:
IYubiKeyConnection connection = key.Connect(YubiKeyApplication.FidoU2f);
byte[] challenge = new byte[32];
RandomNumberGenerator.Fill(challenge);
byte[] appId = new byte[32];
RandomNumberGenerator.Fill(appId);
RegisterCommand registerCommand = new RegisterCommand(challenge, appId);
RegisterResponse registerResponse;
do
{
registerResponse = fidoConnection.SendCommand(registerCommand);
} while (registerResponse.Status == ResponseStatus.ConditionsNotSatisfied);
RegistrationData data = registerResponse.GetData();
Constructors
RegisterCommand()
Creates an instance of the command.
public RegisterCommand()
Remarks
This constructor is provided for those developers who want to use the object initializer pattern.
Set the ApplicationId
and ClientDataHash
properties
before sending the command to the YubiKey.
RegisterCommand(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>)
Creates an instance of the command with the given client data hash and app ID.
public RegisterCommand(ReadOnlyMemory<byte> applicationId, ReadOnlyMemory<byte> clientDataHash)
Parameters
applicationId
ReadOnlyMemory<byte>The SHA256 hash of the Relying Party ID. Must be 32 bytes long. This is the hash of the origin data.
clientDataHash
ReadOnlyMemory<byte>The
clientDataHash
or "challenge" in the CTAP2 and U2F specifications. Must be 32 bytes long.
Remarks
The app ID is specifically the SHA256 hash of the site origin's 'effective domain'. For example, it is the SHA256 hash of "acme.org" if the origin is 'https://acme.org:8443'.
Methods
CreateResponseForApdu(ResponseApdu)
Creates the corresponding IYubiKeyResponse implementation for the current command.
public RegisterResponse CreateResponseForApdu(ResponseApdu responseApdu)
Parameters
responseApdu
ResponseApduThe ResponseApdu returned by the YubiKey.
Returns
- RegisterResponse
The implementation of IYubiKeyResponse that parses and presents ths response APDU.