Documentation ¶
Index ¶
- Variables
- func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
- func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error)
- func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func RegisterSigningMethod(alg string, f func() SigningMethod)
- type Certificate
- type SigningMethod
- type SigningMethodECDSA
- type SigningMethodRSA
- type SigningMethodRSAPSS
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotPublicKey = errors.New("key is not a valid ECDSA public key") ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key") )
var ( ErrInvalidKey = errors.New("key is invalid") ErrInvalidKeyType = errors.New("key is of invalid type") )
var ( ErrKeyMustBePEMEncoded = errors.New("invalid key: must be a PEM encode PKCS1 or PKCS8 key") ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") )
var ( // Sadly this is missing from crypto/ecdsa compared to crypto/rsa ErrECDSAVerification = errors.New("crypto/ecdsa: verification error") )
Functions ¶
func ParseECPrivateKeyFromPEM ¶
func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
ParseECPrivateKeyFromPEM parse PEM encoded Elliptic Curve Key Structure
func ParseRSAPrivateKeyFromPEM ¶
func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
ParseRSAPrivateKeyFromPEM parse PEM encoded PKCS1 or PKCS8 private key
func ParseRSAPrivateKeyFromPEMWithPassword ¶
func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
ParseRSAPrivateKeyFromPEMWithPassword Parse PEM encoded PKCS1 or PKCS8 private key protected with password
func ParseRSAPublicKeyFromPEM ¶
ParseRSAPublicKeyFromPEM Parse PEM encoded PKCS1 or PKCS8 public key
func RegisterSigningMethod ¶
func RegisterSigningMethod(alg string, f func() SigningMethod)
Types ¶
type Certificate ¶
type Certificate struct { *x509.Certificate // contains filtered or unexported fields }
func ParseCertificate ¶
func ParseCertificate(certificate string) (*Certificate, error)
ParseCertificate parse raw data into x509.Certificate format
func (*Certificate) Algorithm ¶
func (c *Certificate) Algorithm() x509.PublicKeyAlgorithm
func (*Certificate) PEM ¶
func (c *Certificate) PEM() []byte
type SigningMethod ¶
type SigningMethod interface { Verify(signingString, signature string, key any) error Sign(signingString string, key any) (string, error) Alg() string }
Implement SigningMethod to add new methods for signing or verifying signed string
func GetSigningMethod ¶
func GetSigningMethod(alg string) (method SigningMethod)
type SigningMethodECDSA ¶
Implement the ECDSA family of signing methods SigningMethod Expects *ecdsa.PrivateKey for signing and *ecdsa.PublicKey for verification
var ( SigningMethodES256 *SigningMethodECDSA SigningMethodES384 *SigningMethodECDSA SigningmethodES512 *SigningMethodECDSA )
Specific instances for ES256 and company
func (*SigningMethodECDSA) Alg ¶
func (m *SigningMethodECDSA) Alg() string
type SigningMethodRSA ¶
var ( SigningMethodRS256 *SigningMethodRSA SigningMethodRS384 *SigningMethodRSA SigningMethodRS512 *SigningMethodRSA )
Specific instances for RSA256 and company
func (*SigningMethodRSA) Alg ¶
func (m *SigningMethodRSA) Alg() string
type SigningMethodRSAPSS ¶
type SigningMethodRSAPSS struct { *SigningMethodRSA Options *rsa.PSSOptions // VerifyOptions is optional, If set overrides Options for rsa.VerifyPPS. // Used to accept tokens signed with rsa.PSSSaltLengthAuto, what doesn't follow // https://tools.ietf.org/html/rfc7518#section-3.5 but was used previously. // See https://github.com/dgrijalva/jwt-go/issues/285#issuecomment-437451244 for details. VerifyOptions *rsa.PSSOptions }
var ( SigningMethodPS256 *SigningMethodRSAPSS SigningMethodPS384 *SigningMethodRSAPSS SigningMethodPS512 *SigningMethodRSAPSS )
Specific instances for RS/PS and company.
func (*SigningMethodRSAPSS) Alg ¶
func (m *SigningMethodRSAPSS) Alg() string