Documentation ¶
Index ¶
- Constants
- Variables
- func CheckSignature(cert *Certificate, signed []byte, signature []byte) error
- func InitNodeStakingKeyPair(keyPath, certPath string) error
- func LoadTLSCertFromBytes(keyBytes, certBytes []byte) (*tls.Certificate, error)
- func LoadTLSCertFromFiles(keyPath, certPath string) (*tls.Certificate, error)
- func NewCertAndKeyBytes() ([]byte, []byte, error)
- func NewTLSCert() (*tls.Certificate, error)
- type Certificate
Constants ¶
const MaxRSAKeyBitLen = 8192
MaxRSAKeyBitLen is the maximum RSA key size in bits that we are willing to parse.
https://github.com/golang/go/blob/go1.19.12/src/crypto/tls/handshake_client.go#L860-L862
Variables ¶
var ( ErrMalformedCertificate = errors.New("staking: malformed certificate") ErrTrailingData = errors.New("staking: trailing data") ErrMalformedTBSCertificate = errors.New("staking: malformed tbs certificate") ErrMalformedVersion = errors.New("staking: malformed version") ErrMalformedSerialNumber = errors.New("staking: malformed serial number") ErrMalformedSignatureAlgorithmIdentifier = errors.New("staking: malformed signature algorithm identifier") ErrMalformedIssuer = errors.New("staking: malformed issuer") ErrMalformedValidity = errors.New("staking: malformed validity") ErrMalformedSPKI = errors.New("staking: malformed spki") ErrMalformedPublicKeyAlgorithmIdentifier = errors.New("staking: malformed public key algorithm identifier") ErrMalformedSubjectPublicKey = errors.New("staking: malformed subject public key") ErrMalformedOID = errors.New("staking: malformed oid") ErrMalformedParameters = errors.New("staking: malformed parameters") ErrRSAKeyMissingNULLParameters = errors.New("staking: RSA key missing NULL parameters") ErrInvalidRSAPublicKey = errors.New("staking: invalid RSA public key") ErrInvalidRSAModulus = errors.New("staking: invalid RSA modulus") ErrInvalidRSAPublicExponent = errors.New("staking: invalid RSA public exponent") ErrRSAModulusNotPositive = errors.New("staking: RSA modulus is not a positive number") ErrInvalidRSAModulusBitLen = fmt.Errorf("staking: RSA modulus bitLen is greater than %d", MaxRSAKeyBitLen) ErrRSAPublicExponentNotPositive = errors.New("staking: RSA public exponent is not a positive number") ErrInvalidECDSAParameters = errors.New("staking: invalid ECDSA parameters") ErrUnsupportedEllipticCurve = errors.New("staking: unsupported elliptic curve") ErrFailedUnmarshallingEllipticCurvePoint = errors.New("staking: failed to unmarshal elliptic curve point") ErrUnexpectedED25519Parameters = errors.New("staking: Ed25519 key encoded with illegal parameters") ErrWrongED25519PublicKeySize = errors.New("staking: wrong Ed25519 public key size") ErrUnknownPublicKeyAlgorithm = errors.New("staking: unknown public key algorithm") )
var ( ErrUnsupportedAlgorithm = errors.New("staking: cannot verify signature: unsupported algorithm") ErrPublicKeyAlgoMismatch = errors.New("staking: signature algorithm specified different public key type") ErrECDSAVerificationFailure = errors.New("staking: ECDSA verification failure") ErrED25519VerificationFailure = errors.New("staking: Ed25519 verification failure") )
Functions ¶
func CheckSignature ¶ added in v1.10.6
func CheckSignature(cert *Certificate, signed []byte, signature []byte) error
CheckSignature verifies that the signature is a valid signature over signed from the certificate.
Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L793-L797 Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L816-L879
func InitNodeStakingKeyPair ¶ added in v1.4.5
InitNodeStakingKeyPair generates a self-signed TLS key/cert pair to use in staking. The key and files will be placed at [keyPath] and [certPath], respectively. If there is already a file at [keyPath], returns nil.
func LoadTLSCertFromBytes ¶ added in v1.7.2
func LoadTLSCertFromBytes(keyBytes, certBytes []byte) (*tls.Certificate, error)
func LoadTLSCertFromFiles ¶ added in v1.7.2
func LoadTLSCertFromFiles(keyPath, certPath string) (*tls.Certificate, error)
func NewCertAndKeyBytes ¶ added in v1.5.3
Creates a new staking private key / staking certificate pair. Returns the PEM byte representations of both.
func NewTLSCert ¶ added in v1.4.0
func NewTLSCert() (*tls.Certificate, error)
Types ¶
type Certificate ¶ added in v1.10.9
type Certificate struct { Raw []byte PublicKey any SignatureAlgorithm x509.SignatureAlgorithm }
func CertificateFromX509 ¶ added in v1.10.9
func CertificateFromX509(cert *x509.Certificate) *Certificate
CertificateFromX509 converts an x509 certificate into a staking certificate.
Invariant: The provided certificate must be a parseable into a staking certificate.
func ParseCertificate ¶ added in v1.10.9
func ParseCertificate(der []byte) (*Certificate, error)
ParseCertificate parses a single certificate from the given ASN.1 DER data.
Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/parser.go#L789-L968