Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a safe way to check if a key is valid. #40

Closed
lgarron opened this issue Jun 19, 2019 · 4 comments · Fixed by #50
Closed

Provide a safe way to check if a key is valid. #40

lgarron opened this issue Jun 19, 2019 · 4 comments · Fixed by #50

Comments

@lgarron
Copy link

lgarron commented Jun 19, 2019

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)
@grzuy
Copy link
Contributor

grzuy commented Jun 22, 2019

For future reference, related comment => #39 (comment).

@grzuy grzuy added the good first issue Good for newcomers label Jul 3, 2019
@grzuy grzuy removed the good first issue Good for newcomers label Aug 25, 2019
@grzuy
Copy link
Contributor

grzuy commented Oct 3, 2019

It feels like most of these would be responsibility of the CBOR decoder... I mean, most of the possible random exceptions you would get are coming from CBOR.decode.

Seems like the responsibility could lie on cbor to respond to the question if the cbor bytes are actually something that would decode without throwing...?

@grzuy
Copy link
Contributor

grzuy commented Oct 3, 2019

Staring discussion in cabo/cbor-ruby#14.

@grzuy
Copy link
Contributor

grzuy commented Dec 19, 2019

FWIW #50 released in v0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants