brainpool

package module
v0.0.0-...-f0988b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: EUPL-1.2 Imports: 25 Imported by: 4

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

View Source
const (
	AlgorithmNameES256   = "ES256"
	AlgorithmNameES384   = "ES384"
	AlgorithmNameES512   = "ES512"
	AlgorithmNameBP256R1 = "BP256R1"
	AlgorithmNameBP384R1 = "BP384R1"
	AlgorithmNameBP512R1 = "BP512R1"
)

Variables

View Source
var OIDNamedCurveP256r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 7}
View Source
var OIDNamedCurveP384r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 11}
View Source
var OIDNamedCurveP512r1 = asn1.ObjectIdentifier{1, 3, 36, 3, 3, 2, 8, 1, 1, 13}

Functions

func AlgorithmForCurve

func AlgorithmForCurve(curve elliptic.Curve) (string, error)

func CurveForJWA

func CurveForJWA(name string) (elliptic.Curve, error)

func CurveFromOID

func CurveFromOID(oid asn1.ObjectIdentifier) (bool, elliptic.Curve)

func DeriveECDHES

func DeriveECDHES(algorithm string, apuData, apvData []byte, privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, keySize int) ([]byte, error)

func HashFunctionForCurve

func HashFunctionForCurve(curve elliptic.Curve) (hash.Hash, error)

func JWAForCurve

func JWAForCurve(curve elliptic.Curve) string

func P256r1

func P256r1() elliptic.Curve

P256r1 returns a Curve which implements Brainpool P256r1 (see RFC 5639, section 3.4)

func P256t1

func P256t1() elliptic.Curve

P256t1 returns a Curve which implements Brainpool P256t1 (see RFC 5639, section 3.4)

func P384r1

func P384r1() elliptic.Curve

P384r1 returns a Curve which implements Brainpool P384r1 (see RFC 5639, section 3.6)

func P384t1

func P384t1() elliptic.Curve

P384t1 returns a Curve which implements Brainpool P384t1 (see RFC 5639, section 3.6)

func P512r1

func P512r1() elliptic.Curve

P512r1 returns a Curve which implements Brainpool P512r1 (see RFC 5639, section 3.7)

func P512t1

func P512t1() elliptic.Curve

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 ParsePKCS8PrivateKey(der []byte) (any, error)

func ParsePrivateKeyPEM

func ParsePrivateKeyPEM(pemBytes []byte) (*ecdsa.PrivateKey, error)

Types

type Claims

type Claims map[string]interface{}

type Headers

type Headers map[string]interface{}

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

func (*JWTBuilder) Sign

func (b *JWTBuilder) Sign(hashFunc hash.Hash, signFunc SignFunc) ([]byte, error)

type SignFunc

type SignFunc func(hash []byte) ([]byte, error)

func SignFuncPrivateKey

func SignFuncPrivateKey(sigPrK *ecdsa.PrivateKey) SignFunc

type VerifierErrorUnsupportedSignatureAlgorithm

type VerifierErrorUnsupportedSignatureAlgorithm error

type VerifierFunc

type VerifierFunc func(token *JWT) error

func WithEcdsaPublicKey

func WithEcdsaPublicKey(pubKey *ecdsa.PublicKey) VerifierFunc

func WithKey

func WithKey(key *JSONWebKey) VerifierFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL