Table of Contents

Class UserEntity

Namespace
Yubico.YubiKey.Fido2
Assembly
Yubico.YubiKey.dll

A FIDO2 UserEntity, consisting of ID, display name, and name. This is used when the FIDO2 standard specifies a PublicKeyCredentialUserEntity.

public class UserEntity
Inheritance
object
UserEntity

Remarks

A relying party (RP) will specify the user ID (which might or might not be human-readable), which can be an account number. Either the platform or the RP can specify a display name, the name of the account holder, and a name, which is an account name (different accounts might have the same display name). The display name and name are human-readable and can be displayed to the user.

This class holds the RP ID, display name, and name, and can encode and decode them as part of CBOR structures.

The FIDO2 standard specifies that when communicating with the authenticator, the ID is not a required element, although it will likely lead to interoperability issues if no value is given. This class will require an ID.

The W3C standard declares the display name and name required elements, but the FIDO2 standard declares them optional. Because the FIDO2 standard specifically prescribes authenticator functionality, this class will allow null display name and name.

Constructors

UserEntity(ReadOnlyMemory<byte>)

Constructs a new instance of UserEntity.

public UserEntity(ReadOnlyMemory<byte> id)

Parameters

id ReadOnlyMemory<byte>

The user's account ID. This constructor will copy a reference to the input id.

UserEntity(ReadOnlyMemory<byte>, out int)

Constructs a new instance of UserEntity from the encodedUserEntity.

public UserEntity(ReadOnlyMemory<byte> encodedUserEntity, out int bytesRead)

Parameters

encodedUserEntity ReadOnlyMemory<byte>

The CBOR encoding of the user information.

bytesRead int

The constructor will return the number of bytes read.

Remarks

This constructor expects the encoding to follow this CBOR template.

map {
  "id"          --byte string--
  "name"        --text string-- (optional)
  "displayName" --text string-- (optional)
}

Exceptions

Ctap2DataException

The encodedUserEntity is not a correct encoding.

Properties

DisplayName

The displayName component of the UserEntity.

public string? DisplayName { get; set; }

Property Value

string

Id

The id component of the UserEntity.

public ReadOnlyMemory<byte> Id { get; set; }

Property Value

ReadOnlyMemory<byte>

Name

The name component of the UserEntity.

public string? Name { get; set; }

Property Value

string

Remarks

The standard specifies that this element of a user entity is optional. However, YubiKeys prior to version 5.3.0 require a Name in order to make a credential.

Methods

CborEncode()

Return a new byte array that is the object encoded following the FIDO2/CBOR standard.

public byte[] CborEncode()

Returns

byte[]

The encoded construct.

Exceptions

InvalidOperationException

The object contains no data.