-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/crypto/acme: crypto.Signer interface mismatch #35829
Comments
@x1ddos Any reason for this? The Unless I'm missing something, we should fix this soon so that code doesn't start relying on it. |
The bug was introduced by golang/crypto@bfa7d42. |
Yeah, pretty sure this is a bug. Sorry I missed it in review. |
That comment would be misleading if you read it from a public API point of view. What it actually does is it formats the signature according to JWS if it's ECDSA or uses whatever
Yes, see commit message golang/crypto@bfa7d42 (you reviewed it at the time, it seems)
The What is public API is https://godoc.org/golang.org/x/crypto/acme#Client:
|
If a From the
|
Ok. I'll take a look. Can't remember at the moment what the issue with using ASN1 for ECDSA was exactly. |
No, signatures are never reformatted from the ASN.1 format to the JWS format, not even for ECDSA. This is fairly easy to demonstrate: package main
import (
"context"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"fmt"
"golang.org/x/crypto/acme"
)
func main() {
var key crypto.Signer
key, _ = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
// comment this line out to generate valid signatures
key = struct{ crypto.Signer }{key}
ac := &acme.Client{Key: key, DirectoryURL: "https://acme-staging-v02.api.letsencrypt.org/directory"}
fmt.Println(ac.Register(context.Background(), &acme.Account{}, acme.AcceptTOS))
} As of golang/crypto@ac88ee7:
|
Found where it's used internally. I believe I'll be able to make it work with ASN1 in all cases. |
FWIW, I've got a patch ready to roll, but the tests would need a bit of rework to actually pass valid signatures around rather than |
@edef1c then please take this bug. |
Change https://golang.org/cl/209537 mentions this issue: |
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, an ECDSA crypto.Signer would have been expected to return a signature in RFC7518 format, which violates crypto.Signer's interface contract. Fixes golang/go#35829 Change-Id: Id0cc2d9296cfb9f89925ab9ac02e12d68eec734b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/209537 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Currently,
acme.Client.Key
is allowed to be acrypto.Signer
, but has rather unusual expectations of that interface:It is the understanding of me and @FiloSottile that a
crypto.Signer
should return the "standard" signature format matching the key type returned byPublic()
, which is the ASN.1(r, s)
tuple for*ecdsa.PublicKey
, and certainly not a JWS-specific format.The text was updated successfully, but these errors were encountered: