mozilla-services / go-cose

go library for CBOR Object Signing and Encryption (COSE)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC8152 Section 7 COSE_Key public key serialization?

holycleugh opened this issue · comments

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?)

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.

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

image

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:

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