mozilla-services / go-cose

go library for CBOR Object Signing and Encryption (COSE)
Mozilla Public License 2.0
40 stars 18 forks source link

RFC8152 Section 7 COSE_Key public key serialization? #48

Closed holycleugh closed 2 years ago

holycleugh commented 5 years ago

Hi, I'm not sure if this is out of the scope for this library or it's implemented but I missed it in the docs.

I'm looking to serialize public keys in the COSE_Key format (https://tools.ietf.org/html/rfc8152#section-7), e.g., a ES256 public key would be serialized as the CBOR representation of {<kty>: 2, <alg>: -7, <crv>: ..., <x>: ..., <y>: ...}, with the specified integers replacing the keys.

Does this library support this? I noticed a general cose.Marshal function but this doesn't seem to encode it in COSE_Key format, but rather the CBOR encoding of the go/crypto ecdsa.PublicKey struct. (And if not, would a PR that does support this be appropriate for this repo?)

g-k commented 5 years ago

Hi @holycleugh!

Does this library support this? And if not, would a PR that does support this be appropriate for this repo?

No it does not. PRs welcome!

This initial implementation is just for the limited functionality we needed to sign addons at Mozilla, but the goal is to support more of the spec.

x448 commented 4 years ago

Hi @g-k, can this be handled by the "keyasint" struct tag feature of fxamacker/cbor?

image

g-k commented 3 years ago

can this be handled by the "keyasint" struct tag feature of fxamacker/cbor?

Yes, that'd be great.

So we probably want separate PRs to:

hwine commented 2 years ago

We are no longer making changes to this repository. See README update for more information on the successor project.