th5/testdata/Server-TLSv12-ECDHE-ECDSA-AES
David Leon Gil a1363d2ed9 crypto/ecdsa: make Sign safe with broken entropy sources
ECDSA is unsafe to use if an entropy source produces predictable
output for the ephemeral nonces. E.g., [Nguyen]. A simple
countermeasure is to hash the secret key, the message, and
entropy together to seed a CSPRNG, from which the ephemeral key
is derived.

Fixes #9452

--

This is a minimalist (in terms of patch size) solution, though
not the most parsimonious in its use of primitives:

   - csprng_key = ChopMD-256(SHA2-512(priv.D||entropy||hash))
   - reader = AES-256-CTR(k=csprng_key)

This, however, provides at most 128-bit collision-resistance,
so that Adv will have a term related to the number of messages
signed that is significantly worse than plain ECDSA. This does
not seem to be of any practical importance.

ChopMD-256(SHA2-512(x)) is used, rather than SHA2-256(x), for
two sets of reasons:

*Practical:* SHA2-512 has a larger state and 16 more rounds; it
is likely non-generically stronger than SHA2-256. And, AFAIK,
cryptanalysis backs this up. (E.g., [Biryukov] gives a
distinguisher on 47-round SHA2-256 with cost < 2^85.) This is
well below a reasonable security-strength target.

*Theoretical:* [Coron] and [Chang] show that Chop-MD(F(x)) is
indifferentiable from a random oracle for slightly beyond the
birthday barrier. It seems likely that this makes a generic
security proof that this construction remains UF-CMA is
possible in the indifferentiability framework.

--

Many thanks to Payman Mohassel for reviewing this construction;
any mistakes are mine, however. And, as he notes, reusing the
private key in this way means that the generic-group (non-RO)
proof of ECDSA's security given in [Brown] no longer directly
applies.

--

[Brown]: http://www.cacr.math.uwaterloo.ca/techreports/2000/corr2000-54.ps
"Brown. The exact security of ECDSA. 2000"

[Coron]: https://www.cs.nyu.edu/~puniya/papers/merkle.pdf
"Coron et al. Merkle-Damgard revisited. 2005"

[Chang]: https://www.iacr.org/archive/fse2008/50860436/50860436.pdf
"Chang and Nandi. Improved indifferentiability security analysis
of chopMD hash function. 2008"

[Biryukov]: http://www.iacr.org/archive/asiacrypt2011/70730269/70730269.pdf
"Biryukov et al. Second-order differential collisions for reduced
SHA-256. 2011"

[Nguyen]: ftp://ftp.di.ens.fr/pub/users/pnguyen/PubECDSA.ps
"Nguyen and Shparlinski. The insecurity of the elliptic curve
digital signature algorithm with partially known nonces. 2003"

New tests:

  TestNonceSafety: Check that signatures are safe even with a
    broken entropy source.

  TestINDCCA: Check that signatures remain non-deterministic
    with a functional entropy source.

Updated "golden" KATs in crypto/tls/testdata that use ECDSA suites.

Change-Id: I55337a2fbec2e42a36ce719bd2184793682d678a
Reviewed-on: https://go-review.googlesource.com/3340
Reviewed-by: Adam Langley <agl@golang.org>
2015-01-28 01:39:51 +00:00

90 lines
6.6 KiB
Plaintext

>>> Flow 1 (client to server)
00000000 16 03 01 00 a1 01 00 00 9d 03 03 eb 02 58 55 90 |.............XU.|
00000010 a0 ba 80 52 28 a5 36 35 ee 6d eb e1 b0 d3 5d 89 |...R(.65.m....].|
00000020 e8 2d a3 5e b1 83 e8 2f 00 f2 1e 00 00 04 c0 0a |.-.^.../........|
00000030 00 ff 02 01 00 00 6f 00 0b 00 04 03 00 01 02 00 |......o.........|
00000040 0a 00 3a 00 38 00 0e 00 0d 00 19 00 1c 00 0b 00 |..:.8...........|
00000050 0c 00 1b 00 18 00 09 00 0a 00 1a 00 16 00 17 00 |................|
00000060 08 00 06 00 07 00 14 00 15 00 04 00 05 00 12 00 |................|
00000070 13 00 01 00 02 00 03 00 0f 00 10 00 11 00 0d 00 |................|
00000080 20 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 | ...............|
00000090 01 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 |................|
000000a0 03 00 0f 00 01 01 |......|
>>> Flow 2 (server to client)
00000000 16 03 03 00 31 02 00 00 2d 03 03 00 00 00 00 00 |....1...-.......|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 c0 0a 00 00 |................|
00000030 05 ff 01 00 01 00 16 03 03 02 0e 0b 00 02 0a 00 |................|
00000040 02 07 00 02 04 30 82 02 00 30 82 01 62 02 09 00 |.....0...0..b...|
00000050 b8 bf 2d 47 a0 d2 eb f4 30 09 06 07 2a 86 48 ce |..-G....0...*.H.|
00000060 3d 04 01 30 45 31 0b 30 09 06 03 55 04 06 13 02 |=..0E1.0...U....|
00000070 41 55 31 13 30 11 06 03 55 04 08 13 0a 53 6f 6d |AU1.0...U....Som|
00000080 65 2d 53 74 61 74 65 31 21 30 1f 06 03 55 04 0a |e-State1!0...U..|
00000090 13 18 49 6e 74 65 72 6e 65 74 20 57 69 64 67 69 |..Internet Widgi|
000000a0 74 73 20 50 74 79 20 4c 74 64 30 1e 17 0d 31 32 |ts Pty Ltd0...12|
000000b0 31 31 32 32 31 35 30 36 33 32 5a 17 0d 32 32 31 |1122150632Z..221|
000000c0 31 32 30 31 35 30 36 33 32 5a 30 45 31 0b 30 09 |120150632Z0E1.0.|
000000d0 06 03 55 04 06 13 02 41 55 31 13 30 11 06 03 55 |..U....AU1.0...U|
000000e0 04 08 13 0a 53 6f 6d 65 2d 53 74 61 74 65 31 21 |....Some-State1!|
000000f0 30 1f 06 03 55 04 0a 13 18 49 6e 74 65 72 6e 65 |0...U....Interne|
00000100 74 20 57 69 64 67 69 74 73 20 50 74 79 20 4c 74 |t Widgits Pty Lt|
00000110 64 30 81 9b 30 10 06 07 2a 86 48 ce 3d 02 01 06 |d0..0...*.H.=...|
00000120 05 2b 81 04 00 23 03 81 86 00 04 00 c4 a1 ed be |.+...#..........|
00000130 98 f9 0b 48 73 36 7e c3 16 56 11 22 f2 3d 53 c3 |...Hs6~..V.".=S.|
00000140 3b 4d 21 3d cd 6b 75 e6 f6 b0 dc 9a df 26 c1 bc |;M!=.ku......&..|
00000150 b2 87 f0 72 32 7c b3 64 2f 1c 90 bc ea 68 23 10 |...r2|.d/....h#.|
00000160 7e fe e3 25 c0 48 3a 69 e0 28 6d d3 37 00 ef 04 |~..%.H:i.(m.7...|
00000170 62 dd 0d a0 9c 70 62 83 d8 81 d3 64 31 aa 9e 97 |b....pb....d1...|
00000180 31 bd 96 b0 68 c0 9b 23 de 76 64 3f 1a 5c 7f e9 |1...h..#.vd?.\..|
00000190 12 0e 58 58 b6 5f 70 dd 9b d8 ea d5 d7 f5 d5 cc |..XX._p.........|
000001a0 b9 b6 9f 30 66 5b 66 9a 20 e2 27 e5 bf fe 3b 30 |...0f[f. .'...;0|
000001b0 09 06 07 2a 86 48 ce 3d 04 01 03 81 8c 00 30 81 |...*.H.=......0.|
000001c0 88 02 42 01 88 a2 4f eb e2 45 c5 48 7d 1b ac f5 |..B...O..E.H}...|
000001d0 ed 98 9d ae 47 70 c0 5e 1b b6 2f bd f1 b6 4d b7 |....Gp.^../...M.|
000001e0 61 40 d3 11 a2 ce ee 0b 7e 92 7e ff 76 9d c3 3b |a@......~.~.v..;|
000001f0 7e a5 3f ce fa 10 e2 59 ec 47 2d 7c ac da 4e 97 |~.?....Y.G-|..N.|
00000200 0e 15 a0 6f d0 02 42 01 4d fc be 67 13 9c 2d 05 |...o..B.M..g..-.|
00000210 0e bd 3f a3 8c 25 c1 33 13 83 0d 94 06 bb d4 37 |..?..%.3.......7|
00000220 7a f6 ec 7a c9 86 2e dd d7 11 69 7f 85 7c 56 de |z..z......i..|V.|
00000230 fb 31 78 2b e4 c7 78 0d ae cb be 9e 4e 36 24 31 |.1x+..x.....N6$1|
00000240 7b 6a 0f 39 95 12 07 8f 2a 16 03 03 00 d7 0c 00 |{j.9....*.......|
00000250 00 d3 03 00 17 41 04 1e 18 37 ef 0d 19 51 88 35 |.....A...7...Q.5|
00000260 75 71 b5 e5 54 5b 12 2e 8f 09 67 fd a7 24 20 3e |uq..T[....g..$ >|
00000270 b2 56 1c ce 97 28 5e f8 2b 2d 4f 9e f1 07 9f 6c |.V...(^.+-O....l|
00000280 4b 5b 83 56 e2 32 42 e9 58 b6 d7 49 a6 b5 68 1a |K[.V.2B.X..I..h.|
00000290 41 03 56 6b dc 5a 89 04 03 00 8a 30 81 87 02 41 |A.Vk.Z.....0...A|
000002a0 68 cb cd c0 12 5e 1e b3 cc d9 47 e7 b5 11 5e be |h....^....G...^.|
000002b0 74 5b 90 93 3f 4c 07 20 a1 94 50 bb 23 82 fc 5b |t[..?L. ..P.#..[|
000002c0 78 87 a3 a1 fe 7c 6f 84 93 8f b8 f7 2e 56 65 85 |x....|o......Ve.|
000002d0 1d 9e 8e 52 b0 89 b0 a7 66 58 98 55 30 64 94 91 |...R....fX.U0d..|
000002e0 8e 02 42 01 3d 74 eb a4 64 9e 7c 8b 05 57 5c f7 |..B.=t..d.|..W\.|
000002f0 fe a7 58 f4 21 7b 75 ea 51 1e 1c be 80 4e 00 d1 |..X.!{u.Q....N..|
00000300 06 80 58 90 c2 f3 47 da 22 8b a2 6b f0 2e 34 d0 |..X...G."..k..4.|
00000310 1a 84 54 87 62 96 b9 2c 91 9f 3f 93 24 df 6c a3 |..T.b..,..?.$.l.|
00000320 77 1f d2 e4 30 16 03 03 00 04 0e 00 00 00 |w...0.........|
>>> Flow 3 (client to server)
00000000 16 03 03 00 46 10 00 00 42 41 04 04 12 72 83 8c |....F...BA...r..|
00000010 55 75 c4 34 48 5d d4 e3 9a 34 54 46 83 2f 69 36 |Uu.4H]...4TF./i6|
00000020 e2 98 65 4d d2 b3 d4 6e 35 93 42 80 02 bd 26 a4 |..eM...n5.B...&.|
00000030 ca 53 8d 50 c8 78 ec e3 0d 68 31 12 11 fe 76 52 |.S.P.x...h1...vR|
00000040 0d 2f 63 76 43 74 5b 55 bd 9a 01 14 03 03 00 01 |./cvCt[U........|
00000050 01 16 03 03 00 40 5f b8 b6 b9 cd 93 37 67 53 6f |.....@_.....7gSo|
00000060 cd 2d c6 c2 92 28 d6 ab b7 31 ab 75 99 c8 83 7d |.-...(...1.u...}|
00000070 99 69 03 2d 52 6f ae 06 ec 34 05 fc 3b dd d0 0b |.i.-Ro...4..;...|
00000080 22 4a 84 cd 86 6c 11 10 3d 0d 9c 0f c8 c9 24 a6 |"J...l..=.....$.|
00000090 f3 e6 e7 87 31 13 |....1.|
>>> Flow 4 (server to client)
00000000 14 03 03 00 01 01 16 03 03 00 40 00 00 00 00 00 |..........@.....|
00000010 00 00 00 00 00 00 00 00 00 00 00 a9 71 da 7a 3d |............q.z=|
00000020 c1 17 da fa 05 ac ed a6 79 79 31 67 83 de 86 92 |........yy1g....|
00000030 de 7e 6f 5c dc d7 e8 29 df 51 15 a1 6f 38 84 a5 |.~o\...).Q..o8..|
00000040 a6 e4 f2 56 8a cc bf ad f4 b8 0c 17 03 03 00 40 |...V...........@|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 b1 a6 a1 eb f4 26 ef e9 25 7d c8 b5 a5 4b dc c8 |.....&..%}...K..|
00000070 32 58 d6 c3 94 e7 f7 20 10 9e a1 db 10 db e4 42 |2X..... .......B|
00000080 3c c5 26 e7 70 f2 d7 f0 38 10 a7 63 61 22 1b 57 |<.&.p...8..ca".W|
00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........|
000000a0 00 00 00 00 00 29 ea 96 ea 08 88 6c 5d 67 91 f7 |.....).....l]g..|
000000b0 31 8e b8 3a 9a d5 87 2a 81 2f 80 fb 7f b5 80 03 |1..:...*./......|
000000c0 9c 8b 7e 39 7b |..~9{|