| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/cert/internal/parse_ocsp.h" | 5 #include "net/cert/internal/parse_ocsp.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
| 10 #include "net/cert/internal/test_helpers.h" | 10 #include "net/cert/internal/test_helpers.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 {"CERTIFICATE", &cert_data}, | 41 {"CERTIFICATE", &cert_data}, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 if (!ReadTestDataFromPemFile(GetFilePath(file_name), mappings)) | 44 if (!ReadTestDataFromPemFile(GetFilePath(file_name), mappings)) |
| 45 return PARSE_CERT; | 45 return PARSE_CERT; |
| 46 | 46 |
| 47 der::Input ocsp_input(&ocsp_data); | 47 der::Input ocsp_input(&ocsp_data); |
| 48 der::Input ca_input(&ca_data); | 48 der::Input ca_input(&ca_data); |
| 49 der::Input cert_input(&cert_data); | 49 der::Input cert_input(&cert_data); |
| 50 | 50 |
| 51 ParsedCertificate issuer; | 51 der::Input issuer_tbs_certificate_tlv; |
| 52 ParsedCertificate cert; | 52 der::Input issuer_signature_algorithm_tlv; |
| 53 if (!ParseCertificate(ca_input, &issuer)) | 53 der::BitString issuer_signature_value; |
| 54 der::Input cert_tbs_certificate_tlv; |
| 55 der::Input cert_signature_algorithm_tlv; |
| 56 der::BitString cert_signature_value; |
| 57 if (!ParseCertificate(ca_input, &issuer_tbs_certificate_tlv, |
| 58 &issuer_signature_algorithm_tlv, |
| 59 &issuer_signature_value)) |
| 54 return PARSE_CERT; | 60 return PARSE_CERT; |
| 55 if (!ParseCertificate(cert_input, &cert)) | 61 if (!ParseCertificate(cert_input, &cert_tbs_certificate_tlv, |
| 62 &cert_signature_algorithm_tlv, &cert_signature_value)) |
| 56 return PARSE_CERT; | 63 return PARSE_CERT; |
| 57 OCSPResponse parsed_ocsp; | 64 OCSPResponse parsed_ocsp; |
| 58 OCSPResponseData parsed_ocsp_data; | 65 OCSPResponseData parsed_ocsp_data; |
| 59 if (!ParseOCSPResponse(ocsp_input, &parsed_ocsp)) | 66 if (!ParseOCSPResponse(ocsp_input, &parsed_ocsp)) |
| 60 return PARSE_OCSP; | 67 return PARSE_OCSP; |
| 61 if (parsed_ocsp.status != OCSPResponse::ResponseStatus::SUCCESSFUL) | 68 if (parsed_ocsp.status != OCSPResponse::ResponseStatus::SUCCESSFUL) |
| 62 return OCSP_NOT_SUCCESSFUL; | 69 return OCSP_NOT_SUCCESSFUL; |
| 63 if (!ParseOCSPResponseData(parsed_ocsp.data, &parsed_ocsp_data)) | 70 if (!ParseOCSPResponseData(parsed_ocsp.data, &parsed_ocsp_data)) |
| 64 return PARSE_OCSP_DATA; | 71 return PARSE_OCSP_DATA; |
| 65 | 72 |
| 66 OCSPCertStatus status; | 73 OCSPCertStatus status; |
| 67 | 74 |
| 68 if (!GetOCSPCertStatus(parsed_ocsp_data, issuer, cert, &status)) | 75 if (!GetOCSPCertStatus(parsed_ocsp_data, issuer_tbs_certificate_tlv, |
| 76 cert_tbs_certificate_tlv, &status)) |
| 69 return PARSE_OCSP_SINGLE_RESPONSE; | 77 return PARSE_OCSP_SINGLE_RESPONSE; |
| 70 | 78 |
| 71 switch (status.status) { | 79 switch (status.status) { |
| 72 case OCSPCertStatus::Status::GOOD: | 80 case OCSPCertStatus::Status::GOOD: |
| 73 return OCSP_SUCCESS; | 81 return OCSP_SUCCESS; |
| 74 case OCSPCertStatus::Status::REVOKED: | 82 case OCSPCertStatus::Status::REVOKED: |
| 75 return OCSP_SUCCESS_REVOKED; | 83 return OCSP_SUCCESS_REVOKED; |
| 76 case OCSPCertStatus::Status::UNKNOWN: | 84 case OCSPCertStatus::Status::UNKNOWN: |
| 77 return OCSP_SUCCESS_UNKNOWN; | 85 return OCSP_SUCCESS_UNKNOWN; |
| 78 } | 86 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 176 |
| 169 TEST(ParseOCSPTest, OCSPOCSPSingleExtension) { | 177 TEST(ParseOCSPTest, OCSPOCSPSingleExtension) { |
| 170 ASSERT_EQ(OCSP_SUCCESS, ParseOCSP("has_single_extension.pem")); | 178 ASSERT_EQ(OCSP_SUCCESS, ParseOCSP("has_single_extension.pem")); |
| 171 } | 179 } |
| 172 | 180 |
| 173 TEST(ParseOCSPTest, OCSPMissingResponse) { | 181 TEST(ParseOCSPTest, OCSPMissingResponse) { |
| 174 ASSERT_EQ(PARSE_OCSP_SINGLE_RESPONSE, ParseOCSP("missing_response.pem")); | 182 ASSERT_EQ(PARSE_OCSP_SINGLE_RESPONSE, ParseOCSP("missing_response.pem")); |
| 175 } | 183 } |
| 176 | 184 |
| 177 } // namespace net | 185 } // namespace net |
| OLD | NEW |