diff options
| author | Adam Langley <agl@golang.org> | 2015-12-04 14:17:03 -0800 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-12-08 17:39:09 +0000 |
| commit | f740d717bd31e1a4b8281072b5cb3dfeb26f3273 (patch) | |
| tree | a1d22aeeda0e35b6c0b39a1b23ceac820ded40dd /src/encoding | |
| parent | aa487e66f869785837275ee20441a53888a51bb2 (diff) | |
| download | go-f740d717bd31e1a4b8281072b5cb3dfeb26f3273.tar.xz | |
crypto/elliptic: resample private keys if out of range.
The orders of the curves in crypto/elliptic are all very close to a
power of two. None the less, there is a tiny bias in the private key
selection.
This change makes the distribution uniform by resampling in the case
that a private key is >= to the order of the curve. (It also switches
from using BitSize to Params().N.BitLen() because, although they're the
same value here, the latter is technically the correct thing to do.)
The private key sampling and nonce sampling in crypto/ecdsa don't have
this issue.
Fixes #11082.
Change-Id: Ie2aad563209a529fa1cab522abaf5fd505c7269a
Reviewed-on: https://go-review.googlesource.com/17460
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/encoding')
0 files changed, 0 insertions, 0 deletions
