Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class CoseKey

  1. Object
  2. CoseKey

A credential’s public key as an authenticator sends it – a COSE_Key, RFC 9052 – turned into what Crypto.verify takes: an algorithm name and a SubjectPublicKeyInfo.

Two kinds of key are read, the two every platform authenticator offers:

COSE algorithmKeyVerified as
-7, ES256EC2 on P-256, uncompressedCrypto.ES256
-257, RS256RSA of 2048 bits or moreCrypto.RS256

Any other algorithm is refused with WebAuthnException.UNSUPPORTED_ALGORITHM – EdDSA (-8) among them, which the server’s cryptography does not verify – and a key that names one of the two and is not such a key with WebAuthnException.INVALID_KEY. The registration options offer only these two, so a conforming authenticator answers with nothing else.

Fields

public static final long ES256 = -7LThe COSE identifier of ES256: ECDSA on P-256 with SHA-256.
public static final long RS256 = -257LThe COSE identifier of RS256: RSASSA-PKCS1-v1_5 with SHA-256.

Methods

public static CoseKey parse(byte[] coseKey)The key a COSE_Key encodes, as another relying party stored it: what a migration of passkeys reads.
public static CoseKey of(long algorithm, byte[] publicKey)The key read from stored bytes: what getPublicKey returned.
public long getAlgorithm()The COSE identifier of the key’s algorithm: ES256 or RS256.
public byte[] getPublicKey()The key as a SubjectPublicKeyInfo, in DER.
public boolean verify(byte[] data, byte[] signature)Whether signature is this key’s signature of data.

Inherited methods

Field details

ES256

public static final long ES256 = -7L
The COSE identifier of ES256: ECDSA on P-256 with SHA-256.

RS256

public static final long RS256 = -257L
The COSE identifier of RS256: RSASSA-PKCS1-v1_5 with SHA-256.

Method details

parse

public static CoseKey parse(byte[] coseKey)

The key a COSE_Key encodes, as another relying party stored it: what a migration of passkeys reads.

of

public static CoseKey of(long algorithm, byte[] publicKey)

The key read from stored bytes: what getPublicKey returned.

getAlgorithm

public long getAlgorithm()
The COSE identifier of the key’s algorithm: ES256 or RS256.

getPublicKey

public byte[] getPublicKey()
The key as a SubjectPublicKeyInfo, in DER.

verify

public boolean verify(byte[] data, byte[] signature)

Whether signature is this key’s signature of data. An ES256 signature is ASN.1 DER, as an authenticator sends it.