Speed up DHPublicKeyTest; make DHPrivateKeyTest consistent.

DHPublicKeyTest.test_getParams() was generating 1024bit Diffie-Hellman
parameters; this operation is very slow and very variable, often taking
more than the 5 minutes allowed before the test times out.

In practice, parameters are not generated at random, especially
not on a mobile device; instead, in practice well-known parameters
are picked rather than generating a random one.

To make this the test both more realistic and faster to run, this
CL splits up DHPublicKeyTest.test_getParams() into two tests:

 1.) generate a 192bit, rather than 1024bit, parameters
 2.) use hard coded 2048bit parameters to generate keys.
     The 2048-bit group from RFC 7919, Appendix A, was used.

The same is done to DHPrivateKeyTest.test_getParams(), which was
previously only doing 1.).

Historical context:

DHPrivateKeyTest historically had observed the same problems;
therefore, commit 8bc378b1cec65bc06766a14a9cc575fec931b418 in
Feb 2011 changed it to only use 192bit, i.e. do 1.);
DHPublicKeyTest was not touched at that time.

DHPublicKeyTest's timeout was increased in June 2015 (cts commit
d16b864e9537e172436bfb8a5de76e9e49fcea35) but that broke with
the switch to CTSv2.

Test: Check that DHPrivateKeyTest and DHPublicKeyTest pass
      within a few seconds on a Nexus 6P.
Bug: 30741591

Change-Id: I6af0a70761557e4f4c1641cad7807d2211553e25
2 files changed