/* Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <gtest/gtest.h> #include <openssl/bytestring.h> #include <openssl/crypto.h> #include <openssl/mem.h> #include <openssl/pem.h> #include <openssl/pkcs7.h> #include <openssl/stack.h> #include <openssl/x509.h> #include "../internal.h" #include "../test/test_util.h" // kPKCS7NSS contains the certificate chain of mail.google.com, as saved by NSS // using the Chrome UI. static const uint8_t kPKCS7NSS[] = …; // kPKCS7Windows is the Equifax root certificate, as exported by Windows 7. static const uint8_t kPKCS7Windows[] = …; // kOpenSSLCRL is the Equifax CRL, converted to PKCS#7 form by: // openssl crl2pkcs7 -inform DER -in secureca.crl static const uint8_t kOpenSSLCRL[] = …; // kPEMCert is the result of exporting the mail.google.com certificate from // Chrome and then running it through: // openssl pkcs7 -inform DER -in mail.google.com -outform PEM static const char kPEMCert[] = …; /* kPEMCRL is the result of downloading the Equifax CRL and running: openssl crl2pkcs7 -inform DER -in secureca.crl */ static const char kPEMCRL[] = …; static void TestCertReparse(const uint8_t *der_bytes, size_t der_len) { … } static void TestCRLReparse(const uint8_t *der_bytes, size_t der_len) { … } static void TestPEMCerts(const char *pem) { … } static void TestPEMCRLs(const char *pem) { … } TEST(PKCS7Test, CertReparseNSS) { … } TEST(PKCS7Test, CertReparseWindows) { … } TEST(PKCS7Test, CrlReparse) { … } TEST(PKCS7Test, PEMCerts) { … } TEST(PKCS7Test, PEMCRLs) { … } // Test that we output certificates in the canonical DER order. TEST(PKCS7Test, SortCerts) { … } // Test that we output certificates in the canonical DER order, using the // CRYPTO_BUFFER version of the parse and bundle functions. TEST(PKCS7Test, SortCertsRaw) { … } // Test that we output CRLs in the canonical DER order. TEST(PKCS7Test, SortCRLs) { … } TEST(PKCS7Test, KernelModuleSigning) { … }