OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/cert/ocsp_parser.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" |
| 9 #include "net/base/test_data_directory.h" |
| 10 #include "net/cert/x509_certificate.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace net { |
| 14 |
| 15 namespace ct { |
| 16 |
| 17 class OCSPParserTest : public ::testing::Test { |
| 18 public: |
| 19 void SetUp() override {} |
| 20 |
| 21 protected: |
| 22 scoped_refptr<X509Certificate> test_cert_; |
| 23 }; |
| 24 |
| 25 TEST_F(OCSPParserTest, ParseOCSPResponse) { |
| 26 const uint8_t data[] = { |
| 27 0x30, 0x82, 0x1, 0x46, 0xa, 0x1, 0x0, 0xa0, 0x82, 0x1, 0x3f, 0x30, |
| 28 0x82, 0x1, 0x3b, 0x6, 0x9, 0x2b, 0x6, 0x1, 0x5, 0x5, 0x7, 0x30, |
| 29 0x1, 0x1, 0x4, 0x82, 0x1, 0x2c, 0x30, 0x82, 0x1, 0x28, 0x30, 0x81, |
| 30 0x92, 0xa2, 0x16, 0x4, 0x14, 0x4e, 0xdf, 0xdf, 0x5f, 0xf9, 0xc9, 0xf, |
| 31 0xfa, 0xcf, 0xca, 0x66, 0xe7, 0xfb, 0xc4, 0x36, 0xbc, 0x39, 0xee, 0x3f, |
| 32 0xc7, 0x18, 0xf, 0x32, 0x30, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, |
| 33 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x67, 0x30, 0x65, 0x30, 0x3d, |
| 34 0x30, 0x9, 0x6, 0x5, 0x2b, 0xe, 0x3, 0x2, 0x1a, 0x5, 0x0, 0x4, |
| 35 0x14, 0xcc, 0x8b, 0x23, 0xc2, 0x61, 0x6f, 0xcd, 0x1a, 0xde, 0xd2, 0xd2, |
| 36 0x32, 0xbd, 0x9a, 0x37, 0xf8, 0x45, 0x40, 0xc3, 0x75, 0x4, 0x14, 0x4e, |
| 37 0xdf, 0xdf, 0x5f, 0xf9, 0xc9, 0xf, 0xfa, 0xcf, 0xca, 0x66, 0xe7, 0xfb, |
| 38 0xc4, 0x36, 0xbc, 0x39, 0xee, 0x3f, 0xc7, 0x13, 0x4, 0x31, 0x32, 0x33, |
| 39 0x34, 0x80, 0x0, 0x18, 0xf, 0x32, 0x30, 0x31, 0x30, 0x30, 0x31, 0x30, |
| 40 0x31, 0x30, 0x36, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, 0x11, 0x18, 0xf, |
| 41 0x32, 0x30, 0x33, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x36, 0x30, 0x30, |
| 42 0x30, 0x30, 0x5a, 0x30, 0xd, 0x6, 0x9, 0x2a, 0x86, 0x48, 0x86, 0xf7, |
| 43 0xd, 0x1, 0x1, 0xb, 0x5, 0x0, 0x3, 0x81, 0x81, 0x0, 0xc, 0x52, |
| 44 0x5f, 0xda, 0x11, 0x44, 0xed, 0xbb, 0xf6, 0x19, 0xa3, 0x37, 0xfa, 0x1b, |
| 45 0xd2, 0xbb, 0xd1, 0x58, 0x48, 0xd5, 0xb9, 0x6b, 0xf, 0x4, 0xbc, 0x1b, |
| 46 0xc, 0x6e, 0x5c, 0x32, 0x28, 0x8d, 0x20, 0x5c, 0x35, 0x84, 0xe8, 0x41, |
| 47 0xe5, 0xca, 0xec, 0x6f, 0xe0, 0xe8, 0x3, 0x7, 0x5b, 0xdf, 0xdc, 0x1d, |
| 48 0xa2, 0xa, 0xab, 0xe9, 0x11, 0xd8, 0x5, 0x8a, 0xbf, 0xd8, 0x74, 0x85, |
| 49 0xd8, 0x54, 0x8f, 0xc2, 0x4b, 0x86, 0xa0, 0x57, 0x17, 0xb0, 0xab, 0xec, |
| 50 0x15, 0xf4, 0xb2, 0xca, 0xfa, 0x34, 0xb5, 0xeb, 0x9a, 0x7c, 0xc7, 0x37, |
| 51 0x83, 0xd6, 0xf, 0x9e, 0x5d, 0x7c, 0xd8, 0x3e, 0x3f, 0x7a, 0x53, 0x12, |
| 52 0x76, 0x95, 0xd6, 0x72, 0x2c, 0x2b, 0x27, 0x24, 0xad, 0xf0, 0x84, 0x53, |
| 53 0xb0, 0x95, 0x4f, 0x11, 0x48, 0xc2, 0x64, 0xb6, 0x7, 0x90, 0xc1, 0xdc, |
| 54 0x8d, 0xf3, 0x91, 0xb1, 0x3, 0x3f}; |
| 55 std::string resp(data, data + sizeof(data)); |
| 56 OCSPResponse parsed_ocsp; |
| 57 ASSERT_TRUE(ParseOCSPResponse(resp, &parsed_ocsp)); |
| 58 const unsigned long kResponseSize = 1; |
| 59 ASSERT_EQ(kResponseSize, parsed_ocsp.data.responses.size()); |
| 60 ASSERT_EQ(OCSP_CERT_GOOD, parsed_ocsp.data.responses[0].cert_status); |
| 61 } |
| 62 |
| 63 } // namespace ct |
| 64 |
| 65 } // namespace net |
OLD | NEW |