Class CoseKey
A base class for all COSE key representations.
public abstract class CoseKey
- Inheritance
-
objectCoseKey
- Derived
Constructors
CoseKey()
Constructs a CoseKey instance.
protected CoseKey()
Fields
TagAlgorithm
The CBOR tag (key of key/value pair) for the COSE key algorithm.
protected const int TagAlgorithm = 3
Field Value
- int
TagKeyType
The CBOR tag (key of key/value pair) for the COSE key type.
protected const int TagKeyType = 1
Field Value
- int
Properties
Algorithm
The key's algorithm.
public CoseAlgorithmIdentifier Algorithm { get; set; }
Property Value
Type
The key's type (or family). E.g. "EC2" for elliptic curve with an X,Y point.
public CoseKeyType Type { get; set; }
Property Value
Methods
Create(ReadOnlyMemory<byte>, out int)
Creates the correct COSE key representation based on the CBOR data provided.
public static CoseKey Create(ReadOnlyMemory<byte> coseEncodedKey, out int bytesRead)
Parameters
coseEncodedKey
ReadOnlyMemory<byte>A valid COSE key representation.
bytesRead
intThe method will return the number of bytes read in this argument.
Returns
- CoseKey
A COSE key instance corresponding to the type described by the CBOR data.
Exceptions
- ArgumentNullException
The
coseEncodedKey
parameter was null.- Ctap2DataException
The CBOR reader is not in the correct position.
--- or ---The CoseAlgorithmIdentifier could not be determined from the data provided.
- NotSupportedException
The CoseAlgorithmIdentifier is not supported by this object representation.
Encode()
Return a new byte array that is the key data encoded following the FIDO2/CBOR standard.
public abstract byte[] Encode()
Returns
- byte[]
The encoded key.
Exceptions
- InvalidOperationException
The object contains no key data.