signctx

package
v2.0.328 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package signctx carries a context.Context to a signer or decrypter that can use one, for packages below cryptoprov in the import graph (certutil). cryptoprov.ContextSigner, ContextDecrypter, SignContext, DecryptContext and BindContext are the public form; an implementation satisfies both, since the interfaces have the same method sets.

signer = signctx.Bind(ctx, signer)
der, err := x509.CreateCertificate(rand.Reader, template, parent, pub, signer)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(ctx context.Context, signer crypto.Signer) crypto.Signer

Bind returns a crypto.Signer whose Sign is Sign(ctx, signer, ...), for an API that only calls Sign, such as x509.CreateCertificate: a Signer signs through SignContext with ctx, any other signer through Sign once ctx is checked. The bound signer has Public and Sign, and SignMessage when signer is a crypto.MessageSigner but not a Signer: SignMessage takes no context, so a Signer is bound without it and crypto.SignMessage signs through the bound Sign. It hides every other method and the concrete type of signer, so bind at the call and keep signer for type checks. It must not outlive ctx.

func Decrypt

func Decrypt(ctx context.Context, decrypter crypto.Decrypter, rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) ([]byte, error)

Decrypt decrypts ciphertext with decrypter under ctx: through DecryptContext when decrypter is a Decrypter, otherwise through Decrypt once ctx is checked.

func Sign

func Sign(ctx context.Context, signer crypto.Signer, rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)

Sign signs digest with signer under ctx: through SignContext when signer is a Signer, otherwise through Sign once ctx is checked, since a plain signer cannot be interrupted.

Types

type Decrypter

type Decrypter interface {
	crypto.Decrypter
	DecryptContext(ctx context.Context, rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) ([]byte, error)
}

Decrypter is a crypto.Decrypter whose decryption can take a context. cryptoprov.ContextDecrypter has the same method set.

type Signer

type Signer interface {
	crypto.Signer
	SignContext(ctx context.Context, rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
}

Signer is a crypto.Signer whose signature operation can take a context. cryptoprov.ContextSigner has the same method set.

Jump to

Keyboard shortcuts

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