Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: crypto: add SignContext #28427

x1ddos opened this issue Oct 26, 2018 · 3 comments

proposal: crypto: add SignContext #28427

x1ddos opened this issue Oct 26, 2018 · 3 comments


Copy link

@x1ddos x1ddos commented Oct 26, 2018

It is often desirable for a custom crypto.Signer implementation to get a hold of a context.Context during a signing operation, especially so if the signing involves HTTP or RPC roundtrips.

For example, one may want to use Google Cloud KMS to sign digests by implementing the crypto.Signer interface. This could then be fed to x/crypto/acme.Client where each request needs to be signed using crypto.Signer.

We already have precedents:

go1.7.txt:pkg net, method (*Dialer) DialContext(context.Context, string, string) (Conn, error)
go1.7.txt:pkg os/exec, func CommandContext(context.Context, string, ...string) *Cmd
go1.8.txt:pkg database/sql, method (*DB) ExecContext(context.Context, string, ...interface{}) (Result, error)

Please add Go2 label.

@gopherbot gopherbot added this to the Proposal milestone Oct 26, 2018
@gopherbot gopherbot added the Proposal label Oct 26, 2018
Copy link

@OneOfOne OneOfOne commented Oct 26, 2018

@gopherbot please add go2

@gopherbot gopherbot added the Go2 label Oct 26, 2018
Copy link

@bcmills bcmills commented Nov 5, 2018

Note that you can already use a curried function to achieve a similar effect:

type CtxSigner = func(context.Context) crypto.Signer

func f(ctx context.Context, signCtx CtxSigner, […]) {
	sig, err := signCtx(ctx).Sign(rand, digest, opts)

That is, this may be more of an issue with the acme.Client API than with the crypto package itself. (See also #28342 and #20280.)

Copy link

@ianlancetaylor ianlancetaylor commented Dec 4, 2018

@ianlancetaylor ianlancetaylor changed the title proposal: Go 2: crypto: add SignContext proposal: crypto: add SignContext Dec 4, 2018
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants