xref: /aosp_15_r20/external/wycheproof/doc/index.md (revision 3d322d526be0ef039eebde10aa6ae75db8cc3a3d)
1*3d322d52SAndroid Build Coastguard Worker# Project Wycheproof
2*3d322d52SAndroid Build Coastguard Worker
3*3d322d52SAndroid Build Coastguard WorkerThis page describes the goals and strategies of project Wycheproof. See
4*3d322d52SAndroid Build Coastguard Worker[README](../README.md) for an introduction to the project.
5*3d322d52SAndroid Build Coastguard Worker
6*3d322d52SAndroid Build Coastguard Worker## Defense in depth
7*3d322d52SAndroid Build Coastguard Worker
8*3d322d52SAndroid Build Coastguard WorkerThere are a number of tests where we check for expected behaviour
9*3d322d52SAndroid Build Coastguard Workerrather than exploitability. Examples:
10*3d322d52SAndroid Build Coastguard Worker
11*3d322d52SAndroid Build Coastguard Worker* default values: we expect that default values are reasonable and correspond
12*3d322d52SAndroid Build Coastguard Worker  to recommendations by current standards. Concretely, in 2016 it is not OK
13*3d322d52SAndroid Build Coastguard Worker  if an RSA key generation uses 1024 bits as default or digital signatures
14*3d322d52SAndroid Build Coastguard Worker  use SHA-1 as default.
15*3d322d52SAndroid Build Coastguard Worker* timing attacks: any timing that relation between keys (or other sensitive)
16*3d322d52SAndroid Build Coastguard Worker  data and the measured time fails the test. However tests are set up
17*3d322d52SAndroid Build Coastguard Worker  such that too much noise during the test can prevent that a relation
18*3d322d52SAndroid Build Coastguard Worker  is detected.
19*3d322d52SAndroid Build Coastguard Worker* wrong exceptions: The JCE interface often specifies the exceptions that
20*3d322d52SAndroid Build Coastguard Worker  should be thrown when the input is invalid. We expect the specified
21*3d322d52SAndroid Build Coastguard Worker  exceptions in the tests.
22*3d322d52SAndroid Build Coastguard Worker* leaking information through exceptions: While it is a good practice to not
23*3d322d52SAndroid Build Coastguard Worker  return detailed logs to a sender, we consider text in exceptions as
24*3d322d52SAndroid Build Coastguard Worker  information that a potential attacker can learn. For example padding
25*3d322d52SAndroid Build Coastguard Worker  failures during decryption should not contain information about the
26*3d322d52SAndroid Build Coastguard Worker  reason why a decryption failed.
27*3d322d52SAndroid Build Coastguard Worker* RSA PKCS #1 signatures: If a signature verification allows signatures
28*3d322d52SAndroid Build Coastguard Worker  with lots of modifications, then RSA signatures can be forged for small
29*3d322d52SAndroid Build Coastguard Worker  public exponents. Tests do not measure how many bytes can be modified.
30*3d322d52SAndroid Build Coastguard Worker  Any accepted modification of the PKCS #1 padding fails the test.
31*3d322d52SAndroid Build Coastguard Worker
32*3d322d52SAndroid Build Coastguard Worker## Compatibility between providers
33*3d322d52SAndroid Build Coastguard Worker
34*3d322d52SAndroid Build Coastguard WorkerOne of the goals of Wycheproof is to test for compatibility issues.
35*3d322d52SAndroid Build Coastguard WorkerSwitching JCE providers should not introduce vulnerabilities simply because
36*3d322d52SAndroid Build Coastguard Workerthe solution was developed by another provider.
37*3d322d52SAndroid Build Coastguard Worker
38*3d322d52SAndroid Build Coastguard WorkerAn example for this was the following observation: When using AES-GCM then
39*3d322d52SAndroid Build Coastguard Workerjavax.crypto.CipherInputStream worked sort of with JCE and
40*3d322d52SAndroid Build Coastguard Workerorg.bouncycastle.jcajce.io.CipherInputStream.java worked with BouncyCastle.
41*3d322d52SAndroid Build Coastguard WorkerHowever, authentication was skipped in some cases when
42*3d322d52SAndroid Build Coastguard Workerjavax.crypto.CipherInputStream was used with BouncyCastle.
43*3d322d52SAndroid Build Coastguard Worker
44*3d322d52SAndroid Build Coastguard Worker## Comparing cryptographic libraries is not a primary goal
45*3d322d52SAndroid Build Coastguard Worker
46*3d322d52SAndroid Build Coastguard WorkerBecause of the strategies mentioned above we expect that a comparison of
47*3d322d52SAndroid Build Coastguard Workercryptographic libraries based on the bugs found would be biased:
48*3d322d52SAndroid Build Coastguard Worker
49*3d322d52SAndroid Build Coastguard Worker* Libraries used internally in Google get more attention.
50*3d322d52SAndroid Build Coastguard Worker  Serious vulnerabilities in these libraries should be fixed at the time the
51*3d322d52SAndroid Build Coastguard Worker  tests are added to Wycheproof.  On the other hand it is also likely that
52*3d322d52SAndroid Build Coastguard Worker  tests find a larger number of bugs in these libraries when old versions are
53*3d322d52SAndroid Build Coastguard Worker  tested.
54*3d322d52SAndroid Build Coastguard Worker* Tests often check for expected behaviour and compatibility.
55*3d322d52SAndroid Build Coastguard Worker  Expected behaviour is often defined by a prominent library.
56*3d322d52SAndroid Build Coastguard Worker  Pointing out such problems can therefore penalize smaller third party
57*3d322d52SAndroid Build Coastguard Worker  libraries.
58*3d322d52SAndroid Build Coastguard Worker* We are working toward covering as many potential vulnerabilities as possible
59*3d322d52SAndroid Build Coastguard Worker  with test vectors, because this simplifies porting the tests to other
60*3d322d52SAndroid Build Coastguard Worker  languages or interfaces. Thus a single test case can cover multiple
61*3d322d52SAndroid Build Coastguard Worker  vulnerabilities.
62*3d322d52SAndroid Build Coastguard Worker
63*3d322d52SAndroid Build Coastguard WorkerWe are not trying to remove this bias when this interferes with more important
64*3d322d52SAndroid Build Coastguard Workergoals such as early reporting.
65*3d322d52SAndroid Build Coastguard WorkerHence we are reluctant to publish comparisons.
66*3d322d52SAndroid Build Coastguard Worker
67*3d322d52SAndroid Build Coastguard Worker
68*3d322d52SAndroid Build Coastguard Worker## Thoughts on the design of cryptographic libraries
69*3d322d52SAndroid Build Coastguard Worker
70*3d322d52SAndroid Build Coastguard WorkerWe should promote robust interfaces with the goal to simplify
71*3d322d52SAndroid Build Coastguard Workerthe use of the library, code reviews of applications using the
72*3d322d52SAndroid Build Coastguard Workerlibrary and testing the library.
73*3d322d52SAndroid Build Coastguard Worker
74*3d322d52SAndroid Build Coastguard Worker* When cryptographic primitives require randomness then the random
75*3d322d52SAndroid Build Coastguard Worker  numbers should be chosen by the library. It shouldn't be possible
76*3d322d52SAndroid Build Coastguard Worker  for a user to provide randomness. If the library itself chooses the
77*3d322d52SAndroid Build Coastguard Worker  randomness then it is possible (at least to some degree) to check
78*3d322d52SAndroid Build Coastguard Worker  that the random number generation is appropriate for the primitive.
79*3d322d52SAndroid Build Coastguard Worker  If the user can provide the randomness then it is not possible to
80*3d322d52SAndroid Build Coastguard Worker  catch this in our tests.
81