See cedarcode/webauthn-ruby#222 and #39
To check if a COSE key is valid, it seems we have to do:
begin
COSE::Key.deserialize(public_key_bytes)
rescue ArgumentError, EOFError, TypeError, COSE::UnknownKeyType, CBOR::UnpackError
# ...
end
This is not quite enough, because a NoMemoryError is also possible (#39). It would be nice to have a safe way to check whether an untrusted byte string is a valid key, e.g.:
- a method with a documented set of possible errors
- a boolean method, e.g.
COSE::Key.valid?(public_key_bytes)