David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2016, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #include <vector> |
| 16 | |
| 17 | #include <assert.h> |
| 18 | #include <string.h> |
| 19 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 20 | #include <openssl/bytestring.h> |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 21 | #include <openssl/crypto.h> |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 22 | #include <openssl/digest.h> |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 23 | #include <openssl/err.h> |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 24 | #include <openssl/pem.h> |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 25 | #include <openssl/pool.h> |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 26 | #include <openssl/x509.h> |
| 27 | |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 28 | #include "../internal.h" |
| 29 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 30 | |
| 31 | static const char kCrossSigningRootPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 32 | "-----BEGIN CERTIFICATE-----\n" |
| 33 | "MIICcTCCAdqgAwIBAgIIagJHiPvE0MowDQYJKoZIhvcNAQELBQAwPDEaMBgGA1UE\n" |
| 34 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxHjAcBgNVBAMTFUNyb3NzLXNpZ25pbmcgUm9v\n" |
| 35 | "dCBDQTAgFw0xNTAxMDEwMDAwMDBaGA8yMTAwMDEwMTAwMDAwMFowPDEaMBgGA1UE\n" |
| 36 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxHjAcBgNVBAMTFUNyb3NzLXNpZ25pbmcgUm9v\n" |
| 37 | "dCBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwo3qFvSB9Zmlbpzn9wJp\n" |
| 38 | "ikI75Rxkatez8VkLqyxbOhPYl2Haz8F5p1gDG96dCI6jcLGgu3AKT9uhEQyyUko5\n" |
| 39 | "EKYasazSeA9CQrdyhPg0mkTYVETnPM1W/ebid1YtqQbq1CMWlq2aTDoSGAReGFKP\n" |
| 40 | "RTdXAbuAXzpCfi/d8LqV13UCAwEAAaN6MHgwDgYDVR0PAQH/BAQDAgIEMB0GA1Ud\n" |
| 41 | "JQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAPBgNVHRMBAf8EBTADAQH/MBkGA1Ud\n" |
| 42 | "DgQSBBBHKHC7V3Z/3oLvEZx0RZRwMBsGA1UdIwQUMBKAEEcocLtXdn/egu8RnHRF\n" |
| 43 | "lHAwDQYJKoZIhvcNAQELBQADgYEAnglibsy6mGtpIXivtlcz4zIEnHw/lNW+r/eC\n" |
| 44 | "CY7evZTmOoOuC/x9SS3MF9vawt1HFUummWM6ZgErqVBOXIB4//ykrcCgf5ZbF5Hr\n" |
| 45 | "+3EFprKhBqYiXdD8hpBkrBoXwn85LPYWNd2TceCrx0YtLIprE2R5MB2RIq8y4Jk3\n" |
| 46 | "YFXvkME=\n" |
| 47 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 48 | |
| 49 | static const char kRootCAPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 50 | "-----BEGIN CERTIFICATE-----\n" |
| 51 | "MIICVTCCAb6gAwIBAgIIAj5CwoHlWuYwDQYJKoZIhvcNAQELBQAwLjEaMBgGA1UE\n" |
| 52 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxEDAOBgNVBAMTB1Jvb3QgQ0EwIBcNMTUwMTAx\n" |
| 53 | "MDAwMDAwWhgPMjEwMDAxMDEwMDAwMDBaMC4xGjAYBgNVBAoTEUJvcmluZ1NTTCBU\n" |
| 54 | "RVNUSU5HMRAwDgYDVQQDEwdSb290IENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB\n" |
| 55 | "iQKBgQDpDn8RDOZa5oaDcPZRBy4CeBH1siSSOO4mYgLHlPE+oXdqwI/VImi2XeJM\n" |
| 56 | "2uCFETXCknJJjYG0iJdrt/yyRFvZTQZw+QzGj+mz36NqhGxDWb6dstB2m8PX+plZ\n" |
| 57 | "w7jl81MDvUnWs8yiQ/6twgu5AbhWKZQDJKcNKCEpqa6UW0r5nwIDAQABo3oweDAO\n" |
| 58 | "BgNVHQ8BAf8EBAMCAgQwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMA8G\n" |
| 59 | "A1UdEwEB/wQFMAMBAf8wGQYDVR0OBBIEEEA31wH7QC+4HH5UBCeMWQEwGwYDVR0j\n" |
| 60 | "BBQwEoAQQDfXAftAL7gcflQEJ4xZATANBgkqhkiG9w0BAQsFAAOBgQDXylEK77Za\n" |
| 61 | "kKeY6ZerrScWyZhrjIGtHFu09qVpdJEzrk87k2G7iHHR9CAvSofCgEExKtWNS9dN\n" |
| 62 | "+9WiZp/U48iHLk7qaYXdEuO07No4BYtXn+lkOykE+FUxmA4wvOF1cTd2tdj3MzX2\n" |
| 63 | "kfGIBAYhzGZWhY3JbhIfTEfY1PNM1pWChQ==\n" |
| 64 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 65 | |
| 66 | static const char kRootCrossSignedPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 67 | "-----BEGIN CERTIFICATE-----\n" |
| 68 | "MIICYzCCAcygAwIBAgIIAj5CwoHlWuYwDQYJKoZIhvcNAQELBQAwPDEaMBgGA1UE\n" |
| 69 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxHjAcBgNVBAMTFUNyb3NzLXNpZ25pbmcgUm9v\n" |
| 70 | "dCBDQTAgFw0xNTAxMDEwMDAwMDBaGA8yMTAwMDEwMTAwMDAwMFowLjEaMBgGA1UE\n" |
| 71 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxEDAOBgNVBAMTB1Jvb3QgQ0EwgZ8wDQYJKoZI\n" |
| 72 | "hvcNAQEBBQADgY0AMIGJAoGBAOkOfxEM5lrmhoNw9lEHLgJ4EfWyJJI47iZiAseU\n" |
| 73 | "8T6hd2rAj9UiaLZd4kza4IURNcKSckmNgbSIl2u3/LJEW9lNBnD5DMaP6bPfo2qE\n" |
| 74 | "bENZvp2y0Habw9f6mVnDuOXzUwO9SdazzKJD/q3CC7kBuFYplAMkpw0oISmprpRb\n" |
| 75 | "SvmfAgMBAAGjejB4MA4GA1UdDwEB/wQEAwICBDAdBgNVHSUEFjAUBggrBgEFBQcD\n" |
| 76 | "AQYIKwYBBQUHAwIwDwYDVR0TAQH/BAUwAwEB/zAZBgNVHQ4EEgQQQDfXAftAL7gc\n" |
| 77 | "flQEJ4xZATAbBgNVHSMEFDASgBBHKHC7V3Z/3oLvEZx0RZRwMA0GCSqGSIb3DQEB\n" |
| 78 | "CwUAA4GBAErTxYJ0en9HVRHAAr5OO5wuk5Iq3VMc79TMyQLCXVL8YH8Uk7KEwv+q\n" |
| 79 | "9MEKZv2eR/Vfm4HlXlUuIqfgUXbwrAYC/YVVX86Wnbpy/jc73NYVCq8FEZeO+0XU\n" |
| 80 | "90SWAPDdp+iL7aZdimnMtG1qlM1edmz8AKbrhN/R3IbA2CL0nCWV\n" |
| 81 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 82 | |
| 83 | static const char kIntermediatePEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 84 | "-----BEGIN CERTIFICATE-----\n" |
| 85 | "MIICXjCCAcegAwIBAgIJAKJMH+7rscPcMA0GCSqGSIb3DQEBCwUAMC4xGjAYBgNV\n" |
| 86 | "BAoTEUJvcmluZ1NTTCBURVNUSU5HMRAwDgYDVQQDEwdSb290IENBMCAXDTE1MDEw\n" |
| 87 | "MTAwMDAwMFoYDzIxMDAwMTAxMDAwMDAwWjA2MRowGAYDVQQKExFCb3JpbmdTU0wg\n" |
| 88 | "VEVTVElORzEYMBYGA1UEAxMPSW50ZXJtZWRpYXRlIENBMIGfMA0GCSqGSIb3DQEB\n" |
| 89 | "AQUAA4GNADCBiQKBgQC7YtI0l8ocTYJ0gKyXTtPL4iMJCNY4OcxXl48jkncVG1Hl\n" |
| 90 | "blicgNUa1r9m9YFtVkxvBinb8dXiUpEGhVg4awRPDcatlsBSEBuJkiZGYbRcAmSu\n" |
| 91 | "CmZYnf6u3aYQ18SU8WqVERPpE4cwVVs+6kwlzRw0+XDoZAczu8ZezVhCUc6NbQID\n" |
| 92 | "AQABo3oweDAOBgNVHQ8BAf8EBAMCAgQwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG\n" |
| 93 | "AQUFBwMCMA8GA1UdEwEB/wQFMAMBAf8wGQYDVR0OBBIEEIwaaKi1dttdV3sfjRSy\n" |
| 94 | "BqMwGwYDVR0jBBQwEoAQQDfXAftAL7gcflQEJ4xZATANBgkqhkiG9w0BAQsFAAOB\n" |
| 95 | "gQCvnolNWEHuQS8PFVVyuLR+FKBeUUdrVbSfHSzTqNAqQGp0C9fk5oCzDq6ZgTfY\n" |
| 96 | "ESXM4cJhb3IAnW0UM0NFsYSKQJ50JZL2L3z5ZLQhHdbs4RmODGoC40BVdnJ4/qgB\n" |
| 97 | "aGSh09eQRvAVmbVCviDK2ipkWNegdyI19jFfNP5uIkGlYg==\n" |
| 98 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 99 | |
| 100 | static const char kIntermediateSelfSignedPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 101 | "-----BEGIN CERTIFICATE-----\n" |
| 102 | "MIICZjCCAc+gAwIBAgIJAKJMH+7rscPcMA0GCSqGSIb3DQEBCwUAMDYxGjAYBgNV\n" |
| 103 | "BAoTEUJvcmluZ1NTTCBURVNUSU5HMRgwFgYDVQQDEw9JbnRlcm1lZGlhdGUgQ0Ew\n" |
| 104 | "IBcNMTUwMTAxMDAwMDAwWhgPMjEwMDAxMDEwMDAwMDBaMDYxGjAYBgNVBAoTEUJv\n" |
| 105 | "cmluZ1NTTCBURVNUSU5HMRgwFgYDVQQDEw9JbnRlcm1lZGlhdGUgQ0EwgZ8wDQYJ\n" |
| 106 | "KoZIhvcNAQEBBQADgY0AMIGJAoGBALti0jSXyhxNgnSArJdO08viIwkI1jg5zFeX\n" |
| 107 | "jyOSdxUbUeVuWJyA1RrWv2b1gW1WTG8GKdvx1eJSkQaFWDhrBE8Nxq2WwFIQG4mS\n" |
| 108 | "JkZhtFwCZK4KZlid/q7dphDXxJTxapURE+kThzBVWz7qTCXNHDT5cOhkBzO7xl7N\n" |
| 109 | "WEJRzo1tAgMBAAGjejB4MA4GA1UdDwEB/wQEAwICBDAdBgNVHSUEFjAUBggrBgEF\n" |
| 110 | "BQcDAQYIKwYBBQUHAwIwDwYDVR0TAQH/BAUwAwEB/zAZBgNVHQ4EEgQQjBpoqLV2\n" |
| 111 | "211Xex+NFLIGozAbBgNVHSMEFDASgBCMGmiotXbbXVd7H40UsgajMA0GCSqGSIb3\n" |
| 112 | "DQEBCwUAA4GBALcccSrAQ0/EqQBsx0ZDTUydHXXNP2DrUkpUKmAXIe8McqIVSlkT\n" |
| 113 | "6H4xz7z8VRKBo9j+drjjtCw2i0CQc8aOLxRb5WJ8eVLnaW2XRlUqAzhF0CrulfVI\n" |
| 114 | "E4Vs6ZLU+fra1WAuIj6qFiigRja+3YkZArG8tMA9vtlhTX/g7YBZIkqH\n" |
| 115 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 116 | |
| 117 | static const char kLeafPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 118 | "-----BEGIN CERTIFICATE-----\n" |
| 119 | "MIICXjCCAcegAwIBAgIIWjO48ufpunYwDQYJKoZIhvcNAQELBQAwNjEaMBgGA1UE\n" |
| 120 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxGDAWBgNVBAMTD0ludGVybWVkaWF0ZSBDQTAg\n" |
| 121 | "Fw0xNTAxMDEwMDAwMDBaGA8yMTAwMDEwMTAwMDAwMFowMjEaMBgGA1UEChMRQm9y\n" |
| 122 | "aW5nU1NMIFRFU1RJTkcxFDASBgNVBAMTC2V4YW1wbGUuY29tMIGfMA0GCSqGSIb3\n" |
| 123 | "DQEBAQUAA4GNADCBiQKBgQDD0U0ZYgqShJ7oOjsyNKyVXEHqeafmk/bAoPqY/h1c\n" |
| 124 | "oPw2E8KmeqiUSoTPjG5IXSblOxcqpbAXgnjPzo8DI3GNMhAf8SYNYsoH7gc7Uy7j\n" |
| 125 | "5x8bUrisGnuTHqkqH6d4/e7ETJ7i3CpR8bvK16DggEvQTudLipz8FBHtYhFakfdh\n" |
| 126 | "TwIDAQABo3cwdTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEG\n" |
| 127 | "CCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwGQYDVR0OBBIEEKN5pvbur7mlXjeMEYA0\n" |
| 128 | "4nUwGwYDVR0jBBQwEoAQjBpoqLV2211Xex+NFLIGozANBgkqhkiG9w0BAQsFAAOB\n" |
| 129 | "gQBj/p+JChp//LnXWC1k121LM/ii7hFzQzMrt70bny406SGz9jAjaPOX4S3gt38y\n" |
| 130 | "rhjpPukBlSzgQXFg66y6q5qp1nQTD1Cw6NkKBe9WuBlY3iYfmsf7WT8nhlT1CttU\n" |
| 131 | "xNCwyMX9mtdXdQicOfNjIGUCD5OLV5PgHFPRKiHHioBAhg==\n" |
| 132 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 133 | |
| 134 | static const char kLeafNoKeyUsagePEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 135 | "-----BEGIN CERTIFICATE-----\n" |
| 136 | "MIICNTCCAZ6gAwIBAgIJAIFQGaLQ0G2mMA0GCSqGSIb3DQEBCwUAMDYxGjAYBgNV\n" |
| 137 | "BAoTEUJvcmluZ1NTTCBURVNUSU5HMRgwFgYDVQQDEw9JbnRlcm1lZGlhdGUgQ0Ew\n" |
| 138 | "IBcNMTUwMTAxMDAwMDAwWhgPMjEwMDAxMDEwMDAwMDBaMDcxGjAYBgNVBAoTEUJv\n" |
| 139 | "cmluZ1NTTCBURVNUSU5HMRkwFwYDVQQDExBldmlsLmV4YW1wbGUuY29tMIGfMA0G\n" |
| 140 | "CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOKoZe75NPz77EOaMMl4/0s3PyQw++zJvp\n" |
| 141 | "ejHAxZiTPCJgMbEHLrSzNoHdopg+CLUH5bE4wTXM8w9Inv5P8OAFJt7gJuPUunmk\n" |
| 142 | "j+NoU3QfzOR6BroePcz1vXX9jyVHRs087M/sLqWRHu9IR+/A+UTcBaWaFiDVUxtJ\n" |
| 143 | "YOwFMwjNPQIDAQABo0gwRjAMBgNVHRMBAf8EAjAAMBkGA1UdDgQSBBBJfLEUWHq1\n" |
| 144 | "27rZ1AVx2J5GMBsGA1UdIwQUMBKAEIwaaKi1dttdV3sfjRSyBqMwDQYJKoZIhvcN\n" |
| 145 | "AQELBQADgYEALVKN2Y3LZJOtu6SxFIYKxbLaXhTGTdIjxipZhmbBRDFjbZjZZOTe\n" |
| 146 | "6Oo+VDNPYco4rBexK7umYXJyfTqoY0E8dbiImhTcGTEj7OAB3DbBomgU1AYe+t2D\n" |
| 147 | "uwBqh4Y3Eto+Zn4pMVsxGEfUpjzjZDel7bN1/oU/9KWPpDfywfUmjgk=\n" |
| 148 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 149 | |
| 150 | static const char kForgeryPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 151 | "-----BEGIN CERTIFICATE-----\n" |
| 152 | "MIICZzCCAdCgAwIBAgIIdTlMzQoKkeMwDQYJKoZIhvcNAQELBQAwNzEaMBgGA1UE\n" |
| 153 | "ChMRQm9yaW5nU1NMIFRFU1RJTkcxGTAXBgNVBAMTEGV2aWwuZXhhbXBsZS5jb20w\n" |
| 154 | "IBcNMTUwMTAxMDAwMDAwWhgPMjEwMDAxMDEwMDAwMDBaMDoxGjAYBgNVBAoTEUJv\n" |
| 155 | "cmluZ1NTTCBURVNUSU5HMRwwGgYDVQQDExNmb3JnZXJ5LmV4YW1wbGUuY29tMIGf\n" |
| 156 | "MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDADTwruBQZGb7Ay6s9HiYv5d1lwtEy\n" |
| 157 | "xQdA2Sy8Rn8uA20Q4KgqwVY7wzIZ+z5Butrsmwb70gdG1XU+yRaDeE7XVoW6jSpm\n" |
| 158 | "0sw35/5vJbTcL4THEFbnX0OPZnvpuZDFUkvVtq5kxpDWsVyM24G8EEq7kPih3Sa3\n" |
| 159 | "OMhXVXF8kso6UQIDAQABo3cwdTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYI\n" |
| 160 | "KwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwGQYDVR0OBBIEEEYJ/WHM\n" |
| 161 | "8p64erPWIg4/liwwGwYDVR0jBBQwEoAQSXyxFFh6tdu62dQFcdieRjANBgkqhkiG\n" |
| 162 | "9w0BAQsFAAOBgQA+zH7bHPElWRWJvjxDqRexmYLn+D3Aivs8XgXQJsM94W0EzSUf\n" |
| 163 | "DSLfRgaQwcb2gg2xpDFoG+W0vc6O651uF23WGt5JaFFJJxqjII05IexfCNhuPmp4\n" |
| 164 | "4UZAXPttuJXpn74IY1tuouaM06B3vXKZR+/ityKmfJvSwxacmFcK+2ziAg==\n" |
| 165 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 166 | |
| 167 | // kExamplePSSCert is an example RSA-PSS self-signed certificate, signed with |
| 168 | // the default hash functions. |
| 169 | static const char kExamplePSSCert[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 170 | "-----BEGIN CERTIFICATE-----\n" |
| 171 | "MIICYjCCAcagAwIBAgIJAI3qUyT6SIfzMBIGCSqGSIb3DQEBCjAFogMCAWowRTEL\n" |
| 172 | "MAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVy\n" |
| 173 | "bmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0xNDEwMDkxOTA5NTVaFw0xNTEwMDkxOTA5\n" |
| 174 | "NTVaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQK\n" |
| 175 | "DBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwgZ8wDQYJKoZIhvcNAQEBBQADgY0A\n" |
| 176 | "MIGJAoGBAPi4bIO0vNmoV8CltFl2jFQdeesiUgR+0zfrQf2D+fCmhRU0dXFahKg8\n" |
| 177 | "0u9aTtPel4rd/7vPCqqGkr64UOTNb4AzMHYTj8p73OxaymPHAyXvqIqDWHYg+hZ3\n" |
| 178 | "13mSYwFIGth7Z/FSVUlO1m5KXNd6NzYM3t2PROjCpywrta9kS2EHAgMBAAGjUDBO\n" |
| 179 | "MB0GA1UdDgQWBBTQQfuJQR6nrVrsNF1JEflVgXgfEzAfBgNVHSMEGDAWgBTQQfuJ\n" |
| 180 | "QR6nrVrsNF1JEflVgXgfEzAMBgNVHRMEBTADAQH/MBIGCSqGSIb3DQEBCjAFogMC\n" |
| 181 | "AWoDgYEASUy2RZcgNbNQZA0/7F+V1YTLEXwD16bm+iSVnzGwtexmQVEYIZG74K/w\n" |
| 182 | "xbdZQdTbpNJkp1QPjPfh0zsatw6dmt5QoZ8K8No0DjR9dgf+Wvv5WJvJUIQBoAVN\n" |
| 183 | "Z0IL+OQFz6+LcTHxD27JJCebrATXZA0wThGTQDm7crL+a+SujBY=\n" |
| 184 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 185 | |
| 186 | // kBadPSSCertPEM is a self-signed RSA-PSS certificate with bad parameters. |
| 187 | static const char kBadPSSCertPEM[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 188 | "-----BEGIN CERTIFICATE-----\n" |
| 189 | "MIIDdjCCAjqgAwIBAgIJANcwZLyfEv7DMD4GCSqGSIb3DQEBCjAxoA0wCwYJYIZI\n" |
| 190 | "AWUDBAIBoRowGAYJKoZIhvcNAQEIMAsGCWCGSAFlAwQCAaIEAgIA3jAnMSUwIwYD\n" |
| 191 | "VQQDDBxUZXN0IEludmFsaWQgUFNTIGNlcnRpZmljYXRlMB4XDTE1MTEwNDE2MDIz\n" |
| 192 | "NVoXDTE1MTIwNDE2MDIzNVowJzElMCMGA1UEAwwcVGVzdCBJbnZhbGlkIFBTUyBj\n" |
| 193 | "ZXJ0aWZpY2F0ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMTaM7WH\n" |
| 194 | "qVCAGAIA+zL1KWvvASTrhlq+1ePdO7wsrWX2KiYoTYrJYTnxhLnn0wrHqApt79nL\n" |
| 195 | "IBG7cfShyZqFHOY/IzlYPMVt+gPo293gw96Fds5JBsjhjkyGnOyr9OUntFqvxDbT\n" |
| 196 | "IIFU7o9IdxD4edaqjRv+fegVE+B79pDk4s0ujsk6dULtCg9Rst0ucGFo19mr+b7k\n" |
| 197 | "dbfn8pZ72ZNDJPueVdrUAWw9oll61UcYfk75XdrLk6JlL41GrYHc8KlfXf43gGQq\n" |
| 198 | "QfrpHkg4Ih2cI6Wt2nhFGAzrlcorzLliQIUJRIhM8h4IgDfpBpaPdVQLqS2pFbXa\n" |
| 199 | "5eQjqiyJwak2vJ8CAwEAAaNQME4wHQYDVR0OBBYEFCt180N4oGUt5LbzBwQ4Ia+2\n" |
| 200 | "4V97MB8GA1UdIwQYMBaAFCt180N4oGUt5LbzBwQ4Ia+24V97MAwGA1UdEwQFMAMB\n" |
| 201 | "Af8wMQYJKoZIhvcNAQEKMCSgDTALBglghkgBZQMEAgGhDTALBgkqhkiG9w0BAQii\n" |
| 202 | "BAICAN4DggEBAAjBtm90lGxgddjc4Xu/nbXXFHVs2zVcHv/mqOZoQkGB9r/BVgLb\n" |
| 203 | "xhHrFZ2pHGElbUYPfifdS9ztB73e1d4J+P29o0yBqfd4/wGAc/JA8qgn6AAEO/Xn\n" |
| 204 | "plhFeTRJQtLZVl75CkHXgUGUd3h+ADvKtcBuW9dSUncaUrgNKR8u/h/2sMG38RWY\n" |
| 205 | "DzBddC/66YTa3r7KkVUfW7yqRQfELiGKdcm+bjlTEMsvS+EhHup9CzbpoCx2Fx9p\n" |
| 206 | "NPtFY3yEObQhmL1JyoCRWqBE75GzFPbRaiux5UpEkns+i3trkGssZzsOuVqHNTNZ\n" |
| 207 | "lC9+9hPHIoc9UMmAQNo1vGIW3NWVoeGbaJ8=\n" |
| 208 | "-----END CERTIFICATE-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 209 | |
| 210 | static const char kRSAKey[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 211 | "-----BEGIN RSA PRIVATE KEY-----\n" |
| 212 | "MIICXgIBAAKBgQDYK8imMuRi/03z0K1Zi0WnvfFHvwlYeyK9Na6XJYaUoIDAtB92\n" |
| 213 | "kWdGMdAQhLciHnAjkXLI6W15OoV3gA/ElRZ1xUpxTMhjP6PyY5wqT5r6y8FxbiiF\n" |
| 214 | "KKAnHmUcrgfVW28tQ+0rkLGMryRtrukXOgXBv7gcrmU7G1jC2a7WqmeI8QIDAQAB\n" |
| 215 | "AoGBAIBy09Fd4DOq/Ijp8HeKuCMKTHqTW1xGHshLQ6jwVV2vWZIn9aIgmDsvkjCe\n" |
| 216 | "i6ssZvnbjVcwzSoByhjN8ZCf/i15HECWDFFh6gt0P5z0MnChwzZmvatV/FXCT0j+\n" |
| 217 | "WmGNB/gkehKjGXLLcjTb6dRYVJSCZhVuOLLcbWIV10gggJQBAkEA8S8sGe4ezyyZ\n" |
| 218 | "m4e9r95g6s43kPqtj5rewTsUxt+2n4eVodD+ZUlCULWVNAFLkYRTBCASlSrm9Xhj\n" |
| 219 | "QpmWAHJUkQJBAOVzQdFUaewLtdOJoPCtpYoY1zd22eae8TQEmpGOR11L6kbxLQsk\n" |
| 220 | "aMly/DOnOaa82tqAGTdqDEZgSNmCeKKknmECQAvpnY8GUOVAubGR6c+W90iBuQLj\n" |
| 221 | "LtFp/9ihd2w/PoDwrHZaoUYVcT4VSfJQog/k7kjE4MYXYWL8eEKg3WTWQNECQQDk\n" |
| 222 | "104Wi91Umd1PzF0ijd2jXOERJU1wEKe6XLkYYNHWQAe5l4J4MWj9OdxFXAxIuuR/\n" |
| 223 | "tfDwbqkta4xcux67//khAkEAvvRXLHTaa6VFzTaiiO8SaFsHV3lQyXOtMrBpB5jd\n" |
| 224 | "moZWgjHvB2W9Ckn7sDqsPB+U2tyX0joDdQEyuiMECDY8oQ==\n" |
| 225 | "-----END RSA PRIVATE KEY-----\n"; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 226 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 227 | // kCRLTestRoot is a test root certificate. It has private key: |
| 228 | // |
| 229 | // -----BEGIN RSA PRIVATE KEY----- |
| 230 | // MIIEpAIBAAKCAQEAo16WiLWZuaymsD8n5SKPmxV1y6jjgr3BS/dUBpbrzd1aeFzN |
| 231 | // lI8l2jfAnzUyp+I21RQ+nh/MhqjGElkTtK9xMn1Y+S9GMRh+5R/Du0iCb1tCZIPY |
| 232 | // 07Tgrb0KMNWe0v2QKVVruuYSgxIWodBfxlKO64Z8AJ5IbnWpuRqO6rctN9qUoMlT |
| 233 | // IAB6dL4G0tDJ/PGFWOJYwOMEIX54bly2wgyYJVBKiRRt4f7n8H922qmvPNA9idmX |
| 234 | // 9G1VAtgV6x97XXi7ULORIQvn9lVQF6nTYDBJhyuPB+mLThbLP2o9orxGx7aCtnnB |
| 235 | // ZUIxUvHNOI0FaSaZH7Fi0xsZ/GkG2HZe7ImPJwIDAQABAoIBAQCJF9MTHfHGkk+/ |
| 236 | // DwCXlA0Wg0e6hBuHl10iNobYkMWIl/xXjOknhYiqOqb181py76472SVC5ERprC+r |
| 237 | // Lf0PXzqKuA117mnkwT2bYLCL9Skf8WEhoFLQNbVlloF6wYjqXcYgKYKh8HgQbZl4 |
| 238 | // aLg2YQl2NADTNABsUWj/4H2WEelsODVviqfFs725lFg9KHDI8zxAZXLzDt/M9uVL |
| 239 | // GxJiX12tr0AwaeAFZ1oPM/y+LznM3N3+Ht3jHHw3jZ/u8Z1RdAmdpu3bZ6tbwGBr |
| 240 | // 9edsH5rKkm9aBvMrY7eX5VHqaqyRNFyG152ZOJh4XiiFG7EmgTPCpaHo50Y018Re |
| 241 | // grVtk+FBAoGBANY3lY+V8ZOwMxSHes+kTnoimHO5Ob7nxrOC71i27x+4HHsYUeAr |
| 242 | // /zOOghiDIn+oNkuiX5CIOWZKx159Bp65CPpCbTb/fh+HYnSgXFgCw7XptycO7LXM |
| 243 | // 5GwR5jSfpfzBFdYxjxoUzDMFBwTEYRTm0HkUHkH+s+ajjw5wqqbcGLcfAoGBAMM8 |
| 244 | // DKW6Tb66xsf708f0jonAjKYTLZ+WOcwsBEWSFHoY8dUjvW5gqx5acHTEsc5ZTeh4 |
| 245 | // BCFLa+Mn9cuJWVJNs09k7Xb2PNl92HQ4GN2vbdkJhExbkT6oLDHg1hVD0w8KLfz1 |
| 246 | // lTAW6pS+6CdOHMEJpvqx89EgU/1GgIQ1fXYczE75AoGAKeJoXdDFkUjsU+FBhAPu |
| 247 | // TDcjc80Nm2QaF9NMFR5/lsYa236f06MGnQAKM9zADBHJu/Qdl1brUjLg1HrBppsr |
| 248 | // RDNkw1IlSOjhuUf5hkPUHGd8Jijm440SRIcjabqla8wdBupdvo2+d2NOQgJbsQiI |
| 249 | // ToQ+fkzcxAXK3Nnuo/1436UCgYBjLH7UNOZHS8OsVM0I1r8NVKVdu4JCfeJQR8/H |
| 250 | // s2P5ffBir+wLRMnH+nMDreMQiibcPxMCArkERAlE4jlgaJ38Z62E76KLbLTmnJRt |
| 251 | // EC9Bv+bXjvAiHvWMRMUbOj/ddPNVez7Uld+FvdBaHwDWQlvzHzBWfBCOKSEhh7Z6 |
| 252 | // qDhUqQKBgQDPMDx2i5rfmQp3imV9xUcCkIRsyYQVf8Eo7NV07IdUy/otmksgn4Zt |
| 253 | // Lbf3v2dvxOpTNTONWjp2c+iUQo8QxJCZr5Sfb21oQ9Ktcrmc/CY7LeBVDibXwxdM |
| 254 | // vRG8kBzvslFWh7REzC3u06GSVhyKDfW93kN2cKVwGoahRlhj7oHuZQ== |
| 255 | // -----END RSA PRIVATE KEY----- |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 256 | static const char kCRLTestRoot[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 257 | "-----BEGIN CERTIFICATE-----\n" |
| 258 | "MIIDbzCCAlegAwIBAgIJAODri7v0dDUFMA0GCSqGSIb3DQEBCwUAME4xCzAJBgNV\n" |
| 259 | "BAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1Nb3VudGFpbiBW\n" |
| 260 | "aWV3MRIwEAYDVQQKDAlCb3JpbmdTU0wwHhcNMTYwOTI2MTUwNjI2WhcNMjYwOTI0\n" |
| 261 | "MTUwNjI2WjBOMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG\n" |
| 262 | "A1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJQm9yaW5nU1NMMIIBIjANBgkq\n" |
| 263 | "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo16WiLWZuaymsD8n5SKPmxV1y6jjgr3B\n" |
| 264 | "S/dUBpbrzd1aeFzNlI8l2jfAnzUyp+I21RQ+nh/MhqjGElkTtK9xMn1Y+S9GMRh+\n" |
| 265 | "5R/Du0iCb1tCZIPY07Tgrb0KMNWe0v2QKVVruuYSgxIWodBfxlKO64Z8AJ5IbnWp\n" |
| 266 | "uRqO6rctN9qUoMlTIAB6dL4G0tDJ/PGFWOJYwOMEIX54bly2wgyYJVBKiRRt4f7n\n" |
| 267 | "8H922qmvPNA9idmX9G1VAtgV6x97XXi7ULORIQvn9lVQF6nTYDBJhyuPB+mLThbL\n" |
| 268 | "P2o9orxGx7aCtnnBZUIxUvHNOI0FaSaZH7Fi0xsZ/GkG2HZe7ImPJwIDAQABo1Aw\n" |
| 269 | "TjAdBgNVHQ4EFgQUWPt3N5cZ/CRvubbrkqfBnAqhq94wHwYDVR0jBBgwFoAUWPt3\n" |
| 270 | "N5cZ/CRvubbrkqfBnAqhq94wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC\n" |
| 271 | "AQEAORu6M0MOwXy+3VEBwNilfTxyqDfruQsc1jA4PT8Oe8zora1WxE1JB4q2FJOz\n" |
| 272 | "EAuM3H/NXvEnBuN+ITvKZAJUfm4NKX97qmjMJwLKWe1gVv+VQTr63aR7mgWJReQN\n" |
| 273 | "XdMztlVeZs2dppV6uEg3ia1X0G7LARxGpA9ETbMyCpb39XxlYuTClcbA5ftDN99B\n" |
| 274 | "3Xg9KNdd++Ew22O3HWRDvdDpTO/JkzQfzi3sYwUtzMEonENhczJhGf7bQMmvL/w5\n" |
| 275 | "24Wxj4Z7KzzWIHsNqE/RIs6RV3fcW61j/mRgW2XyoWnMVeBzvcJr9NXp4VQYmFPw\n" |
| 276 | "amd8GKMZQvP0ufGnUn7D7uartA==\n" |
| 277 | "-----END CERTIFICATE-----\n"; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 278 | |
| 279 | static const char kCRLTestLeaf[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 280 | "-----BEGIN CERTIFICATE-----\n" |
| 281 | "MIIDkDCCAnigAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwTjELMAkGA1UEBhMCVVMx\n" |
| 282 | "EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEjAQ\n" |
| 283 | "BgNVBAoMCUJvcmluZ1NTTDAeFw0xNjA5MjYxNTA4MzFaFw0xNzA5MjYxNTA4MzFa\n" |
| 284 | "MEsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQKDAlC\n" |
| 285 | "b3JpbmdTU0wxEzARBgNVBAMMCmJvcmluZy5zc2wwggEiMA0GCSqGSIb3DQEBAQUA\n" |
| 286 | "A4IBDwAwggEKAoIBAQDc5v1S1M0W+QWM+raWfO0LH8uvqEwuJQgODqMaGnSlWUx9\n" |
| 287 | "8iQcnWfjyPja3lWg9K62hSOFDuSyEkysKHDxijz5R93CfLcfnVXjWQDJe7EJTTDP\n" |
| 288 | "ozEvxN6RjAeYv7CF000euYr3QT5iyBjg76+bon1p0jHZBJeNPP1KqGYgyxp+hzpx\n" |
| 289 | "e0gZmTlGAXd8JQK4v8kpdYwD6PPifFL/jpmQpqOtQmH/6zcLjY4ojmqpEdBqIKIX\n" |
| 290 | "+saA29hMq0+NK3K+wgg31RU+cVWxu3tLOIiesETkeDgArjWRS1Vkzbi4v9SJxtNu\n" |
| 291 | "OZuAxWiynRJw3JwH/OFHYZIvQqz68ZBoj96cepjPAgMBAAGjezB5MAkGA1UdEwQC\n" |
| 292 | "MAAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRl\n" |
| 293 | "MB0GA1UdDgQWBBTGn0OVVh/aoYt0bvEKG+PIERqnDzAfBgNVHSMEGDAWgBRY+3c3\n" |
| 294 | "lxn8JG+5tuuSp8GcCqGr3jANBgkqhkiG9w0BAQsFAAOCAQEAd2nM8gCQN2Dc8QJw\n" |
| 295 | "XSZXyuI3DBGGCHcay/3iXu0JvTC3EiQo8J6Djv7WLI0N5KH8mkm40u89fJAB2lLZ\n" |
| 296 | "ShuHVtcC182bOKnePgwp9CNwQ21p0rDEu/P3X46ZvFgdxx82E9xLa0tBB8PiPDWh\n" |
| 297 | "lV16jbaKTgX5AZqjnsyjR5o9/mbZVupZJXx5Syq+XA8qiJfstSYJs4KyKK9UOjql\n" |
| 298 | "ICkJVKpi2ahDBqX4MOH4SLfzVk8pqSpviS6yaA1RXqjpkxiN45WWaXDldVHMSkhC\n" |
| 299 | "5CNXsXi4b1nAntu89crwSLA3rEwzCWeYj+BX7e1T9rr3oJdwOU/2KQtW1js1yQUG\n" |
| 300 | "tjJMFw==\n" |
| 301 | "-----END CERTIFICATE-----\n"; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 302 | |
| 303 | static const char kBasicCRL[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 304 | "-----BEGIN X509 CRL-----\n" |
| 305 | "MIIBpzCBkAIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 306 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJ\n" |
| 307 | "Qm9yaW5nU1NMFw0xNjA5MjYxNTEwNTVaFw0xNjEwMjYxNTEwNTVaoA4wDDAKBgNV\n" |
| 308 | "HRQEAwIBATANBgkqhkiG9w0BAQsFAAOCAQEAnrBKKgvd9x9zwK9rtUvVeFeJ7+LN\n" |
| 309 | "ZEAc+a5oxpPNEsJx6hXoApYEbzXMxuWBQoCs5iEBycSGudct21L+MVf27M38KrWo\n" |
| 310 | "eOkq0a2siqViQZO2Fb/SUFR0k9zb8xl86Zf65lgPplALun0bV/HT7MJcl04Tc4os\n" |
| 311 | "dsAReBs5nqTGNEd5AlC1iKHvQZkM//MD51DspKnDpsDiUVi54h9C1SpfZmX8H2Vv\n" |
| 312 | "diyu0fZ/bPAM3VAGawatf/SyWfBMyKpoPXEG39oAzmjjOj8en82psn7m474IGaho\n" |
| 313 | "/vBbhl1ms5qQiLYPjm4YELtnXQoFyC72tBjbdFd/ZE9k4CNKDbxFUXFbkw==\n" |
| 314 | "-----END X509 CRL-----\n"; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 315 | |
| 316 | static const char kRevokedCRL[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 317 | "-----BEGIN X509 CRL-----\n" |
| 318 | "MIIBvjCBpwIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 319 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJ\n" |
| 320 | "Qm9yaW5nU1NMFw0xNjA5MjYxNTEyNDRaFw0xNjEwMjYxNTEyNDRaMBUwEwICEAAX\n" |
| 321 | "DTE2MDkyNjE1MTIyNlqgDjAMMAoGA1UdFAQDAgECMA0GCSqGSIb3DQEBCwUAA4IB\n" |
| 322 | "AQCUGaM4DcWzlQKrcZvI8TMeR8BpsvQeo5BoI/XZu2a8h//PyRyMwYeaOM+3zl0d\n" |
| 323 | "sjgCT8b3C1FPgT+P2Lkowv7rJ+FHJRNQkogr+RuqCSPTq65ha4WKlRGWkMFybzVH\n" |
| 324 | "NloxC+aU3lgp/NlX9yUtfqYmJek1CDrOOGPrAEAwj1l/BUeYKNGqfBWYJQtPJu+5\n" |
| 325 | "OaSvIYGpETCZJscUWODmLEb/O3DM438vLvxonwGqXqS0KX37+CHpUlyhnSovxXxp\n" |
| 326 | "Pz4aF+L7OtczxL0GYtD2fR9B7TDMqsNmHXgQrixvvOY7MUdLGbd4RfJL3yA53hyO\n" |
| 327 | "xzfKY2TzxLiOmctG0hXFkH5J\n" |
| 328 | "-----END X509 CRL-----\n"; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 329 | |
| 330 | static const char kBadIssuerCRL[] = |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 331 | "-----BEGIN X509 CRL-----\n" |
| 332 | "MIIBwjCBqwIBATANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 333 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEWMBQGA1UECgwN\n" |
| 334 | "Tm90IEJvcmluZ1NTTBcNMTYwOTI2MTUxMjQ0WhcNMTYxMDI2MTUxMjQ0WjAVMBMC\n" |
| 335 | "AhAAFw0xNjA5MjYxNTEyMjZaoA4wDDAKBgNVHRQEAwIBAjANBgkqhkiG9w0BAQsF\n" |
| 336 | "AAOCAQEAlBmjOA3Fs5UCq3GbyPEzHkfAabL0HqOQaCP12btmvIf/z8kcjMGHmjjP\n" |
| 337 | "t85dHbI4Ak/G9wtRT4E/j9i5KML+6yfhRyUTUJKIK/kbqgkj06uuYWuFipURlpDB\n" |
| 338 | "cm81RzZaMQvmlN5YKfzZV/clLX6mJiXpNQg6zjhj6wBAMI9ZfwVHmCjRqnwVmCUL\n" |
| 339 | "TybvuTmkryGBqREwmSbHFFjg5ixG/ztwzON/Ly78aJ8Bql6ktCl9+/gh6VJcoZ0q\n" |
| 340 | "L8V8aT8+Ghfi+zrXM8S9BmLQ9n0fQe0wzKrDZh14EK4sb7zmOzFHSxm3eEXyS98g\n" |
| 341 | "Od4cjsc3ymNk88S4jpnLRtIVxZB+SQ==\n" |
| 342 | "-----END X509 CRL-----\n"; |
| 343 | |
| 344 | // kKnownCriticalCRL is kBasicCRL but with a critical issuing distribution point |
| 345 | // extension. |
| 346 | static const char kKnownCriticalCRL[] = |
| 347 | "-----BEGIN X509 CRL-----\n" |
| 348 | "MIIBujCBowIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 349 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJ\n" |
| 350 | "Qm9yaW5nU1NMFw0xNjA5MjYxNTEwNTVaFw0xNjEwMjYxNTEwNTVaoCEwHzAKBgNV\n" |
| 351 | "HRQEAwIBATARBgNVHRwBAf8EBzAFoQMBAf8wDQYJKoZIhvcNAQELBQADggEBAA+3\n" |
| 352 | "i+5e5Ub8sccfgOBs6WVJFI9c8gvJjrJ8/dYfFIAuCyeocs7DFXn1n13CRZ+URR/Q\n" |
| 353 | "mVWgU28+xeusuSPYFpd9cyYTcVyNUGNTI3lwgcE/yVjPaOmzSZKdPakApRxtpKKQ\n" |
| 354 | "NN/56aQz3bnT/ZSHQNciRB8U6jiD9V30t0w+FDTpGaG+7bzzUH3UVF9xf9Ctp60A\n" |
| 355 | "3mfLe0scas7owSt4AEFuj2SPvcE7yvdOXbu+IEv21cEJUVExJAbhvIweHXh6yRW+\n" |
| 356 | "7VVeiNzdIjkZjyTmAzoXGha4+wbxXyBRbfH+XWcO/H+8nwyG8Gktdu2QB9S9nnIp\n" |
| 357 | "o/1TpfOMSGhMyMoyPrk=\n" |
| 358 | "-----END X509 CRL-----\n"; |
| 359 | |
| 360 | // kUnknownCriticalCRL is kBasicCRL but with an unknown critical extension. |
| 361 | static const char kUnknownCriticalCRL[] = |
| 362 | "-----BEGIN X509 CRL-----\n" |
| 363 | "MIIBvDCBpQIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 364 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJ\n" |
| 365 | "Qm9yaW5nU1NMFw0xNjA5MjYxNTEwNTVaFw0xNjEwMjYxNTEwNTVaoCMwITAKBgNV\n" |
| 366 | "HRQEAwIBATATBgwqhkiG9xIEAYS3CQABAf8EADANBgkqhkiG9w0BAQsFAAOCAQEA\n" |
| 367 | "GvBP0xqL509InMj/3493YVRV+ldTpBv5uTD6jewzf5XdaxEQ/VjTNe5zKnxbpAib\n" |
| 368 | "Kf7cwX0PMSkZjx7k7kKdDlEucwVvDoqC+O9aJcqVmM6GDyNb9xENxd0XCXja6MZC\n" |
| 369 | "yVgP4AwLauB2vSiEprYJyI1APph3iAEeDm60lTXX/wBM/tupQDDujKh2GPyvBRfJ\n" |
| 370 | "+wEDwGg3ICwvu4gO4zeC5qnFR+bpL9t5tOMAQnVZ0NWv+k7mkd2LbHdD44dxrfXC\n" |
| 371 | "nhtfERx99SDmC/jtUAJrGhtCO8acr7exCeYcduN7KKCm91OeCJKK6OzWst0Og1DB\n" |
| 372 | "kwzzU2rL3G65CrZ7H0SZsQ==\n" |
| 373 | "-----END X509 CRL-----\n"; |
| 374 | |
| 375 | // kUnknownCriticalCRL2 is kBasicCRL but with a critical issuing distribution |
| 376 | // point extension followed by an unknown critical extension |
| 377 | static const char kUnknownCriticalCRL2[] = |
| 378 | "-----BEGIN X509 CRL-----\n" |
| 379 | "MIIBzzCBuAIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzETMBEGA1UE\n" |
| 380 | "CAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzESMBAGA1UECgwJ\n" |
| 381 | "Qm9yaW5nU1NMFw0xNjA5MjYxNTEwNTVaFw0xNjEwMjYxNTEwNTVaoDYwNDAKBgNV\n" |
| 382 | "HRQEAwIBATARBgNVHRwBAf8EBzAFoQMBAf8wEwYMKoZIhvcSBAGEtwkAAQH/BAAw\n" |
| 383 | "DQYJKoZIhvcNAQELBQADggEBACTcpQC8jXL12JN5YzOcQ64ubQIe0XxRAd30p7qB\n" |
| 384 | "BTXGpgqBjrjxRfLms7EBYodEXB2oXMsDq3km0vT1MfYdsDD05S+SQ9CDsq/pUfaC\n" |
| 385 | "E2WNI5p8WircRnroYvbN2vkjlRbMd1+yNITohXYXCJwjEOAWOx3XIM10bwPYBv4R\n" |
| 386 | "rDobuLHoMgL3yHgMHmAkP7YpkBucNqeBV8cCdeAZLuhXFWi6yfr3r/X18yWbC/r2\n" |
| 387 | "2xXdkrSqXLFo7ToyP8YKTgiXpya4x6m53biEYwa2ULlas0igL6DK7wjYZX95Uy7H\n" |
| 388 | "GKljn9weIYiMPV/BzGymwfv2EW0preLwtyJNJPaxbdin6Jc=\n" |
| 389 | "-----END X509 CRL-----\n"; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 390 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 391 | // CertFromPEM parses the given, NUL-terminated pem block and returns an |
| 392 | // |X509*|. |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 393 | static bssl::UniquePtr<X509> CertFromPEM(const char *pem) { |
| 394 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(pem, strlen(pem))); |
| 395 | return bssl::UniquePtr<X509>( |
| 396 | PEM_read_bio_X509(bio.get(), nullptr, nullptr, nullptr)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 397 | } |
| 398 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 399 | // CRLFromPEM parses the given, NUL-terminated pem block and returns an |
| 400 | // |X509_CRL*|. |
| 401 | static bssl::UniquePtr<X509_CRL> CRLFromPEM(const char *pem) { |
| 402 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(pem, strlen(pem))); |
| 403 | return bssl::UniquePtr<X509_CRL>( |
| 404 | PEM_read_bio_X509_CRL(bio.get(), nullptr, nullptr, nullptr)); |
| 405 | } |
| 406 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 407 | // PrivateKeyFromPEM parses the given, NUL-terminated pem block and returns an |
| 408 | // |EVP_PKEY*|. |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 409 | static bssl::UniquePtr<EVP_PKEY> PrivateKeyFromPEM(const char *pem) { |
| 410 | bssl::UniquePtr<BIO> bio( |
| 411 | BIO_new_mem_buf(const_cast<char *>(pem), strlen(pem))); |
| 412 | return bssl::UniquePtr<EVP_PKEY>( |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 413 | PEM_read_bio_PrivateKey(bio.get(), nullptr, nullptr, nullptr)); |
| 414 | } |
| 415 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 416 | // CertsToStack converts a vector of |X509*| to an OpenSSL STACK_OF(X509), |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 417 | // bumping the reference counts for each certificate in question. |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 418 | static bssl::UniquePtr<STACK_OF(X509)> CertsToStack( |
| 419 | const std::vector<X509 *> &certs) { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 420 | bssl::UniquePtr<STACK_OF(X509)> stack(sk_X509_new_null()); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 421 | if (!stack) { |
| 422 | return nullptr; |
| 423 | } |
| 424 | for (auto cert : certs) { |
| 425 | if (!sk_X509_push(stack.get(), cert)) { |
| 426 | return nullptr; |
| 427 | } |
| 428 | X509_up_ref(cert); |
| 429 | } |
| 430 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 431 | return stack; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 432 | } |
| 433 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 434 | // CRLsToStack converts a vector of |X509_CRL*| to an OpenSSL |
| 435 | // STACK_OF(X509_CRL), bumping the reference counts for each CRL in question. |
| 436 | static bssl::UniquePtr<STACK_OF(X509_CRL)> CRLsToStack( |
| 437 | const std::vector<X509_CRL *> &crls) { |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 438 | bssl::UniquePtr<STACK_OF(X509_CRL)> stack(sk_X509_CRL_new_null()); |
| 439 | if (!stack) { |
| 440 | return nullptr; |
| 441 | } |
| 442 | for (auto crl : crls) { |
| 443 | if (!sk_X509_CRL_push(stack.get(), crl)) { |
| 444 | return nullptr; |
| 445 | } |
| 446 | X509_CRL_up_ref(crl); |
| 447 | } |
| 448 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 449 | return stack; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | static int Verify(X509 *leaf, const std::vector<X509 *> &roots, |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 453 | const std::vector<X509 *> &intermediates, |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 454 | const std::vector<X509_CRL *> &crls, |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 455 | unsigned long flags, |
| 456 | bool use_additional_untrusted) { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 457 | bssl::UniquePtr<STACK_OF(X509)> roots_stack(CertsToStack(roots)); |
| 458 | bssl::UniquePtr<STACK_OF(X509)> intermediates_stack( |
| 459 | CertsToStack(intermediates)); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 460 | bssl::UniquePtr<STACK_OF(X509_CRL)> crls_stack(CRLsToStack(crls)); |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 461 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 462 | if (!roots_stack || |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 463 | !intermediates_stack || |
| 464 | !crls_stack) { |
| 465 | return X509_V_ERR_UNSPECIFIED; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 466 | } |
| 467 | |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 468 | bssl::UniquePtr<X509_STORE_CTX> ctx(X509_STORE_CTX_new()); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 469 | bssl::UniquePtr<X509_STORE> store(X509_STORE_new()); |
| 470 | if (!ctx || |
| 471 | !store) { |
| 472 | return X509_V_ERR_UNSPECIFIED; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 473 | } |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 474 | |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 475 | if (use_additional_untrusted) { |
| 476 | X509_STORE_set0_additional_untrusted(store.get(), |
| 477 | intermediates_stack.get()); |
| 478 | } |
| 479 | |
| 480 | if (!X509_STORE_CTX_init( |
| 481 | ctx.get(), store.get(), leaf, |
| 482 | use_additional_untrusted ? nullptr : intermediates_stack.get())) { |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 483 | return X509_V_ERR_UNSPECIFIED; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | X509_STORE_CTX_trusted_stack(ctx.get(), roots_stack.get()); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 487 | X509_STORE_CTX_set0_crls(ctx.get(), crls_stack.get()); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 488 | |
| 489 | X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new(); |
| 490 | if (param == nullptr) { |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 491 | return X509_V_ERR_UNSPECIFIED; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 492 | } |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 493 | X509_VERIFY_PARAM_set_time(param, 1474934400 /* Sep 27th, 2016 */); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 494 | X509_VERIFY_PARAM_set_depth(param, 16); |
| 495 | if (flags) { |
| 496 | X509_VERIFY_PARAM_set_flags(param, flags); |
| 497 | } |
| 498 | X509_STORE_CTX_set0_param(ctx.get(), param); |
| 499 | |
| 500 | ERR_clear_error(); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 501 | if (X509_verify_cert(ctx.get()) != 1) { |
| 502 | return X509_STORE_CTX_get_error(ctx.get()); |
| 503 | } |
| 504 | |
| 505 | return X509_V_OK; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 506 | } |
| 507 | |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 508 | static int Verify(X509 *leaf, const std::vector<X509 *> &roots, |
| 509 | const std::vector<X509 *> &intermediates, |
| 510 | const std::vector<X509_CRL *> &crls, |
| 511 | unsigned long flags = 0) { |
| 512 | const int r1 = Verify(leaf, roots, intermediates, crls, flags, false); |
| 513 | const int r2 = Verify(leaf, roots, intermediates, crls, flags, true); |
| 514 | |
| 515 | if (r1 != r2) { |
| 516 | fprintf(stderr, |
| 517 | "Verify with, and without, use_additional_untrusted gave different " |
| 518 | "results: %d vs %d.\n", |
| 519 | r1, r2); |
| 520 | return false; |
| 521 | } |
| 522 | |
| 523 | return r1; |
| 524 | } |
| 525 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 526 | static bool TestVerify() { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 527 | bssl::UniquePtr<X509> cross_signing_root(CertFromPEM(kCrossSigningRootPEM)); |
| 528 | bssl::UniquePtr<X509> root(CertFromPEM(kRootCAPEM)); |
| 529 | bssl::UniquePtr<X509> root_cross_signed(CertFromPEM(kRootCrossSignedPEM)); |
| 530 | bssl::UniquePtr<X509> intermediate(CertFromPEM(kIntermediatePEM)); |
| 531 | bssl::UniquePtr<X509> intermediate_self_signed( |
| 532 | CertFromPEM(kIntermediateSelfSignedPEM)); |
| 533 | bssl::UniquePtr<X509> leaf(CertFromPEM(kLeafPEM)); |
| 534 | bssl::UniquePtr<X509> leaf_no_key_usage(CertFromPEM(kLeafNoKeyUsagePEM)); |
| 535 | bssl::UniquePtr<X509> forgery(CertFromPEM(kForgeryPEM)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 536 | |
| 537 | if (!cross_signing_root || |
| 538 | !root || |
| 539 | !root_cross_signed || |
| 540 | !intermediate || |
| 541 | !intermediate_self_signed || |
| 542 | !leaf || |
| 543 | !leaf_no_key_usage || |
| 544 | !forgery) { |
| 545 | fprintf(stderr, "Failed to parse certificates\n"); |
| 546 | return false; |
| 547 | } |
| 548 | |
| 549 | std::vector<X509*> empty; |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 550 | std::vector<X509_CRL*> empty_crls; |
| 551 | if (Verify(leaf.get(), empty, empty, empty_crls) != |
| 552 | X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 553 | fprintf(stderr, "Leaf verified with no roots!\n"); |
| 554 | return false; |
| 555 | } |
| 556 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 557 | if (Verify(leaf.get(), empty, {intermediate.get()}, empty_crls) != |
| 558 | X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 559 | fprintf(stderr, "Leaf verified with no roots!\n"); |
| 560 | return false; |
| 561 | } |
| 562 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 563 | if (Verify(leaf.get(), {root.get()}, {intermediate.get()}, empty_crls) != |
| 564 | X509_V_OK) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 565 | ERR_print_errors_fp(stderr); |
| 566 | fprintf(stderr, "Basic chain didn't verify.\n"); |
| 567 | return false; |
| 568 | } |
| 569 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 570 | if (Verify(leaf.get(), {cross_signing_root.get()}, |
| 571 | {intermediate.get(), root_cross_signed.get()}, |
| 572 | empty_crls) != X509_V_OK) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 573 | ERR_print_errors_fp(stderr); |
| 574 | fprintf(stderr, "Cross-signed chain didn't verify.\n"); |
| 575 | return false; |
| 576 | } |
| 577 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 578 | if (Verify(leaf.get(), {cross_signing_root.get(), root.get()}, |
| 579 | {intermediate.get(), root_cross_signed.get()}, |
| 580 | empty_crls) != X509_V_OK) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 581 | ERR_print_errors_fp(stderr); |
| 582 | fprintf(stderr, "Cross-signed chain with root didn't verify.\n"); |
| 583 | return false; |
| 584 | } |
| 585 | |
| 586 | /* This is the “altchains” test – we remove the cross-signing CA but include |
| 587 | * the cross-sign in the intermediates. */ |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 588 | if (Verify(leaf.get(), {root.get()}, |
| 589 | {intermediate.get(), root_cross_signed.get()}, |
| 590 | empty_crls) != X509_V_OK) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 591 | ERR_print_errors_fp(stderr); |
| 592 | fprintf(stderr, "Chain with cross-sign didn't backtrack to find root.\n"); |
| 593 | return false; |
| 594 | } |
| 595 | |
| 596 | if (Verify(leaf.get(), {root.get()}, |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 597 | {intermediate.get(), root_cross_signed.get()}, empty_crls, |
| 598 | X509_V_FLAG_NO_ALT_CHAINS) != |
| 599 | X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 600 | fprintf(stderr, "Altchains test still passed when disabled.\n"); |
| 601 | return false; |
| 602 | } |
| 603 | |
| 604 | if (Verify(forgery.get(), {intermediate_self_signed.get()}, |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 605 | {leaf_no_key_usage.get()}, |
| 606 | empty_crls) != X509_V_ERR_INVALID_CA) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 607 | fprintf(stderr, "Basic constraints weren't checked.\n"); |
| 608 | return false; |
| 609 | } |
| 610 | |
| 611 | /* Test that one cannot skip Basic Constraints checking with a contorted set |
| 612 | * of roots and intermediates. This is a regression test for CVE-2015-1793. */ |
| 613 | if (Verify(forgery.get(), |
| 614 | {intermediate_self_signed.get(), root_cross_signed.get()}, |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 615 | {leaf_no_key_usage.get(), intermediate.get()}, |
| 616 | empty_crls) != X509_V_ERR_INVALID_CA) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 617 | fprintf(stderr, "Basic constraints weren't checked.\n"); |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | return true; |
| 622 | } |
| 623 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 624 | static bool TestCRL() { |
| 625 | bssl::UniquePtr<X509> root(CertFromPEM(kCRLTestRoot)); |
| 626 | bssl::UniquePtr<X509> leaf(CertFromPEM(kCRLTestLeaf)); |
| 627 | bssl::UniquePtr<X509_CRL> basic_crl(CRLFromPEM(kBasicCRL)); |
| 628 | bssl::UniquePtr<X509_CRL> revoked_crl(CRLFromPEM(kRevokedCRL)); |
| 629 | bssl::UniquePtr<X509_CRL> bad_issuer_crl(CRLFromPEM(kBadIssuerCRL)); |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 630 | bssl::UniquePtr<X509_CRL> known_critical_crl(CRLFromPEM(kKnownCriticalCRL)); |
| 631 | bssl::UniquePtr<X509_CRL> unknown_critical_crl( |
| 632 | CRLFromPEM(kUnknownCriticalCRL)); |
| 633 | bssl::UniquePtr<X509_CRL> unknown_critical_crl2( |
| 634 | CRLFromPEM(kUnknownCriticalCRL2)); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 635 | |
| 636 | if (!root || |
| 637 | !leaf || |
| 638 | !basic_crl || |
| 639 | !revoked_crl || |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 640 | !bad_issuer_crl || |
| 641 | !known_critical_crl || |
| 642 | !unknown_critical_crl || |
| 643 | !unknown_critical_crl2) { |
| 644 | fprintf(stderr, "Failed to parse certificates and CRLs.\n"); |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 645 | return false; |
| 646 | } |
| 647 | |
| 648 | if (Verify(leaf.get(), {root.get()}, {root.get()}, {basic_crl.get()}, |
| 649 | X509_V_FLAG_CRL_CHECK) != X509_V_OK) { |
| 650 | fprintf(stderr, "Cert with CRL didn't verify.\n"); |
| 651 | return false; |
| 652 | } |
| 653 | |
| 654 | if (Verify(leaf.get(), {root.get()}, {root.get()}, |
| 655 | {basic_crl.get(), revoked_crl.get()}, |
| 656 | X509_V_FLAG_CRL_CHECK) != X509_V_ERR_CERT_REVOKED) { |
| 657 | fprintf(stderr, "Revoked CRL wasn't checked.\n"); |
| 658 | return false; |
| 659 | } |
| 660 | |
| 661 | std::vector<X509_CRL *> empty_crls; |
| 662 | if (Verify(leaf.get(), {root.get()}, {root.get()}, empty_crls, |
| 663 | X509_V_FLAG_CRL_CHECK) != X509_V_ERR_UNABLE_TO_GET_CRL) { |
| 664 | fprintf(stderr, "CRLs were not required.\n"); |
| 665 | return false; |
| 666 | } |
| 667 | |
| 668 | if (Verify(leaf.get(), {root.get()}, {root.get()}, {bad_issuer_crl.get()}, |
| 669 | X509_V_FLAG_CRL_CHECK) != X509_V_ERR_UNABLE_TO_GET_CRL) { |
| 670 | fprintf(stderr, "Bad CRL issuer was unnoticed.\n"); |
| 671 | return false; |
| 672 | } |
| 673 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 674 | if (Verify(leaf.get(), {root.get()}, {root.get()}, {known_critical_crl.get()}, |
| 675 | X509_V_FLAG_CRL_CHECK) != X509_V_OK) { |
| 676 | fprintf(stderr, "CRL with known critical extension was rejected.\n"); |
| 677 | return false; |
| 678 | } |
| 679 | |
| 680 | if (Verify(leaf.get(), {root.get()}, {root.get()}, |
| 681 | {unknown_critical_crl.get()}, X509_V_FLAG_CRL_CHECK) != |
| 682 | X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION) { |
| 683 | fprintf(stderr, "CRL with unknown critical extension was accepted.\n"); |
| 684 | return false; |
| 685 | } |
| 686 | |
| 687 | if (Verify(leaf.get(), {root.get()}, {root.get()}, |
| 688 | {unknown_critical_crl2.get()}, X509_V_FLAG_CRL_CHECK) != |
| 689 | X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION) { |
| 690 | fprintf(stderr, "CRL with unknown critical extension (2) was accepted.\n"); |
| 691 | return false; |
| 692 | } |
| 693 | |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 694 | return true; |
| 695 | } |
| 696 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 697 | static bool TestPSS() { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 698 | bssl::UniquePtr<X509> cert(CertFromPEM(kExamplePSSCert)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 699 | if (!cert) { |
| 700 | return false; |
| 701 | } |
| 702 | |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 703 | bssl::UniquePtr<EVP_PKEY> pkey(X509_get_pubkey(cert.get())); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 704 | if (!pkey) { |
| 705 | return false; |
| 706 | } |
| 707 | |
| 708 | if (!X509_verify(cert.get(), pkey.get())) { |
| 709 | fprintf(stderr, "Could not verify certificate.\n"); |
| 710 | return false; |
| 711 | } |
| 712 | return true; |
| 713 | } |
| 714 | |
| 715 | static bool TestBadPSSParameters() { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 716 | bssl::UniquePtr<X509> cert(CertFromPEM(kBadPSSCertPEM)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 717 | if (!cert) { |
| 718 | return false; |
| 719 | } |
| 720 | |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 721 | bssl::UniquePtr<EVP_PKEY> pkey(X509_get_pubkey(cert.get())); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 722 | if (!pkey) { |
| 723 | return false; |
| 724 | } |
| 725 | |
| 726 | if (X509_verify(cert.get(), pkey.get())) { |
| 727 | fprintf(stderr, "Unexpectedly verified bad certificate.\n"); |
| 728 | return false; |
| 729 | } |
| 730 | ERR_clear_error(); |
| 731 | return true; |
| 732 | } |
| 733 | |
| 734 | static bool SignatureRoundTrips(EVP_MD_CTX *md_ctx, EVP_PKEY *pkey) { |
| 735 | // Make a certificate like signed with |md_ctx|'s settings.' |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 736 | bssl::UniquePtr<X509> cert(CertFromPEM(kLeafPEM)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 737 | if (!cert || !X509_sign_ctx(cert.get(), md_ctx)) { |
| 738 | return false; |
| 739 | } |
| 740 | |
| 741 | // Ensure that |pkey| may still be used to verify the resulting signature. All |
| 742 | // settings in |md_ctx| must have been serialized appropriately. |
| 743 | return !!X509_verify(cert.get(), pkey); |
| 744 | } |
| 745 | |
| 746 | static bool TestSignCtx() { |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 747 | bssl::UniquePtr<EVP_PKEY> pkey(PrivateKeyFromPEM(kRSAKey)); |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 748 | if (!pkey) { |
| 749 | return false; |
| 750 | } |
| 751 | |
| 752 | // Test PKCS#1 v1.5. |
David Benjamin | 1b24967 | 2016-12-06 18:25:50 -0500 | [diff] [blame] | 753 | bssl::ScopedEVP_MD_CTX md_ctx; |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 754 | if (!EVP_DigestSignInit(md_ctx.get(), NULL, EVP_sha256(), NULL, pkey.get()) || |
| 755 | !SignatureRoundTrips(md_ctx.get(), pkey.get())) { |
| 756 | fprintf(stderr, "RSA PKCS#1 with SHA-256 failed\n"); |
| 757 | return false; |
| 758 | } |
| 759 | |
| 760 | // Test RSA-PSS with custom parameters. |
| 761 | md_ctx.Reset(); |
| 762 | EVP_PKEY_CTX *pkey_ctx; |
| 763 | if (!EVP_DigestSignInit(md_ctx.get(), &pkey_ctx, EVP_sha256(), NULL, |
| 764 | pkey.get()) || |
| 765 | !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
| 766 | !EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, EVP_sha512()) || |
| 767 | !SignatureRoundTrips(md_ctx.get(), pkey.get())) { |
| 768 | fprintf(stderr, "RSA-PSS failed\n"); |
| 769 | return false; |
| 770 | } |
| 771 | |
| 772 | return true; |
| 773 | } |
| 774 | |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 775 | static bool PEMToDER(bssl::UniquePtr<uint8_t> *out, size_t *out_len, |
| 776 | const char *pem) { |
| 777 | bssl::UniquePtr<BIO> bio(BIO_new_mem_buf(pem, strlen(pem))); |
| 778 | if (!bio) { |
| 779 | return false; |
| 780 | } |
| 781 | |
| 782 | char *name, *header; |
| 783 | uint8_t *data; |
| 784 | long data_len; |
| 785 | if (!PEM_read_bio(bio.get(), &name, &header, &data, &data_len)) { |
| 786 | fprintf(stderr, "failed to read PEM data.\n"); |
| 787 | return false; |
| 788 | } |
| 789 | OPENSSL_free(name); |
| 790 | OPENSSL_free(header); |
| 791 | |
| 792 | out->reset(data); |
| 793 | *out_len = data_len; |
| 794 | |
| 795 | return true; |
| 796 | } |
| 797 | |
| 798 | static bool TestFromBuffer() { |
| 799 | size_t data_len; |
| 800 | bssl::UniquePtr<uint8_t> data; |
| 801 | if (!PEMToDER(&data, &data_len, kRootCAPEM)) { |
| 802 | return false; |
| 803 | } |
| 804 | |
| 805 | bssl::UniquePtr<CRYPTO_BUFFER> buf( |
| 806 | CRYPTO_BUFFER_new(data.get(), data_len, nullptr)); |
| 807 | if (!buf) { |
| 808 | return false; |
| 809 | } |
| 810 | |
| 811 | bssl::UniquePtr<X509> root(X509_parse_from_buffer(buf.get())); |
| 812 | if (!root) { |
| 813 | return false; |
| 814 | } |
| 815 | |
| 816 | const uint8_t *enc_pointer = root->cert_info->enc.enc; |
| 817 | const uint8_t *buf_pointer = CRYPTO_BUFFER_data(buf.get()); |
| 818 | if (enc_pointer < buf_pointer || |
| 819 | enc_pointer >= buf_pointer + CRYPTO_BUFFER_len(buf.get())) { |
| 820 | fprintf(stderr, "TestFromBuffer: enc does not alias the buffer.\n"); |
| 821 | return false; |
| 822 | } |
| 823 | |
| 824 | buf.reset(); |
| 825 | |
| 826 | /* This ensures the X509 took a reference to |buf|, otherwise this will be a |
| 827 | * reference to free memory and ASAN should notice. */ |
| 828 | if (enc_pointer[0] != CBS_ASN1_SEQUENCE) { |
| 829 | fprintf(stderr, "TestFromBuffer: enc data is not a SEQUENCE.\n"); |
| 830 | return false; |
| 831 | } |
| 832 | |
| 833 | return true; |
| 834 | } |
| 835 | |
| 836 | static bool TestFromBufferTrailingData() { |
| 837 | size_t data_len; |
| 838 | bssl::UniquePtr<uint8_t> data; |
| 839 | if (!PEMToDER(&data, &data_len, kRootCAPEM)) { |
| 840 | return false; |
| 841 | } |
| 842 | |
| 843 | std::unique_ptr<uint8_t[]> trailing_data(new uint8_t[data_len + 1]); |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 844 | OPENSSL_memcpy(trailing_data.get(), data.get(), data_len); |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 845 | |
| 846 | bssl::UniquePtr<CRYPTO_BUFFER> buf_trailing_data( |
| 847 | CRYPTO_BUFFER_new(trailing_data.get(), data_len + 1, nullptr)); |
| 848 | if (!buf_trailing_data) { |
| 849 | return false; |
| 850 | } |
| 851 | |
| 852 | bssl::UniquePtr<X509> root_trailing_data( |
| 853 | X509_parse_from_buffer(buf_trailing_data.get())); |
| 854 | if (root_trailing_data) { |
| 855 | fprintf(stderr, "TestFromBuffer: trailing data was not rejected.\n"); |
| 856 | return false; |
| 857 | } |
| 858 | |
| 859 | return true; |
| 860 | } |
| 861 | |
| 862 | static bool TestFromBufferModified() { |
| 863 | size_t data_len; |
| 864 | bssl::UniquePtr<uint8_t> data; |
| 865 | if (!PEMToDER(&data, &data_len, kRootCAPEM)) { |
| 866 | return false; |
| 867 | } |
| 868 | |
| 869 | bssl::UniquePtr<CRYPTO_BUFFER> buf( |
| 870 | CRYPTO_BUFFER_new(data.get(), data_len, nullptr)); |
| 871 | if (!buf) { |
| 872 | return false; |
| 873 | } |
| 874 | |
| 875 | bssl::UniquePtr<X509> root(X509_parse_from_buffer(buf.get())); |
| 876 | if (!root) { |
| 877 | return false; |
| 878 | } |
| 879 | |
| 880 | bssl::UniquePtr<ASN1_INTEGER> fourty_two(ASN1_INTEGER_new()); |
| 881 | ASN1_INTEGER_set(fourty_two.get(), 42); |
| 882 | X509_set_serialNumber(root.get(), fourty_two.get()); |
| 883 | |
| 884 | if (i2d_X509(root.get(), nullptr) != static_cast<long>(data_len)) { |
| 885 | fprintf(stderr, |
| 886 | "TestFromBufferModified: i2d_X509 gives different answer before " |
| 887 | "marking as modified.\n"); |
| 888 | return false; |
| 889 | } |
| 890 | |
| 891 | X509_CINF_set_modified(root->cert_info); |
| 892 | |
| 893 | if (i2d_X509(root.get(), nullptr) == static_cast<long>(data_len)) { |
| 894 | fprintf(stderr, |
| 895 | "TestFromBufferModified: i2d_X509 gives same answer after marking " |
| 896 | "as modified.\n"); |
| 897 | return false; |
| 898 | } |
| 899 | |
| 900 | return true; |
| 901 | } |
| 902 | |
| 903 | static bool TestFromBufferReused() { |
| 904 | size_t data_len; |
| 905 | bssl::UniquePtr<uint8_t> data; |
| 906 | if (!PEMToDER(&data, &data_len, kRootCAPEM)) { |
| 907 | return false; |
| 908 | } |
| 909 | |
| 910 | bssl::UniquePtr<CRYPTO_BUFFER> buf( |
| 911 | CRYPTO_BUFFER_new(data.get(), data_len, nullptr)); |
| 912 | if (!buf) { |
| 913 | return false; |
| 914 | } |
| 915 | |
| 916 | bssl::UniquePtr<X509> root(X509_parse_from_buffer(buf.get())); |
| 917 | if (!root) { |
| 918 | return false; |
| 919 | } |
| 920 | |
| 921 | size_t data2_len; |
| 922 | bssl::UniquePtr<uint8_t> data2; |
| 923 | if (!PEMToDER(&data2, &data2_len, kLeafPEM)) { |
| 924 | return false; |
| 925 | } |
| 926 | |
| 927 | X509 *x509p = root.get(); |
| 928 | const uint8_t *inp = data2.get(); |
| 929 | X509 *ret = d2i_X509(&x509p, &inp, data2_len); |
| 930 | if (ret != root.get()) { |
| 931 | fprintf(stderr, |
| 932 | "TestFromBufferReused: d2i_X509 parsed into a different object.\n"); |
| 933 | return false; |
| 934 | } |
| 935 | |
| 936 | if (root->buf != nullptr) { |
| 937 | fprintf(stderr, |
| 938 | "TestFromBufferReused: d2i_X509 didn't clear |buf| pointer.\n"); |
| 939 | return false; |
| 940 | } |
| 941 | |
| 942 | // Free |data2| and ensure that |root| took its own copy. Otherwise the |
| 943 | // following will trigger a use-after-free. |
| 944 | data2.reset(); |
| 945 | |
| 946 | uint8_t *i2d = nullptr; |
| 947 | int i2d_len = i2d_X509(root.get(), &i2d); |
| 948 | if (i2d_len < 0) { |
| 949 | return false; |
| 950 | } |
| 951 | bssl::UniquePtr<uint8_t> i2d_storage(i2d); |
| 952 | |
| 953 | if (!PEMToDER(&data2, &data2_len, kLeafPEM)) { |
| 954 | return false; |
| 955 | } |
| 956 | if (i2d_len != static_cast<long>(data2_len) || |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 957 | OPENSSL_memcmp(data2.get(), i2d, i2d_len) != 0) { |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 958 | fprintf(stderr, "TestFromBufferReused: i2d gave wrong result.\n"); |
| 959 | return false; |
| 960 | } |
| 961 | |
| 962 | if (root->buf != NULL) { |
| 963 | fprintf(stderr, "TestFromBufferReused: X509.buf was not cleared.\n"); |
| 964 | return false; |
| 965 | } |
| 966 | |
| 967 | return true; |
| 968 | } |
| 969 | |
David Benjamin | 1b24967 | 2016-12-06 18:25:50 -0500 | [diff] [blame] | 970 | static bool TestFailedParseFromBuffer() { |
| 971 | static const uint8_t kNonsense[] = {1, 2, 3, 4, 5}; |
| 972 | |
| 973 | bssl::UniquePtr<CRYPTO_BUFFER> buf( |
| 974 | CRYPTO_BUFFER_new(kNonsense, sizeof(kNonsense), nullptr)); |
| 975 | if (!buf) { |
| 976 | return false; |
| 977 | } |
| 978 | |
| 979 | bssl::UniquePtr<X509> cert(X509_parse_from_buffer(buf.get())); |
| 980 | if (cert) { |
| 981 | fprintf(stderr, "Nonsense somehow parsed.\n"); |
| 982 | return false; |
| 983 | } |
| 984 | ERR_clear_error(); |
| 985 | |
| 986 | // Test a buffer with trailing data. |
| 987 | size_t data_len; |
| 988 | bssl::UniquePtr<uint8_t> data; |
| 989 | if (!PEMToDER(&data, &data_len, kRootCAPEM)) { |
| 990 | return false; |
| 991 | } |
| 992 | |
| 993 | std::unique_ptr<uint8_t[]> data_with_trailing_byte(new uint8_t[data_len + 1]); |
Robert Sloan | 69939df | 2017-01-09 10:53:07 -0800 | [diff] [blame^] | 994 | OPENSSL_memcpy(data_with_trailing_byte.get(), data.get(), data_len); |
David Benjamin | 1b24967 | 2016-12-06 18:25:50 -0500 | [diff] [blame] | 995 | data_with_trailing_byte[data_len] = 0; |
| 996 | |
| 997 | bssl::UniquePtr<CRYPTO_BUFFER> buf_with_trailing_byte( |
| 998 | CRYPTO_BUFFER_new(data_with_trailing_byte.get(), data_len + 1, nullptr)); |
| 999 | if (!buf_with_trailing_byte) { |
| 1000 | return false; |
| 1001 | } |
| 1002 | |
| 1003 | bssl::UniquePtr<X509> root( |
| 1004 | X509_parse_from_buffer(buf_with_trailing_byte.get())); |
| 1005 | if (root) { |
| 1006 | fprintf(stderr, "Parsed buffer with trailing byte.\n"); |
| 1007 | return false; |
| 1008 | } |
| 1009 | ERR_clear_error(); |
| 1010 | |
| 1011 | return true; |
| 1012 | } |
| 1013 | |
| 1014 | int main() { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 1015 | CRYPTO_library_init(); |
| 1016 | |
| 1017 | if (!TestVerify() || |
Steven Valdez | bb1ceac | 2016-10-07 10:34:51 -0400 | [diff] [blame] | 1018 | !TestCRL() || |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 1019 | !TestPSS() || |
| 1020 | !TestBadPSSParameters() || |
Steven Valdez | 909b19f | 2016-11-21 15:35:44 -0500 | [diff] [blame] | 1021 | !TestSignCtx() || |
| 1022 | !TestFromBuffer() || |
| 1023 | !TestFromBufferTrailingData() || |
| 1024 | !TestFromBufferModified() || |
David Benjamin | 1b24967 | 2016-12-06 18:25:50 -0500 | [diff] [blame] | 1025 | !TestFromBufferReused() || |
| 1026 | !TestFailedParseFromBuffer()) { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 1027 | return 1; |
| 1028 | } |
| 1029 | |
| 1030 | printf("PASS\n"); |
| 1031 | return 0; |
| 1032 | } |