-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/elliptic: unexpected P256.ScalarMult result #26020
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
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Comments
P256.ScalarMult
is different from that generated by openssl cmd line tool (or python cryptography)P256.ScalarMult
is different from that generated by openssl cmd line tool (or python cryptography)
CC @FiloSottile |
/cc @agl too |
P256.ScalarMult
is different from that generated by openssl cmd line tool (or python cryptography)
These are the same values, but the one generated by OpenSSL has a leading zero:
This is because the shareKeyBytes := shareKey.Bytes()
for len(shareKeyBytes) < len(cliPubkey.Curve.Params().N.Bytes()) {
shareKeyBytes = append([]byte{0}, shareKeyBytes...)
} |
Thanks @conradoplg, that's right. This is a common annoying corner of |
Thank all. It helps me a lot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Please answer these questions before submitting your issue. Thanks!
What did you do?
A link on play.golang.org is https://play.golang.org/p/prLYofpthWy
What did you expect to see?
The shared key expected is
ACjIKHvl1FAT1zAEQ882cmRQjT75GoLk6MpGHsiDqno=
What did you see instead?
The actual shared key is
KMgoe+XUUBPXMARDzzZyZFCNPvkaguToykYeyIOqeg==
Trying to use openssl cmd tool and python to generate shared key
ACjIKHvl1FAT1zAEQ882cmRQjT75GoLk6MpGHsiDqno=
ACjIKHvl1FAT1zAEQ882cmRQjT75GoLk6MpGHsiDqno=
This different shared key case rarely happens. I am sure
cliPubBytes
andserPriBytes
in this case is validated. I used go bench to test ScalarMult's performance and I found the issue. I don't know how to slove it. Hope to get help.System details
The text was updated successfully, but these errors were encountered: