Documentation ¶
Index ¶
Constants ¶
const ( TypeEC = "EC" TypeRSA = "RSA" TypeOCT = "oct" )
JSON Web Key types defined in RFC7518, Section 6.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CryptoKey ¶
type CryptoKey interface{}
CryptoKey represents a cryptographic key using an unspecified algorithm.
type ECDSAPrivateKey ¶
type ECDSAPrivateKey struct { *ECDSAPublicKey D *base64url.Value `json:"d"` // contains filtered or unexported fields }
ECDSAPrivateKey represents an ECDSA private key, which contains algorithm-specific parameters defined in RFC 7518, Section 6.2.2.
ECDSAPrivate implements the Key interface.
func NewECDSAPrivateKey ¶
func NewECDSAPrivateKey(priv *ecdsa.PrivateKey, params *Params) (*ECDSAPrivateKey, error)
NewECDSAPrivateKey creates a new ECDSAPrivate.
func ParseECDSAPrivateKey ¶
func ParseECDSAPrivateKey(jwk []byte) (*ECDSAPrivateKey, error)
ParseECDSAPrivateKey parses the JSON Web Key as an ECDSA private key.
func (*ECDSAPrivateKey) CryptoKey ¶
func (key *ECDSAPrivateKey) CryptoKey() CryptoKey
CryptoKey returns the underlying cryptographic key.
type ECDSAPublicKey ¶
type ECDSAPublicKey struct { *Params CRV string `json:"crv"` X *base64url.Value `json:"x"` Y *base64url.Value `json:"y"` // contains filtered or unexported fields }
ECDSAPublicKey represents an ECDSA public key, which contains algorithm-specific parameters defined in RFC7518, Section 6.2.1.
ECDSAPublicKey implements the Key interface.
func NewECDSAPublicKey ¶
func NewECDSAPublicKey(pub *ecdsa.PublicKey, params *Params) (*ECDSAPublicKey, error)
NewECDSAPublicKey creates a new ECDSAPublicKey.
func ParseECDSAPublicKey ¶
func ParseECDSAPublicKey(jwk []byte) (*ECDSAPublicKey, error)
ParseECDSAPublicKey parses the JSON Web Key as an ECDSA public key.
func (*ECDSAPublicKey) CryptoKey ¶
func (key *ECDSAPublicKey) CryptoKey() CryptoKey
CryptoKey returns the underlying cryptographic key.
type OctetSequenceKey ¶
OctetSequenceKey represents an octet sequence key, which contains algorithm-specific parameters defined in RFC7518, Section 6.4.
OctetSequenceKey implements the Key interface.
func NewOctetSequenceKey ¶
func NewOctetSequenceKey(key []byte, params *Params) (*OctetSequenceKey, error)
NewOctetSequenceKey creates a new OctetSequenceKey.
func ParseOctetSequenceKey ¶
func ParseOctetSequenceKey(jwk []byte) (*OctetSequenceKey, error)
Parse parses the JSON Web Key as an octet sequence key.
func (*OctetSequenceKey) CryptoKey ¶
func (key *OctetSequenceKey) CryptoKey() CryptoKey
CryptoKey returns the underlying cryptographic key.
type Params ¶
type Params struct { KeyType string `json:"kty"` KeyUse string `json:"use,omitempty"` KeyOps []string `json:"key_ops,omitempty"` Algorithm string `json:"alg,omitempty"` KeyID string `json:"kid,omitempty"` }
Params contains common JSON Web Key parameters.
type RSAPrivateKey ¶
type RSAPrivateKey struct { *RSAPublicKey D *base64url.Value `json:"d"` P *base64url.Value `json:"p"` Q *base64url.Value `json:"q"` DP *base64url.Value `json:"dp,omitempty"` DQ *base64url.Value `json:"dq,omitempty"` QI *base64url.Value `json:"qi,omitempty"` OTH *json.RawMessage `json:"oth,omitempty"` // multi-prime key not supported // contains filtered or unexported fields }
RSAPrivateKey represents an RSA private key, which contains algorithm-specific parameters defined in RFC7518, Section 6.3.2.
RSAPrivate implements the Key interface.
func NewRSAPrivateKey ¶
func NewRSAPrivateKey(priv *rsa.PrivateKey, params *Params) (*RSAPrivateKey, error)
NewRSAPrivateKey creates a new RSAPrivate.
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(jwk []byte) (*RSAPrivateKey, error)
ParseRSAPrivateKey parses the JSON Web Key as an RSA private key.
func (*RSAPrivateKey) CryptoKey ¶
func (key *RSAPrivateKey) CryptoKey() CryptoKey
CryptoKey returns the underlying cryptographic key.
type RSAPublicKey ¶
type RSAPublicKey struct { *Params N *base64url.Value `json:"n"` E *base64url.Value `json:"e"` // contains filtered or unexported fields }
RSAPublicKey represents an RSA public key, which contains algorithm-specific parameters defined in RFC7518, Section 6.3.1.
RSAPublicKey implements the Key interface.
func NewRSAPublicKey ¶
func NewRSAPublicKey(pub *rsa.PublicKey, params *Params) (*RSAPublicKey, error)
NewRSAPublicKey creates a new RSAPublicKey.
func ParseRSAPublicKey ¶
func ParseRSAPublicKey(jwk []byte) (*RSAPublicKey, error)
ParseRSAPublicKey parses the JSON Web Key as an RSA public key.
func (*RSAPublicKey) CryptoKey ¶
func (key *RSAPublicKey) CryptoKey() CryptoKey
CryptoKey returns the underlying cryptographic key.