-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto/elliptic: tolerate zero-padded scalars in generic P-256
Fixes golang#52075 Change-Id: I595a7514c9a0aa1b9c76aedfc2307e1124271f27 Reviewed-on: https://go-review.googlesource.com/c/go/+/397135 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]>
- Loading branch information
1 parent
e88851b
commit 2664205
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package elliptic | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIssue52075(t *testing.T) { | ||
Gx, Gy := P256().Params().Gx, P256().Params().Gy | ||
scalar := make([]byte, 33) | ||
scalar[32] = 1 | ||
x, y := P256().ScalarBaseMult(scalar) | ||
if x.Cmp(Gx) != 0 || y.Cmp(Gy) != 0 { | ||
t.Errorf("unexpected output (%v,%v)", x, y) | ||
} | ||
x, y = P256().ScalarMult(Gx, Gy, scalar) | ||
if x.Cmp(Gx) != 0 || y.Cmp(Gy) != 0 { | ||
t.Errorf("unexpected output (%v,%v)", x, y) | ||
} | ||
} |