英文:
crypto/elliptic: attempted operation on invalid point
问题
我使用签名有效载荷后的 r
和 s
值,然后将其解码回签名。
首先,我将字符串值转换为大整数:
myBigInt := new(big.Int)
myBigInt.SetString(byteValue, 16)
然后,我将其转换为签名:
elliptic.Marshal(elliptic.P256(), &myBigIntR, &myBigIntS)
当我在本地执行时,没有任何问题。然后我将其推送到 GitHub,render.com 进行了捕捉。然而,在服务器上,我遇到了以下问题:
我收到:
Mar 15 05:36:31 PM 2023/03/15 17:36:31 http: panic serving : crypto/elliptic: attempted operation on invalid point
Mar 15 05:36:31 PM goroutine 1252 [running]:
Mar 15 05:36:31 PM net/http.(*conn).serve.func1()
Mar 15 05:36:31 PM /usr/local/go/src/net/http/server.go:1854 +0xbf
Mar 15 05:36:31 PM panic({0xc5ff40, 0xfaae70})
Mar 15 05:36:31 PM /usr/local/go/src/runtime/panic.go:890 +0x263
Mar 15 05:36:31 PM crypto/elliptic.panicIfNotOnCurve({0xfbc088?, 0x15d3950?}, 0x40?, 0xc000100400?)
Mar 15 05:36:31 PM /usr/local/go/src/crypto/elliptic/elliptic.go:215 +0xa5
Mar 15 05:36:31 PM crypto/elliptic.Marshal({0xfbc088, 0x15d3950}, 0x15d3950?, 0xc0002c2020?)
Mar 15 05:36:31 PM /usr/local/go/src/crypto/elliptic/elliptic.go:105 +0x31
我无法确定服务器版本和本地版本之间有什么不同。是否有人遇到过这个问题?谷歌上没有明显的问题解决方法。
使用 sigR 和 sigS 值:
v2signature := new(refs.Signature)
v2signature.SetScheme(refs.ECDSA_SHA512)
signatureData := elliptic.Marshal(elliptic.P256(), &sigR, &sigS)
v2signature.SetSign(signatureData)
v2signature.SetKey(containerOwnerKey.Bytes()) //1. this should be the container owner
var bearerV2 acl.BearerToken
bearerToken.WriteToV2(&bearerV2)
bearerV2.SetSignature(v2signature)
这是一个使用承载令牌访问远程服务器上的资产的 SDK。我使用 r 和 s 两个值创建了一个新的签名,使用方案 ECDSA_SHA512
,然后将其附加到承载令牌中。
英文:
I'm using the r
and s
value after signing a payload to then decode it back to a signature.
First I convert the string values to a bigInt with
myBigInt := new(big.Int)
myBigInt.SetString(byteValue, 16)
Then I convert to the signature with
elliptic.Marshal(elliptic.P256(), &myBigIntR, &myBigIntS)
When I do this locally, I have no issues whatsoever. I am pushing this then to github and render.com picks it up. However on the server, i get:
I Receive:
Mar 15 05:36:31 PM 2023/03/15 17:36:31 http: panic serving : crypto/elliptic: attempted operation on invalid point
Mar 15 05:36:31 PM goroutine 1252 [running]:
Mar 15 05:36:31 PM net/http.(*conn).serve.func1()
Mar 15 05:36:31 PM /usr/local/go/src/net/http/server.go:1854 +0xbf
Mar 15 05:36:31 PM panic({0xc5ff40, 0xfaae70})
Mar 15 05:36:31 PM /usr/local/go/src/runtime/panic.go:890 +0x263
Mar 15 05:36:31 PM crypto/elliptic.panicIfNotOnCurve({0xfbc088?, 0x15d3950?}, 0x40?, 0xc000100400?)
Mar 15 05:36:31 PM /usr/local/go/src/crypto/elliptic/elliptic.go:215 +0xa5
Mar 15 05:36:31 PM crypto/elliptic.Marshal({0xfbc088, 0x15d3950}, 0x15d3950?, 0xc0002c2020?)
Mar 15 05:36:31 PM /usr/local/go/src/crypto/elliptic/elliptic.go:105 +0x31
I cannot work out what could be different between the server version and a local version.
Has anyone come across this. Google didn't have much in the way of an obvious issue I could be making.
Using the sigR and sigS values:
v2signature := new(refs.Signature)
v2signature.SetScheme(refs.ECDSA_SHA512)
signatureData := elliptic.Marshal(elliptic.P256(), &sigR, &sigS)
v2signature.SetSign(signatureData)
v2signature.SetKey(containerOwnerKey.Bytes()) //1. this should be the container owner
var bearerV2 acl.BearerToken
bearerToken.WriteToV2(&bearerV2)
bearerV2.SetSignature(v2signature)
This is from an SDK that uses bearer tokens to access assets on a remote server.
I am creating a new signature using the two values r and s, with scheme ECDSA_SHA512
and then attaching that to the bearer token
答案1
得分: 0
我最终将所有内容都放入了一个Docker镜像中,这样我就可以在本地和远程控制所有版本。这解决了我的问题。我怀疑云服务使用了一些不同的Go版本或其他东西。感谢那些帮助过我的人!
英文:
I ended up sticking the whole lot in a docker image so that I could control versions of everything locally and remotely. This solved my issues. I suspect the cloud service was using some different Go version or something. Thanks for those who helped out!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论