Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(263)

Issue 7002050: code review 7002050: crypto/rsa: ensure that RSA keys use the full number of... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 7 months ago by agl1
Modified:
12 years, 6 months ago
Reviewers:
CC:
rsc, minux1, golang-dev
Visibility:
Public.

Description

crypto/rsa: ensure that RSA keys use the full number of bits. While half of all numbers don't have their most-significant bit set, this is becoming increasingly impermissible for RSA moduli. In an attempt to exclude weak keys, several bits of software either do, or will, enforce that RSA moduli are >= 1024-bits. However, Go often generates 1023-bit RSA moduli which this software would then reject. This change causes crypto/rsa to regenerate the primes in the event that the result is shorter than requested. It also alters crypto/rand in order to remove the performance impact of this: The most important change to crypto/rand is that it will now set the top two bits in a generated prime (OpenSSL does the same thing). Multiplying two n/2 bit numbers, where each have the top two bits set, will always result in an n-bit product. (The effectively makes the crypto/rsa change moot, but that seems too fragile to depend on.) Also this change adds code to crypto/rand to rapidly eliminate some obviously composite numbers and reduce the number of Miller-Rabin tests needed to generate a prime.

Patch Set 1 #

Patch Set 2 : diff -r df1405f02219 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r df1405f02219 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 5cf37c9db688 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+66 lines, -3 lines) Patch
M src/pkg/crypto/rand/util.go View 1 3 chunks +58 lines, -3 lines 0 comments Download
M src/pkg/crypto/rsa/rsa.go View 1 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/crypto/rsa/rsa_test.go View 1 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 5
agl1
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 7 months ago (2012-12-22 16:02:00 UTC) #1
rsc
LGTM
12 years, 7 months ago (2012-12-22 16:10:18 UTC) #2
minux1
On Sun, Dec 23, 2012 at 12:02 AM, <agl@golang.org> wrote: > Description: > will always ...
12 years, 7 months ago (2012-12-22 21:06:33 UTC) #3
agl1
On Sat, Dec 22, 2012 at 4:06 PM, minux <minux.ma@gmail.com> wrote: >> will always result ...
12 years, 6 months ago (2012-12-29 00:03:41 UTC) #4
agl1
12 years, 6 months ago (2012-12-29 00:12:30 UTC) #5
*** Submitted as https://code.google.com/p/go/source/detail?r=019884311591 ***

crypto/rsa: ensure that RSA keys use the full number of bits.

While half of all numbers don't have their most-significant bit set,
this is becoming increasingly impermissible for RSA moduli. In an
attempt to exclude weak keys, several bits of software either do, or
will, enforce that RSA moduli are >= 1024-bits.

However, Go often generates 1023-bit RSA moduli which this software
would then reject.

This change causes crypto/rsa to regenerate the primes in the event
that the result is shorter than requested.

It also alters crypto/rand in order to remove the performance impact
of this:

The most important change to crypto/rand is that it will now set the
top two bits in a generated prime (OpenSSL does the same thing).
Multiplying two n/2 bit numbers, where each have the top two bits set,
will always result in an n-bit product. (The effectively makes the
crypto/rsa change moot, but that seems too fragile to depend on.)

Also this change adds code to crypto/rand to rapidly eliminate some
obviously composite numbers and reduce the number of Miller-Rabin
tests needed to generate a prime.

R=rsc, minux.ma
CC=golang-dev
https://codereview.appspot.com/7002050
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b