Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Issue 141036: Fix decoding bug in RSAPrivateKey. (Closed)

Created:
11 years, 6 months ago by Aaron Boodman
Modified:
9 years, 6 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Fix decoding bug in RSAPrivateKey. We were dropping the most significant byte from the input when decoding PrivateKeyInfo, whether or not it was part of the original data. This shouldn't matter, except that we need to get back the original byte lengths so that we can give them to CryptoAPI. BUG=14877 TEST=Stress tested the functions by creating 1000 random private keys, exporting them, then re-importing. Also tried stressing the edge cases in particular around extra trailing null bytes.

Patch Set 1 #

Patch Set 2 : Cleanup #

Patch Set 3 : more cleanup #

Patch Set 4 : Simpler fix #

Patch Set 5 : Simpler fix #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+51 lines, -31 lines) Patch
M base/crypto/rsa_private_key_win.cc View 1 2 3 7 chunks +51 lines, -31 lines 4 comments Download

Messages

Total messages: 7 (0 generated)
Aaron Boodman
One thing I'm curious about here: how do other people who parse PrivateKeyInfo determine the ...
11 years, 6 months ago (2009-06-22 02:08:32 UTC) #1
Aaron Boodman
On 2009/06/22 02:08:32, Aaron Boodman wrote: > One thing I'm curious about here: how do ...
11 years, 6 months ago (2009-06-22 04:44:07 UTC) #2
Aaron Boodman
OK, here is a much simpler fix.
11 years, 6 months ago (2009-06-22 16:13:39 UTC) #3
Evan Martin
http://codereview.chromium.org/141036/diff/1016/24 File base/crypto/rsa_private_key_win.cc (right): http://codereview.chromium.org/141036/diff/1016/24#newcode88 Line 88: // Skip any trailing null bytes since the ...
11 years, 6 months ago (2009-06-22 16:23:44 UTC) #4
Erik does not do reviews
LGTM I'd like to see two things which could be done in a followup: (1) ...
11 years, 6 months ago (2009-06-22 16:35:51 UTC) #5
Aaron Boodman
Cool, I added/referenced a bug. I'll work on adding some worst-case keys to the tests ...
11 years, 6 months ago (2009-06-22 16:44:43 UTC) #6
wtc
11 years, 6 months ago (2009-06-22 17:26:18 UTC) #7
LGTM.

http://codereview.chromium.org/141036/diff/1016/24
File base/crypto/rsa_private_key_win.cc (right):

http://codereview.chromium.org/141036/diff/1016/24#newcode96
Line 96: if ((val[num_bytes - 1] & 0x80) != 0) {
Nit: it's less confusing to test 'data' here:
  if (data->front() & 0x80) != 0) {

http://codereview.chromium.org/141036/diff/1016/24#newcode212
Line 212: // Pad out any missing bytes with null.
Are you sure you want to allow missing bytes?  I don't have
time to check this, so I'm counting on you to make the right
decision.

http://codereview.chromium.org/141036/diff/1016/24#newcode272
Line 272: if (!ReadIntegerWithExpectedSize(&src, end, 4, &public_exponent) ||
The expected size of 4 for the public exponent assumes more
than necessary.  Numbers other than 2^16 + 1 can also be used
as public exponents.

Powered by Google App Engine
This is Rietveld 408576698