-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[CBOR] Implement a proof of concept for ECDsa COSE key serialization #36002
Conversation
ffbcfb8
to
5f4923d
Compare
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborReaderTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborReaderTests.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborWriterTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
c61de60
to
3427744
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently my Approve (with feedback) from a couple days ago didn't post.
This box said something like "LGTM, but a few comments to make it more sample-friendly".
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
throw new FormatException("Unexpected number of elements in the CBOR cose key."); | ||
} | ||
|
||
// CTAP2 guarantees order of fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious to see if you were going to take advantage of this in the reader.
For a public method I'd expect the conformance mode check to be a runtime check => ArgumentException (not just an assert). For internal an assert would make sense, since the only callers should have either validated it themselves or were the ones who created the reader.
To make this Proof of Concept more sample-friendly, I'd switch the access modifier to internal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious to see if you were going to take advantage of this in the reader.
If you mean the field ordering guarantee, I think it's mostly effective in scenaria where you don't support optional fields. In the general case something like this might be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, to be clear, I approve of taking the dependency; it's part of the niceness of the conformance mode 😄.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I suppose my point is that even assuming CTAP2 conformance mode, you might still need to opt for something like the original approach if you needed to tolerate arbitrary fields (e.g. because of forward compatibility concerns).
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborWriterTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborReaderTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborReaderTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborWriterTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CoseKeyHelpers.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after fixing comments
Implements a proof-of-concept serializer for ECDsa COSE key serialization, as defined in https://www.w3.org/TR/webauthn/#sctn-encoded-credPubKey-examples.