Documentation
¶
Overview ¶
Package brainpool implements Brainpool elliptic curves. Implementation of rcurves is from github.com/ebfe/brainpool Note that these curves are implemented with naive, non-constant time operations and are likely not suitable for enviroments where timing attacks are a concern.
Index ¶
- Constants
- Variables
- func AlgorithmForCurve(curve elliptic.Curve) (string, error)
- func CurveForJWA(name string) (elliptic.Curve, error)
- func CurveFromOID(oid asn1.ObjectIdentifier) (bool, elliptic.Curve)
- func DeriveECDHES(algorithm string, apuData, apvData []byte, privateKey *ecdsa.PrivateKey, ...) ([]byte, error)
- func HashFunctionForCurve(curve elliptic.Curve) (hash.Hash, error)
- func JWAForCurve(curve elliptic.Curve) string
- func P256r1() elliptic.Curve
- func P256t1() elliptic.Curve
- func P384r1() elliptic.Curve
- func P384t1() elliptic.Curve
- func P512r1() elliptic.Curve
- func P512t1() elliptic.Curve
- func ParseCertificate(der []byte) (*x509.Certificate, error)
- func ParseCertificatePEM(pemBytes []byte) (*x509.Certificate, error)
- func ParseECPrivateKey(der []byte) (*ecdsa.PrivateKey, error)
- func ParsePKCS8PrivateKey(der []byte) (any, error)
- func ParsePrivateKeyPEM(pemBytes []byte) (*ecdsa.PrivateKey, error)
- type Claims
- type Headers
- type JSONWebKey
- type JWEBuilder
- type JWT
- type JWTBuilder
- type SignFunc
- type VerifierErrorUnsupportedSignatureAlgorithm
- type VerifierFunc
Constants ¶
const ( AlgorithmNameES256 = "ES256" AlgorithmNameES384 = "ES384" AlgorithmNameES512 = "ES512" AlgorithmNameBP256R1 = "BP256R1" AlgorithmNameBP384R1 = "BP384R1" AlgorithmNameBP512R1 = "BP512R1" )
Variables ¶
var OIDNamedCurveP256r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 7}
var OIDNamedCurveP384r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 11}
var OIDNamedCurveP512r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 13}
Functions ¶
func CurveFromOID ¶
func CurveFromOID(oid asn1.ObjectIdentifier) (bool, elliptic.Curve)
func DeriveECDHES ¶
func JWAForCurve ¶
func P256r1 ¶
P256r1 returns a Curve which implements Brainpool P256r1 (see RFC 5639, section 3.4)
func P256t1 ¶
P256t1 returns a Curve which implements Brainpool P256t1 (see RFC 5639, section 3.4)
func P384r1 ¶
P384r1 returns a Curve which implements Brainpool P384r1 (see RFC 5639, section 3.6)
func P384t1 ¶
P384t1 returns a Curve which implements Brainpool P384t1 (see RFC 5639, section 3.6)
func P512r1 ¶
P512r1 returns a Curve which implements Brainpool P512r1 (see RFC 5639, section 3.7)
func P512t1 ¶
P512t1 returns a Curve which implements Brainpool P512t1 (see RFC 5639, section 3.7)
func ParseCertificate ¶
func ParseCertificate(der []byte) (*x509.Certificate, error)
func ParseCertificatePEM ¶
func ParseCertificatePEM(pemBytes []byte) (*x509.Certificate, error)
func ParseECPrivateKey ¶
func ParseECPrivateKey(der []byte) (*ecdsa.PrivateKey, error)
func ParsePKCS8PrivateKey ¶
func ParsePrivateKeyPEM ¶
func ParsePrivateKeyPEM(pemBytes []byte) (*ecdsa.PrivateKey, error)
Types ¶
type JSONWebKey ¶
type JSONWebKey struct {
KeyType string `json:"kty"`
Use string `json:"use,omitempty"`
Algortihm string `json:"alg,omitempty"`
KeyID string `json:"kid,omitempty"`
Key interface{} `json:"-"`
CertificatesRaw [][]byte `json:"x5c,omitempty"`
Certificates []*x509.Certificate `json:"-"`
X string `json:"x"`
Y string `json:"y"`
D string `json:"d,omitempty"`
CurveName string `json:"crv"`
}
See https://datatracker.ietf.org/doc/html/rfc7517
func (*JSONWebKey) MarshalJSON ¶
func (jwk *JSONWebKey) MarshalJSON() ([]byte, error)
func (*JSONWebKey) UnmarshalJSON ¶
func (jwk *JSONWebKey) UnmarshalJSON(data []byte) error
type JWEBuilder ¶
type JWEBuilder struct {
// contains filtered or unexported fields
}
func NewJWEBuilder ¶
func NewJWEBuilder() *JWEBuilder
func (*JWEBuilder) EncryptECDHES ¶
func (b *JWEBuilder) EncryptECDHES(recipient interface{}) ([]byte, error)
func (*JWEBuilder) Header ¶
func (b *JWEBuilder) Header(key string, value interface{}) *JWEBuilder
func (*JWEBuilder) Plaintext ¶
func (b *JWEBuilder) Plaintext(plaintext []byte) *JWEBuilder
type JWT ¶
type JWT struct {
Raw []byte
HeadersJson []byte
PayloadJson []byte
Signature []byte
Headers Headers
Claims Claims
}
func ParseToken ¶
func ParseToken(rawToken []byte, verifiers ...VerifierFunc) (*JWT, error)
type JWTBuilder ¶
type JWTBuilder struct {
// contains filtered or unexported fields
}
func NewJWTBuilder ¶
func NewJWTBuilder() *JWTBuilder
func (*JWTBuilder) Claim ¶
func (b *JWTBuilder) Claim(key string, value interface{}) *JWTBuilder
func (*JWTBuilder) Header ¶
func (b *JWTBuilder) Header(key string, value interface{}) *JWTBuilder
type SignFunc ¶
func SignFuncPrivateKey ¶
func SignFuncPrivateKey(sigPrK *ecdsa.PrivateKey) SignFunc
type VerifierErrorUnsupportedSignatureAlgorithm ¶
type VerifierErrorUnsupportedSignatureAlgorithm error
type VerifierFunc ¶
func WithEcdsaPublicKey ¶
func WithEcdsaPublicKey(pubKey *ecdsa.PublicKey) VerifierFunc
func WithKey ¶
func WithKey(key *JSONWebKey) VerifierFunc