Class CoseKey
java.lang.Object
com.iizix.server.user.passkey.CoseKey
The public key of a passkey in its COSE form (RFC 9052, RFC 9053), as the authenticator sends it in the attested credential data and as the server stores it (CC-LOGIN-L8-PASSKEYS): decoded, checked, and turned into a key of the Java platform that verifies the signatures of the authenticator. No library: the platform's own
Signature, KeyFactory and curves.The key is a peer's data. Its type, curve and algorithm must agree with each other as WebAuthn requires (ES256 is P-256, EdDSA is Ed25519), an elliptic curve point must be on its curve, an RSA modulus must have MIN_RSA_BITS bits at least, and a key that carries a private part is refused.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe COSE algorithm of the key.static final intCOSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.static final intCOSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.static final intCOSE algorithm: EdDSA, for WebAuthn on Ed25519.static final intCOSE algorithm: ECDSA with SHA-256 on P-256.static final intCOSE algorithm: ECDSA with SHA-384 on P-384.static final intCOSE algorithm: ECDSA with SHA-512 on P-521.static final intCOSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.static final intCOSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.static final intCOSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.static final intThe least size of an RSA modulus that is accepted, in bits.static final intCOSE algorithm: RSASSA-PKCS1-v1_5 with SHA-256.Method Summary
Field Details
ES256
public static final int ES256COSE algorithm: ECDSA with SHA-256 on P-256.- See Also:
EDDSA
public static final int EDDSACOSE algorithm: EdDSA, for WebAuthn on Ed25519.- See Also:
ES384
public static final int ES384COSE algorithm: ECDSA with SHA-384 on P-384.- See Also:
ES512
public static final int ES512COSE algorithm: ECDSA with SHA-512 on P-521.- See Also:
RS256
public static final int RS256COSE algorithm: RSASSA-PKCS1-v1_5 with SHA-256.- See Also:
ESP256
public static final int ESP256COSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.- See Also:
ED25519
public static final int ED25519COSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.- See Also:
ESP384
public static final int ESP384COSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.- See Also:
ESP512
public static final int ESP512COSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.- See Also:
ED448
public static final int ED448COSE algorithms of RFC 9864, which name the curve: ESP256, Ed25519, ESP384, ESP512, Ed448.- See Also:
MIN_RSA_BITS
public static final int MIN_RSA_BITSThe least size of an RSA modulus that is accepted, in bits.- See Also:
algorithm
public final int algorithmThe COSE algorithm of the key.
Method Details
decode
Decodes a key from the bytes of its COSE form.- Parameters:
cose- The COSE form: exactly one CBOR map.- Returns:
- The key.
- Throws:
NullPointerException- Ifcoseis null.PasskeyException- If the bytes are no COSE key of a kind that is supported, or the key is not a sound one.
verify
public boolean verify(byte[] signed, byte[] signature) Verifies a signature of the authenticator.- Parameters:
signed- The data that was signed.signature- The signature: ASN.1 DER for ECDSA, as WebAuthn defines it.- Returns:
- true when the signature is the key's signature of the data; false when it is not, and when it is not a signature at all.
- Throws:
NullPointerException- If a parameter is null.
getEncoded
public byte[] getEncoded()Gets the bytes of the COSE form.- Returns:
- A copy of the bytes.
getPublicKey