a1363d2ed9
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>
113 linhas
8.4 KiB
Plaintext
113 linhas
8.4 KiB
Plaintext
>>> Flow 1 (client to server)
|
|
00000000 16 03 01 01 61 01 00 01 5d 03 03 17 83 43 01 d8 |....a...]....C..|
|
|
00000010 14 04 ed 55 41 35 99 cd f6 50 e6 47 10 60 7d d9 |...UA5...P.G.`}.|
|
|
00000020 d1 f4 0f a1 bf 27 ab 0c 44 56 a5 00 00 c4 c0 30 |.....'..DV.....0|
|
|
00000030 c0 2c c0 28 c0 24 c0 14 c0 0a 00 a5 00 a3 00 a1 |.,.(.$..........|
|
|
00000040 00 9f 00 6b 00 6a 00 69 00 68 00 39 00 38 00 37 |...k.j.i.h.9.8.7|
|
|
00000050 00 36 00 88 00 87 00 86 00 85 c0 32 c0 2e c0 2a |.6.........2...*|
|
|
00000060 c0 26 c0 0f c0 05 00 9d 00 3d 00 35 00 84 c0 2f |.&.......=.5.../|
|
|
00000070 c0 2b c0 27 c0 23 c0 13 c0 09 00 a4 00 a2 00 a0 |.+.'.#..........|
|
|
00000080 00 9e 00 67 00 40 00 3f 00 3e 00 33 00 32 00 31 |...g.@.?.>.3.2.1|
|
|
00000090 00 30 00 9a 00 99 00 98 00 97 00 45 00 44 00 43 |.0.........E.D.C|
|
|
000000a0 00 42 c0 31 c0 2d c0 29 c0 25 c0 0e c0 04 00 9c |.B.1.-.).%......|
|
|
000000b0 00 3c 00 2f 00 96 00 41 00 07 c0 11 c0 07 c0 0c |.<./...A........|
|
|
000000c0 c0 02 00 05 00 04 c0 12 c0 08 00 16 00 13 00 10 |................|
|
|
000000d0 00 0d c0 0d c0 03 00 0a 00 15 00 12 00 0f 00 0c |................|
|
|
000000e0 00 09 00 14 00 11 00 0e 00 0b 00 08 00 06 00 03 |................|
|
|
000000f0 00 ff 02 01 00 00 6f 00 0b 00 04 03 00 01 02 00 |......o.........|
|
|
00000100 0a 00 3a 00 38 00 0e 00 0d 00 19 00 1c 00 0b 00 |..:.8...........|
|
|
00000110 0c 00 1b 00 18 00 09 00 0a 00 1a 00 16 00 17 00 |................|
|
|
00000120 08 00 06 00 07 00 14 00 15 00 04 00 05 00 12 00 |................|
|
|
00000130 13 00 01 00 02 00 03 00 0f 00 10 00 11 00 0d 00 |................|
|
|
00000140 20 00 1e 06 01 06 02 06 03 05 01 05 02 05 03 04 | ...............|
|
|
00000150 01 04 02 04 03 03 01 03 02 03 03 02 01 02 02 02 |................|
|
|
00000160 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 14 00 00 |................|
|
|
00000030 05 ff 01 00 01 00 16 03 03 02 be 0b 00 02 ba 00 |................|
|
|
00000040 02 b7 00 02 b4 30 82 02 b0 30 82 02 19 a0 03 02 |.....0...0......|
|
|
00000050 01 02 02 09 00 85 b0 bb a4 8a 7f b8 ca 30 0d 06 |.............0..|
|
|
00000060 09 2a 86 48 86 f7 0d 01 01 05 05 00 30 45 31 0b |.*.H........0E1.|
|
|
00000070 30 09 06 03 55 04 06 13 02 41 55 31 13 30 11 06 |0...U....AU1.0..|
|
|
00000080 03 55 04 08 13 0a 53 6f 6d 65 2d 53 74 61 74 65 |.U....Some-State|
|
|
00000090 31 21 30 1f 06 03 55 04 0a 13 18 49 6e 74 65 72 |1!0...U....Inter|
|
|
000000a0 6e 65 74 20 57 69 64 67 69 74 73 20 50 74 79 20 |net Widgits Pty |
|
|
000000b0 4c 74 64 30 1e 17 0d 31 30 30 34 32 34 30 39 30 |Ltd0...100424090|
|
|
000000c0 39 33 38 5a 17 0d 31 31 30 34 32 34 30 39 30 39 |938Z..1104240909|
|
|
000000d0 33 38 5a 30 45 31 0b 30 09 06 03 55 04 06 13 02 |38Z0E1.0...U....|
|
|
000000e0 41 55 31 13 30 11 06 03 55 04 08 13 0a 53 6f 6d |AU1.0...U....Som|
|
|
000000f0 65 2d 53 74 61 74 65 31 21 30 1f 06 03 55 04 0a |e-State1!0...U..|
|
|
00000100 13 18 49 6e 74 65 72 6e 65 74 20 57 69 64 67 69 |..Internet Widgi|
|
|
00000110 74 73 20 50 74 79 20 4c 74 64 30 81 9f 30 0d 06 |ts Pty Ltd0..0..|
|
|
00000120 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 81 8d 00 |.*.H............|
|
|
00000130 30 81 89 02 81 81 00 bb 79 d6 f5 17 b5 e5 bf 46 |0.......y......F|
|
|
00000140 10 d0 dc 69 be e6 2b 07 43 5a d0 03 2d 8a 7a 43 |...i..+.CZ..-.zC|
|
|
00000150 85 b7 14 52 e7 a5 65 4c 2c 78 b8 23 8c b5 b4 82 |...R..eL,x.#....|
|
|
00000160 e5 de 1f 95 3b 7e 62 a5 2c a5 33 d6 fe 12 5c 7a |....;~b.,.3...\z|
|
|
00000170 56 fc f5 06 bf fa 58 7b 26 3f b5 cd 04 d3 d0 c9 |V.....X{&?......|
|
|
00000180 21 96 4a c7 f4 54 9f 5a bf ef 42 71 00 fe 18 99 |!.J..T.Z..Bq....|
|
|
00000190 07 7f 7e 88 7d 7d f1 04 39 c4 a2 2e db 51 c9 7c |..~.}}..9....Q.||
|
|
000001a0 e3 c0 4c 3b 32 66 01 cf af b1 1d b8 71 9a 1d db |..L;2f......q...|
|
|
000001b0 db 89 6b ae da 2d 79 02 03 01 00 01 a3 81 a7 30 |..k..-y........0|
|
|
000001c0 81 a4 30 1d 06 03 55 1d 0e 04 16 04 14 b1 ad e2 |..0...U.........|
|
|
000001d0 85 5a cf cb 28 db 69 ce 23 69 de d3 26 8e 18 88 |.Z..(.i.#i..&...|
|
|
000001e0 39 30 75 06 03 55 1d 23 04 6e 30 6c 80 14 b1 ad |90u..U.#.n0l....|
|
|
000001f0 e2 85 5a cf cb 28 db 69 ce 23 69 de d3 26 8e 18 |..Z..(.i.#i..&..|
|
|
00000200 88 39 a1 49 a4 47 30 45 31 0b 30 09 06 03 55 04 |.9.I.G0E1.0...U.|
|
|
00000210 06 13 02 41 55 31 13 30 11 06 03 55 04 08 13 0a |...AU1.0...U....|
|
|
00000220 53 6f 6d 65 2d 53 74 61 74 65 31 21 30 1f 06 03 |Some-State1!0...|
|
|
00000230 55 04 0a 13 18 49 6e 74 65 72 6e 65 74 20 57 69 |U....Internet Wi|
|
|
00000240 64 67 69 74 73 20 50 74 79 20 4c 74 64 82 09 00 |dgits Pty Ltd...|
|
|
00000250 85 b0 bb a4 8a 7f b8 ca 30 0c 06 03 55 1d 13 04 |........0...U...|
|
|
00000260 05 30 03 01 01 ff 30 0d 06 09 2a 86 48 86 f7 0d |.0....0...*.H...|
|
|
00000270 01 01 05 05 00 03 81 81 00 08 6c 45 24 c7 6b b1 |..........lE$.k.|
|
|
00000280 59 ab 0c 52 cc f2 b0 14 d7 87 9d 7a 64 75 b5 5a |Y..R.......zdu.Z|
|
|
00000290 95 66 e4 c5 2b 8e ae 12 66 1f eb 4f 38 b3 6e 60 |.f..+...f..O8.n`|
|
|
000002a0 d3 92 fd f7 41 08 b5 25 13 b1 18 7a 24 fb 30 1d |....A..%...z$.0.|
|
|
000002b0 ba ed 98 b9 17 ec e7 d7 31 59 db 95 d3 1d 78 ea |........1Y....x.|
|
|
000002c0 50 56 5c d5 82 5a 2d 5a 5f 33 c4 b6 d8 c9 75 90 |PV\..Z-Z_3....u.|
|
|
000002d0 96 8c 0f 52 98 b5 cd 98 1f 89 20 5f f2 a0 1c a3 |...R...... _....|
|
|
000002e0 1b 96 94 dd a9 fd 57 e9 70 e8 26 6d 71 99 9b 26 |......W.p.&mq..&|
|
|
000002f0 6e 38 50 29 6c 90 a7 bd d9 16 03 03 00 cd 0c 00 |n8P)l...........|
|
|
00000300 00 c9 03 00 17 41 04 1e 18 37 ef 0d 19 51 88 35 |.....A...7...Q.5|
|
|
00000310 75 71 b5 e5 54 5b 12 2e 8f 09 67 fd a7 24 20 3e |uq..T[....g..$ >|
|
|
00000320 b2 56 1c ce 97 28 5e f8 2b 2d 4f 9e f1 07 9f 6c |.V...(^.+-O....l|
|
|
00000330 4b 5b 83 56 e2 32 42 e9 58 b6 d7 49 a6 b5 68 1a |K[.V.2B.X..I..h.|
|
|
00000340 41 03 56 6b dc 5a 89 04 01 00 80 7f 65 76 11 35 |A.Vk.Z......ev.5|
|
|
00000350 e1 9c c6 0c 21 41 d6 b4 22 2f a3 02 57 5c 40 5c |....!A.."/..W\@\|
|
|
00000360 2e 0c 5f 07 01 d1 78 29 a3 7b 65 37 1c c6 51 a8 |.._...x).{e7..Q.|
|
|
00000370 e1 70 b4 73 9a cf 37 73 c8 ce 7c 8b 60 9e 0f e4 |.p.s..7s..|.`...|
|
|
00000380 d7 2e 2a a8 fd 5a 0c 8a e7 e0 4c ca 0b 28 6d ea |..*..Z....L..(m.|
|
|
00000390 39 da 9f ac 6c 23 f0 c6 fe 21 a8 ad fb e8 c9 6d |9...l#...!.....m|
|
|
000003a0 96 86 75 4d 88 f0 e8 71 e0 dc 32 b9 81 f9 f3 fe |..uM...q..2.....|
|
|
000003b0 64 e1 34 62 dc e2 0a 21 a3 7e 70 0d b0 f3 9d 13 |d.4b...!.~p.....|
|
|
000003c0 5c 81 58 24 97 a9 fb 1d 99 60 a7 16 03 03 00 04 |\.X$.....`......|
|
|
000003d0 0e 00 00 00 |....|
|
|
>>> Flow 3 (client to server)
|
|
00000000 16 03 03 00 46 10 00 00 42 41 04 27 9e 27 b7 bf |....F...BA.'.'..|
|
|
00000010 b1 a9 b0 5b 7d 1c 9a 02 51 6e 03 ba 60 5a a2 50 |...[}...Qn..`Z.P|
|
|
00000020 17 a6 2a e4 02 cd 6f ed a2 97 49 49 0c 36 70 53 |..*...o...II.6pS|
|
|
00000030 ce 0c 79 49 14 55 9a 7f a6 0a 10 65 4f e4 c6 10 |..yI.U.....eO...|
|
|
00000040 c2 31 68 5c 0e 5c ab 8a a8 1c 52 14 03 03 00 01 |.1h\.\....R.....|
|
|
00000050 01 16 03 03 00 40 25 59 40 9e 5b 9a d5 95 a1 59 |.....@%Y@.[....Y|
|
|
00000060 d4 1d ea 0c 02 d1 66 29 c2 d5 d4 24 7a c7 9e 47 |......f)...$z..G|
|
|
00000070 f7 79 a1 5f 72 fb c8 10 61 81 e8 e3 fb 16 7e 30 |.y._r...a.....~0|
|
|
00000080 e2 cc 95 d2 24 2a 0f 94 96 b6 0a 27 1a 87 c9 36 |....$*.....'...6|
|
|
00000090 c7 b4 e9 21 d1 94 |...!..|
|
|
>>> 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 fe 1d f1 25 18 |..............%.|
|
|
00000020 dd 7a 1e 10 f0 86 7f 75 74 44 a5 89 92 c8 21 ff |.z.....utD....!.|
|
|
00000030 b8 1b bf 79 3f 19 8e 12 04 65 58 a7 e5 96 52 3a |...y?....eX...R:|
|
|
00000040 15 af 57 d8 9e 46 6f 3f 0d 89 67 17 03 03 00 40 |..W..Fo?..g....@|
|
|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
|
00000060 1b fb 13 e3 c0 eb 94 bb 4f e1 9e 47 6a ce 9b 6c |........O..Gj..l|
|
|
00000070 03 2f bf 0b 2f 08 36 48 b2 00 26 ab fb cc 3c 2f |./../.6H..&...</|
|
|
00000080 8d 99 82 86 a1 b7 15 04 f0 59 97 d7 50 61 1c a1 |.........Y..Pa..|
|
|
00000090 15 03 03 00 30 00 00 00 00 00 00 00 00 00 00 00 |....0...........|
|
|
000000a0 00 00 00 00 00 95 ed 23 80 9e f5 f2 37 ac 2d 50 |.......#....7.-P|
|
|
000000b0 3d 30 de 68 be 25 c0 72 cc c9 2d 80 41 82 f7 0e |=0.h.%.r..-.A...|
|
|
000000c0 2e 86 0e 07 41 |....A|
|