Class CoseUnsupportedPublicKey
A COSE public key whose algorithm this SDK cannot decode into a strongly typed key representation, preserved in its original encoded form.
public sealed class CoseUnsupportedPublicKey : CoseKey, ICborEncode
- Inheritance
-
objectCoseUnsupportedPublicKey
- Implements
- Inherited Members
Remarks
The SDK returns an instance of this class when a YubiKey reports a public key using an algorithm that its strongly typed COSE key decoder does not implement. Rather than failing, the SDK preserves the original encoding in EncodedKey along with the key type and algorithm the YubiKey reported, so callers that understand the representation can decode it themselves.
This typically arises with a credential created by an extension that introduces its own key type, or with an algorithm registered after this version of the SDK was released.
Type and Algorithm preserve the values from the encoding. Either value may still be a named member of CoseKeyType or CoseAlgorithmIdentifier; do not assume that both values are unrecognized merely because the full algorithm is not implemented by the typed decoder. Check whether a decoded key is an instance of this class rather than inferring support from whether the reported enum values are named.
This class has no public constructor. Instances are produced by the SDK while decoding a response from a YubiKey, and by CreateOrUnsupported(ReadOnlyMemory<byte>), which callers can use to decode an encoding they hold themselves — for example one their application persisted after an earlier registration.
EncodedKey is fixed at construction. The inherited Type and Algorithm properties are settable, but changing them does not alter EncodedKey or the result of Encode(), and will make the reported metadata disagree with the encoded key. Treat them as read-only.
Properties
EncodedKey
The original COSE encoding this key was decoded from, byte for byte.
public ReadOnlyMemory<byte> EncodedKey { get; }
Property Value
- ReadOnlyMemory<byte>
Remarks
When the key came from a YubiKey response this is exactly what the YubiKey returned. When it came from CreateOrUnsupported(ReadOnlyMemory<byte>) it is exactly the encoding the caller supplied, excluding any trailing data that followed the key in the caller's buffer.
Methods
Encode()
Return a new byte array containing the original COSE encoding of the key.
public override byte[] Encode()
Returns
- byte[]
The encoded key.
Remarks
Because the SDK does not implement this key's algorithm, it cannot re-encode the key from decoded components. This method returns a copy of EncodedKey, so the result is byte-for-byte identical to the encoding this key was decoded from.