add optional "use":"sig" to public jwk

This commit is contained in:
AJ ONeal 2019-02-12 16:57:01 +00:00
parent a91624fb78
commit 34e2ec1a8e
1 changed files with 2 additions and 2 deletions

View File

@ -153,7 +153,7 @@ func MarshalECPublicKey(k *ecdsa.PublicKey, exp ...time.Time) []byte {
if 0 != len(exp) { if 0 != len(exp) {
expstr = fmt.Sprintf(`"exp":%d,`, exp[0].Unix()) expstr = fmt.Sprintf(`"exp":%d,`, exp[0].Unix())
} }
return []byte(fmt.Sprintf(`{"kid":%q,%s"crv":%q,"kty":"EC","x":%q,"y":%q}`, expstr, thumb, crv, x, y)) return []byte(fmt.Sprintf(`{"kid":%q,"use":"sig",%s"crv":%q,"kty":"EC","x":%q,"y":%q}`, expstr, thumb, crv, x, y))
} }
func MarshalECPublicKeyWithoutKeyID(k *ecdsa.PublicKey) []byte { func MarshalECPublicKeyWithoutKeyID(k *ecdsa.PublicKey) []byte {
@ -177,7 +177,7 @@ func MarshalRSAPublicKey(p *rsa.PublicKey, exp ...time.Time) []byte {
if 0 != len(exp) { if 0 != len(exp) {
expstr = fmt.Sprintf(`"exp":%d,`, exp[0].Unix()) expstr = fmt.Sprintf(`"exp":%d,`, exp[0].Unix())
} }
return []byte(fmt.Sprintf(`{"kid":%q,%s"e":%q,"kty":"RSA","n":%q}`, expstr, thumb, e, n)) return []byte(fmt.Sprintf(`{"kid":%q,"use":"sig",%s"e":%q,"kty":"RSA","n":%q}`, expstr, thumb, e, n))
} }
func MarshalRSAPublicKeyWithoutKeyID(p *rsa.PublicKey) []byte { func MarshalRSAPublicKeyWithoutKeyID(p *rsa.PublicKey) []byte {