Commit Graph

49 Commits

Author SHA1 Message Date
Wycheproof Team 6eeb70e249 Automated g4 rollback of changelist 205815425.
Please note that this was created with g4 rollback, but the version number in the Wycheproof file regresses. I'm unsure whether that's desired. The BoringSSL change works for both the old and new files so can be landed without touching Wycheproof if that's better.

*** Reason for rollback ***

Fix to BoringSSL scripts now included.

*** Original change description ***

Adding the curve back to the test cases to avoid failing BoringSSL tests.

***

PiperOrigin-RevId: 205957468
GitOrigin-RevId: c0afaa191d5509050bbea307265b07bca61b4714
2018-07-31 10:48:02 -07:00
Daniel Bleichenbacher 012a83f4fe Adding the curve back to the test cases to avoid failing BoringSSL tests.
PiperOrigin-RevId: 205815425
GitOrigin-RevId: 4b439ccf90d0aa5f2259f9d30253918f5332bc36
2018-07-31 10:47:52 -07:00
Daniel Bleichenbacher 8f2cba4d3f Test vectors version 0.4.12.
Tests using the new test vectors will be added in another CL.

Changes:
AES-GCM has test vectors for modified tags, which were previously missing.
ECDSA has more test vectors for potential arithmetic errors.
  There are no more random test vectors.
Webcrypto has a few test vectors with the bitcoin curve (since some libraries
  want to add this).
DSA and ECDSA have more invalid test vectors with r,s = ((q-1)/2 or q-1).
This is motivated by some weak ElGamal implementation in beecrypt.
ECDH test vectors have some new files where the public key is just a point
using SEC 1 / X9.62 format.
All tests for ASN modifications are removed from ecdh_test.json, so that
this file has a more resonable size. These test vectors are included in
the files ecdh_curve_test.json.
EDDSA has a few more invalid test vectors for malformed signatures.
(I.e. the python implementation in the RFC has a small bug).
Adding test vectors for AES-CCM. (tested against BouncyCastle, which sort of
abuses the JCE interface)
There are some test vectors for RSA-PSS (so far tested with BouncyCastle and boringSSL)
More tests will be added when we have an idea what is actually being used.
PiperOrigin-RevId: 205802874
GitOrigin-RevId: 250ab89370a0dcfc56e887fb185a494f45f9a3f5
2018-07-31 10:47:42 -07:00
Thai Duong f1b3b3429b Fixing Wycheproof ECDH tests. There's no bug, the tests are incorrect.
First, background and history:

In Java, an ECDH public key can be encoded as a SubjectPublicKeyInfo spec [1]. This spec contains the public point, and a named curve or curve parameters [2]. To test ECDH libraries, Wycheproof generates public key specs with modified curve parameters, and checks that the libraries must reject them [3].

Android M and N (and possibly other versions) do not reject said public keys specs. Given a spec Android just takes the field ID, and derives the rest of the parameters. This leads to a somewhat interesting situation: not only Android accepts Wycheproof's modified public key specs, but it also computes the shared secrets correctly and securely. So we changed Wycheproof to accept Android's behavior, and added to each test case the expected shared secret, had the public key spec not been modified.

What went wrong:

The expected shared secrets for "modified prime" and "public key of order 3" test are incorrect. I found that the public key specs (the "public" field in the ecdh_test.json) don't contain the same public point as in other tests. I'm not sure this is intentional, but because the public point is different the expected shared secret must be different too.

Let's look at test case #336. Its expected shared secret is the same as test case #335. Yet two test cases contain two different public points, as shown below (
the public point is the last BIT STRING, it starts with 04):

# Test case 335

  0 304: SEQUENCE {
  4 233:   SEQUENCE {
  7   7:     OBJECT IDENTIFIER '1 2 840 10045 2 1'
 16 221:     SEQUENCE {
 19   1:       INTEGER 1
 22  44:       SEQUENCE {
 24   7:         OBJECT IDENTIFIER '1 2 840 10045 1 1'
 33  33:         INTEGER
       :           00 FF FF FF FF 00 00 00 01 00 00 00 00 00 00 00
       :           00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF
       :           FF
       :         }
 68  68:       SEQUENCE {
 70  32:         OCTET STRING
       :           FF FF FF FF 00 00 00 01 00 00 00 00 00 00 00 00
       :           00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FC
104  32:         OCTET STRING
       :           5A C6 35 D8 AA 3A 93 E7 B3 EB BD 55 76 98 86 BC
       :           65 1D 06 B0 CC 53 B0 F6 3B CE 3C 3E 27 D2 60 4B
       :         }
138  65:       OCTET STRING
       :         04 6B 17 D1 F2 E1 2C 42 47 F8 BC E6 E5 63 A4 40
       :         F2 77 03 7D 81 2D EB 33 A0 F4 A1 39 45 D8 98 C2
       :         96 4F E3 42 E2 FE 1A 7F 9B 8E E7 EB 4A 7C 0F 9E
       :         16 2B CE 33 57 6B 31 5E CE CB B6 40 68 37 BF 51
       :         F5
205  33:       INTEGER
       :         00 FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF
       :         FF BC E6 FA AD A7 17 9E 84 F3 B9 CA C2 FC 63 25
       :         51
       :       }
       :     }
240  66:   BIT STRING
       :     04 15 10 26 4C 18 9C 3D 52 3F F9 91 6A BD 70 69
       :     EF A6 96 8D 8D C7 DD B6 45 7D 78 69 B5 3E A6 0C
       :     DC FA FB 7E D4 78 6D A1 5D 29 EE 59 25 6F 53 6D
       :     A3 57 5A 48 88 C1 BB 0A 95 B2 56 F4 A7 E9 FD 76
       :     4A
       :   }

# Test case 336:

  0 307: SEQUENCE {
  4 236:   SEQUENCE {
  7   7:     OBJECT IDENTIFIER '1 2 840 10045 2 1'
 16 224:     SEQUENCE {
 19   1:       INTEGER 1
 22  44:       SEQUENCE {
 24   7:         OBJECT IDENTIFIER '1 2 840 10045 1 1'
 33  33:         INTEGER
       :           00 FD 09 10 59 A6 89 36 35 F9 00 E9 44 9D 63 F5
       :           72 B2 AE BC 4C FF 7B 4E 5E 33 F1 B2 00 E8 BB C1
       :           45
       :         }
 68  68:       SEQUENCE {
 70  32:         OCTET STRING
       :           02 F6 EF A5 59 76 C9 CB 06 FF 16 BB 62 9C 0A 8D
       :           4D 51 43 B4 00 84 B1 A1 CC 0E 4D FF 17 44 3E B7
104  32:         OCTET STRING
       :           5A C6 35 D8 AA 3A 93 E7 B3 EB BD 55 76 98 86 BC
       :           65 1D 06 B0 CC 53 B0 F6 3B CE 3C 3E 27 D2 60 4B
       :         }
138  65:       OCTET STRING
       :         04 00 00 00 00 00 00 00 00 00 00 06 59 7F A9 4B
       :         1F D9 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       :         02 1B 8C 7D D7 7F 9A 95 62 79 22 EC EE FE A7 3F
       :         02 8F 1E C9 5B A9 B8 FA 95 A3 AD 24 BD F9 FF F4
       :         14
205  33:       INTEGER
       :         00 FF FF FF FF 00 00 00 00 FF FF FF FF FF FF FF
       :         FF BC E6 FA AD A7 17 9E 84 F3 B9 CA C2 FC 63 25
       :         51
240   1:       INTEGER 1
       :       }
       :     }
243  66:   BIT STRING
       :     04 00 00 00 00 00 00 00 00 00 00 06 59 7F A9 4B
       :     1F D9 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       :     02 1B 8C 7D D7 7F 9A 95 62 79 22 EC EE FE A7 3F
       :     02 8F 1E C9 5B A9 B8 FA 95 A3 AD 24 BD F9 FF F4
       :     14
       :   }

[1] https://tools.ietf.org/html/rfc5280#section-4.1.2.7.
[2] https://tools.ietf.org/html/rfc3279#section-2.3.5
[3] Many libraries don't, and usually that leads to vulnerabilities that leak the private key.

PiperOrigin-RevId: 204515375
GitOrigin-RevId: 26b6eb30145d94209b9d828db7c6a0b0ed6be695
2018-07-31 10:47:33 -07:00
Thai Duong abb656f1a3 Release empty IV tests.
PiperOrigin-RevId: 204463594
GitOrigin-RevId: 105ad708ed85d47635e3859b0a4e2b062c154033
2018-07-31 10:47:24 -07:00
Wycheproof Team 202ec7ef23 Format .bzl files with buildifier
This is a part of a large-scale change: go/lsc-format-bzl-files . All .bzl files are being formatted with buildifier.

To format a file manually run `buildifier path/to/file.bzl`. Integration with `g4 fix` will be available later, but you can try using `g4 fix --format=bzl`.

Tested:
    tap_presubmit
    Some tests failed; test failures are believed to be unrelated to this CL

BEGIN_PUBLIC
Format .bzl files with buildifier
END_PUBLIC

PiperOrigin-RevId: 203461813
GitOrigin-RevId: 079b58e5340b57819c361af79e4b820f4c66e590
2018-07-31 10:47:15 -07:00
Daniel Bleichenbacher f22bfc7c3d This CL is mainly documenting that Oracle is not fixing CipherInputStream
and CipherOutputStream. The test code is slightly refactored.

PiperOrigin-RevId: 203082697
GitOrigin-RevId: aa26a3d92f94b5f79780ebc2d0674f47ca0d223d
2018-07-31 10:47:03 -07:00
Thai Duong 2904be69e9 Stop scrubbing @NoPresubmitTest annotation to make it easier to import external changes.
Also fixing a typo in Java transformation rules.

PiperOrigin-RevId: 199870545
GitOrigin-RevId: b2bf283c8f782205598503e14b0f13278ac0b4db
2018-06-27 12:04:44 -04:00
Daniel Bleichenbacher b9b3b2119c Adding JSON test vectors for version 0.4.6.
This CL only adds test vectors.
Changes using the new test vectors are in CL 199130745.

There are the following changes to version 0.4:
ECDSA test vectors with a valid signature but non-DER encoding
have "result":"invalid" and have the flag "BER".

Version 0.4.4 has some additional test vectors:
- Tests for invalid encoding of the INTEGER 0 (i.e. "0200" instead
of "020100")
- Truncation after the ASN tag.
- ECDH test vectors now include shared secrets in invalid test vectors.
  This allows to check if an implementation is just sloppy at comparing
  public keys (i.e. ignoring parameters) or vulnerable (i.e. using
  modified parameters for ECDH computation)
- More tests vectors like the unexplained test vector in b/74209208
- ECDH now has tests vectors where public and private keys are
  on different, but isomorphic curves. The result is invalid, since
  the encoding of the shared secret is undefined.
- ECDH has test vectors with modified ASN. Again the shared secret
  computed with the original public key is included so that it is
  a bit easier to distinguish between serious and non-serious cases.
- Some third party test cases were added to all files. They are
  removed.

Version 0.4.5:
- adds more test vectors for ECDSA.
- adds more test vectors for RSA signatures and splits the signatures
  into more files, sorted by key size and hash.
Version 0.4.6:
- adds an uncompressed encoding to EC keys.
- rsa_signature_test.json now contains more keys for size 1024 to 4096.
  Most keys only contain a small number of tests.
  More extensive tests are done with a 2048 bit key only.

New bugs:
BouncyCastle and ConsCrypt both accepts some invalid keys (with
additional garbage) as valid. These bugs are currently silenced
by marking the test vectors as acceptable. I.e. the first goal is
to verify that invalid ECDH keys cannot be used to find the private
key.

PiperOrigin-RevId: 199611433
GitOrigin-RevId: f1f99cc52617e18224ec98f84dcaa55c42df9b46
2018-06-27 12:04:31 -04:00
Wycheproof Team 127d8022a2 Integrate test fix from GitHub PR
https://github.com/google/wycheproof/pull/45

PiperOrigin-RevId: 199395510
GitOrigin-RevId: 1ad1df83ae6f0ae915cdfd3174fa9cb755961980
2018-06-27 12:04:19 -04:00
Juraj Somorovsky eb9f7b59e6 Added some recent information about SunEC and Utimaco HSM problems.
Importing https://github.com/google/wycheproof/pull/50.

PiperOrigin-RevId: 195427107
GitOrigin-RevId: 39bbc63b20d5d08c5457bd338c90f45370047831
2018-06-27 12:04:08 -04:00
Juraj Somorovsky 0329f5b751 Some documentation and extra information (#50)
* Add more information about the used Java Runtime and the tested provider version

* Added some recent information about SunEC and Utimaco HSM problems
2018-04-27 14:36:45 -07:00
Daniel Bleichenbacher 933e2e10aa Adding a test for key wrapping:
This supports RFC 3394 and RFC 5649,
which is also described in NIST SP 800 38f.

I also have a mini analysis of the primitive:
If one cares about distinguishing attacks then
there is an attack with a somewhat smaller complexity
than what NIST claims in their standard:
https://docs.google.com/document/d/1oH36v6SNdff5tkydC75EnqRyqqgHbXR4hy_SMPzwqVU/edit?usp=sharing
But even if one cares about these attacks then the key
wrappings are nowhere comparable to the attacks possible against e.g.
AES-GCM.

PiperOrigin-RevId: 192747615
GitOrigin-RevId: 0bebc767022ba3053c1d0391378d5c0b32b7f5be
2018-04-27 14:10:27 -07:00
Thai Duong 16b1d26f28 Fixing tests that depend on JSON test vectors.
Also fixing doc links in open source (see #48).

PiperOrigin-RevId: 191699981
GitOrigin-RevId: e5a0caaf2d794dce378d1c4efefe36a36d2048f7
2018-04-05 02:35:23 -04:00
Lucas Garron 6321e25685 Fix bug brag sheet link in main README. (#48) 2018-04-04 20:24:25 -07:00
Thai Duong 0569f074f3 Fixing the open source build.
PiperOrigin-RevId: 191640973
GitOrigin-RevId: e1253df8c8c78a305d746a48778e1aed07cd48fe
2018-04-04 13:54:59 -07:00
Thai Duong 31387e2cd5 Project import generated by Copybara.
PiperOrigin-RevId: 191113399
GitOrigin-RevId: cfebd59d1f086e907f468004c7d033199d116fad
2018-04-04 13:54:50 -07:00
Thai Duong 72412ae03c Move Wycheproof to third_party/wycheproof. Each language will have its own subdirectory.
Approved by third-party-help@: https://groups.google.com/a/google.com/forum/#!topic/third-party-help/K-JKmnxAGoU.

PiperOrigin-RevId: 126106900
GitOrigin-RevId: cb4418c62d6412f61134cbee74074bdbd2cd3657
2018-04-04 13:54:42 -07:00
Brandon Weeks 62da332257 Updates for release of BouncyCastle 1.59 (#45) 2018-03-21 16:34:25 -07:00
Thai Duong 39b8eed940 Using closure rules at master, this helps prevent issues like #41. (#43) 2018-01-09 16:57:34 -08:00
wwjd228 b577f8e8cc Add a tag of @Test in AesEaxTest.java (#42)
Add a tag of @Test in AesEaxTest.java to avoid the build error.
2017-12-21 11:18:26 -08:00
Jordan Mews cf0eace1f5 Updates for release of BouncyCastle 1.57/1.58 (#37)
- add maven entry for BC 1.57/1.58 and update the versions range
2017-08-31 09:51:58 -07:00
Jordan Mews 9cd6c67936 Fixed #38 - JUnit3 runner is being used instead of JUnit4 (#39)
- Remove `extends TestCase` which triggered usage of the JUnit3 runner
- Replace `import static org.junit.Assert.assertArrayEquals;` with `import static org.junit.Assert.*;`
- Replace `import junit.framework.TestCase;` with `import org.junit.Test;`
- Annotate all existing test methods (that are prefixed with 'test' and have no args) with `@Test`
2017-08-31 09:12:02 -07:00
Thanh Bui f755ff0279 Add Web Crypto API tests and Java tests using test vectors (#35)
* Add test vectors

* Add Java tests using test vectors

* Add Web Crypto API tests.
2017-07-27 11:12:16 -07:00
bdonlan 730842ac8c Add tests for partially-overlapping input/output buffers (#29)
update/doFinal are required to be "copy-safe". From the javadoc:

    Note: this method should be copy-safe, which means the input and output
    buffers can reference the same block of memory and no unprocessed input
    data is overwritten when the result is copied into the output buffer.

However many implementations of JCE methods do not implement this property in
all cases. Notably, BouncyCastle fails this test on arrays, and the built-in
OpenJDK providers fail when the input bytebuffer is either a read-only
array-backed byte buffer, or if the buffers are direct buffers. For SunJCE,
this has been acknowledged publicly by Oracle at
https://bugs.openjdk.java.net/browse/JDK-8181386 .

These new tests verify correct overlapping buffer handling for AES/GCM
specifically; as future work, it would be good to generalize these tests for
other ciphers and modes.
2017-06-13 16:43:50 -07:00
quannguyentm 9c44da8d18 Release a few more bugs. (#33) 2017-06-13 16:18:15 -07:00
quannguyentm db3e019bf2 Move init into the loop. (#32)
The current code fails to initialize the cipher c after a c.doFinal()
fails. According to JCE documentation, a cipher is in an undefined state
after throwing an exception.
2017-06-07 17:12:10 -07:00
quannguyentm 7cb50d31f6 Fix format bugs.md (#31)
* Fix format bugs.md

The internal Google format doesn't seem to work with github.

* Update bugs.md
2017-06-05 10:41:17 -07:00
quannguyentm d16e6915e5 Bugs found by Wycheproof Project. (#30)
There are bugs that are not publishable yet.
2017-06-02 15:23:07 -07:00
Juraj Somorovsky c89a32e2ce RSA decryption tests with specific PKCS#1 valid/inalid values (#27)
* RSA decryption tests with specific PKCS#1 valid/inalid values

* Typo (Hopefully nobody noticed this :-/)
2017-02-23 23:19:02 -08:00
quannguyentm e6b88724b3 Disable @SlowTest testWrappedAroundCounter because bazel ignores test annotation (#28)
This is a workaround for #26.
2017-02-21 23:27:34 -08:00
Thai Duong 7dfe46ba87 Typo and style fixes (#25) 2017-02-07 17:01:34 -08:00
Thai Duong 62e1bf0ec4 Fix #23 and #2 (#24) 2017-02-03 11:16:18 -08:00
Peter Dettman fa01b5aeae Updates for release of BouncyCastle 1.56 (#8)
- add maven entry for BC 1.56 and update the versions range
- DHIES weak crypto tests now pass if algs not even supported
- some ECIES entries moved to the invalid list
- ECIES decryption init calls fixed to pass the correct parameters
- EciesTest.testModifyPoint now expects GeneralSecurityException
2017-02-03 10:49:56 -08:00
Thai Duong 06d73e0349 Suppress more warnings, sighed (#22) 2017-02-01 16:19:15 -08:00
Thai Duong 9130b7625f Fix ErrorProne build errors (#21)
* Fix ErrorProne build errors
2017-02-01 16:04:21 -08:00
Thai Duong f2f6a309e2 Set tags=[manual] for *Local test targets, thus exclude them from bazel build ... (#20) 2017-02-01 15:49:11 -08:00
Ange Albertini eef0c4262e typos (#1) 2017-02-01 11:39:49 -08:00
Alex Lau ca5bdb45ba Typo (#14) 2017-02-01 11:15:24 -08:00
Thai Duong 397bfb49f8 Google -> GitHub Sync, 1 Feb 2017 (#19)
* Removing duplicates from BigIntegerTest.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142548323

* Remove @NoPresubmitCheck from testModifiedPublic() and testModifiedPublicSpec(). The corresponding bug was fixed in BC 1.55 or BC 1.56.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142561682

* minor typos

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=142743772

* Regenerating the test vectors for ECDSA:
- this adds more comments for bugtypes and modifications or the signatures.
- fixes some ugly formatting.
- adds some additional test vectors.

There are no new bugs.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144619819

* Regenerating DSA test vectors:
This adds a few more test vectors.
The test vectors are now divided between test vectors with valid BER encodings
and test vectors with invalid DER encodings.
The description of the test vector better describes what was modified.

Also fixing issue #17 on Github: testVectors in DsaTest not using the message parameter

There are no changes to the presubmit tests. Tests that can be enabled because of the
Oracles security update will be added in another CL.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144814889

* Regenerating test vectors for EcdhTest.java

Merging a test with small order into the test vectors.
Fixing ASN encoding of 0 (from 0200 to 020100, i.e. length must be > 0).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144815129

* Regenerating RSA signatures.

Adding test vectors that were removed because of b/31575502. Oracle fixes this with CVE-2016-5547.

Changing ASN tags with value 0x50 to 0x30 (0x50 would be something like sequence of sequence but does not exist), hence the old vectors are unlikely to cause problems.

Adding more modifications of OIDs. The new vectors unpack the OIDs and change the nodes.
(E.g. the OID for sha256 is the hexadecimal string "608648016503040201" which is an
ASN encoding of "2.16.840.1.101.3.4.2.1". The new test vectors include invalid encoding,
encodings with additional nodes, deleted nodes and nodes that are changed to large integers)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=144846826

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145060646

* Removing presubmit restrictions for tests that have been fixed internally and upstream.
Mainly these are tests with CVEs that were announced during the Jan 17 security update
by Oracle.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145397539

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145418516

* Adding the CVE numbers from Oracles Jan 17 security update to the documentation.
Minor changes to some test vectors: Some of the garbage added to the ASN encoding
was itself incorrect and has been replaced.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145650774

* ECDSA MODIFIED_SIGNATURES should be public now.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146186539
2017-02-01 10:45:16 -08:00
Emilia Käsper b898a62f3f Option to test a local BouncyCastle jar (#16)
Resolves Github issue #4
2017-01-11 17:57:11 -08:00
Thai Duong 189df20960 Better usage instruction and add BUILD targets for OpenJDK tests. 2016-12-13 19:30:49 -08:00
Thai Duong 223332fde6 Some last minute changes before public announcement. 2016-12-13 03:17:31 -08:00
Thai Duong 75efe2b665 Final sync before public release. 2016-12-07 01:17:05 -08:00
Thai Duong 625f91ce32 Add CREDITS 2016-12-04 21:32:40 -08:00
Thai Duong b1b22bc6c0 Fix more typos in README.md and rename CONTRIBUTING to CONTRIBUTING.md so that it is rendered correctly. 2016-12-04 19:23:25 -08:00
Thai Duong 0a3269d0f9 Fix some typos and links in README 2016-11-30 18:27:49 -08:00
Emilia Kasper f7ecb0dfad Initial GitHub export 2016-11-30 17:59:14 -08:00
Emilia Kasper c662a0ac90 Add a placeholder README.md 2016-10-13 11:34:15 +02:00