Class Credential
- Namespace
- Yubico.YubiKey.YubiHsmAuth
- Assembly
- Yubico.YubiKey.dll
The public properties of a long-lived secret stored in the YubiHSM Auth application. The associated secret is used to establish a secure session to a YubiHSM 2 device.
public class Credential
- Inheritance
-
objectCredential
- Derived
Constructors
Credential()
Constructs an instance of the Credential class.
public Credential()
Remarks
This constructor is provided to allow for object-initializer syntax. The default values are not guaranteed to be valid, so all properties should be set manually.
Credential(CryptographicKeyType, string, bool)
Constructs an instance of the Credential class with the provided arguments.
public Credential(CryptographicKeyType keyType, string label, bool touchRequired)
Parameters
keyType
CryptographicKeyTypeThe cryptographic algorithm associated with the Credential. The value is not allowed to be None. label
stringA short name or description of the Credential. The string only contains characters that can be encoded with UTF-8, and its UTF-8 byte count is between MinLabelByteCount and MaxLabelByteCount. Non-printing characters are allowed, as long as they can be encoded with UTF-8. For example, null (UTF-8: 0x00) and Right-To-Left Mark U+200F (UTF-8: 0xE2 0x80 0x8F) would be acceptable.
The System.Text.UTF8Encoding class contains methods such as System.Text.UTF8Encoding.GetByteCount(string) which can be used to validate the string prior to attempting to set it here. It is recommended to use the constructor System.Text.UTF8Encoding.UTF8Encoding(bool, bool) so error detection is enabled for invalid characters.
touchRequired
boolDescribes if the user is required to touch the YubiKey when accessing the Credential.
Exceptions
- ArgumentException
Thrown when
label
has an invalid length.- ArgumentOutOfRangeException
Thrown when
keyType
is an invalid value.
Fields
MaxLabelByteCount
Maximum length of the Label.
public const int MaxLabelByteCount = 64
Field Value
- int
MinLabelByteCount
Minimum length of the Label.
public const int MinLabelByteCount = 1
Field Value
- int
Properties
KeyType
The cryptographic algorithm associated with the Credential.
public CryptographicKeyType KeyType { get; set; }
Property Value
Remarks
The value is not allowed to be None.
Exceptions
- ArgumentOutOfRangeException
Thrown when the value is not defined in CryptographicKeyType, or if there was an attempt to set it to None.
Label
A short name or description of the Credential.
public string Label { get; set; }
Property Value
- string
Remarks
The string only contains characters that can be encoded with UTF-8, and its UTF-8 byte count is between MinLabelByteCount and MaxLabelByteCount. Non-printing characters are allowed, as long as they can be encoded with UTF-8. For example, null (UTF-8: 0x00) and Right-To-Left Mark U+200F (UTF-8: 0xE2 0x80 0x8F) would be acceptable.
The System.Text.UTF8Encoding class contains methods such as System.Text.UTF8Encoding.GetByteCount(string) which can be used to validate the string prior to attempting to set it here. It is recommended to use the constructor System.Text.UTF8Encoding.UTF8Encoding(bool, bool) so error detection is enabled for invalid characters.
Exceptions
- ArgumentNullException
Thrown when the supplied string is null.
- ArgumentOutOfRangeException
Thrown when the string's UTF-8 byte count does not meet the length parameters MinLabelByteCount and MaxLabelByteCount.
- ArgumentException
Thrown when there is a character that cannot be encoded with UTF-8. The exact exception may be derived from ArgumentException.
TouchRequired
Describes if the user is required to touch the YubiKey when accessing the Credential.
public bool TouchRequired { get; set; }
Property Value
- bool