Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: net/cert/internal/parsed_certificate.cc

Issue 2327973002: Add CertErrors* parameter to the main Certificate parsing functions. (Closed)
Patch Set: StringPiece is kind of dangerous... Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/internal/parsed_certificate.h ('k') | net/cert/internal/path_builder_pkits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/parsed_certificate.cc
diff --git a/net/cert/internal/parsed_certificate.cc b/net/cert/internal/parsed_certificate.cc
index a3e5cc30c901e2a666f4a14b812b513da205f428..1db530e5245449abbe580ca8df384ebb2da144bc 100644
--- a/net/cert/internal/parsed_certificate.cc
+++ b/net/cert/internal/parsed_certificate.cc
@@ -24,11 +24,61 @@ WARN_UNUSED_RESULT bool GetSequenceValue(const der::Input& tlv,
ParsedCertificate::ParsedCertificate() {}
ParsedCertificate::~ParsedCertificate() {}
-scoped_refptr<ParsedCertificate> ParsedCertificate::CreateFromCertificateData(
+scoped_refptr<ParsedCertificate> ParsedCertificate::Create(
+ const uint8_t* data,
+ size_t length,
+ const ParseCertificateOptions& options,
+ CertErrors* errors) {
+ return CreateInternal(data, length, DataSource::INTERNAL_COPY, options,
+ errors);
+}
+
+scoped_refptr<ParsedCertificate> ParsedCertificate::Create(
+ const base::StringPiece& data,
+ const ParseCertificateOptions& options,
+ CertErrors* errors) {
+ return ParsedCertificate::Create(
+ reinterpret_cast<const uint8_t*>(data.data()), data.size(), options,
+ errors);
+}
+
+bool ParsedCertificate::CreateAndAddToVector(
+ const uint8_t* data,
+ size_t length,
+ const ParseCertificateOptions& options,
+ ParsedCertificateList* chain,
+ CertErrors* errors) {
+ scoped_refptr<ParsedCertificate> cert(Create(data, length, options, errors));
+ if (!cert)
+ return false;
+ chain->push_back(std::move(cert));
+ return true;
+}
+
+bool ParsedCertificate::CreateAndAddToVector(
+ const base::StringPiece& data,
+ const ParseCertificateOptions& options,
+ ParsedCertificateList* chain,
+ CertErrors* errors) {
+ return CreateAndAddToVector(reinterpret_cast<const uint8_t*>(data.data()),
+ data.size(), options, chain, errors);
+}
+
+scoped_refptr<ParsedCertificate> ParsedCertificate::CreateWithoutCopyingUnsafe(
+ const uint8_t* data,
+ size_t length,
+ const ParseCertificateOptions& options,
+ CertErrors* errors) {
+ return CreateInternal(data, length, DataSource::EXTERNAL_REFERENCE, options,
+ errors);
+}
+
+scoped_refptr<ParsedCertificate> ParsedCertificate::CreateInternal(
const uint8_t* data,
size_t length,
DataSource source,
- const ParseCertificateOptions& options) {
+ const ParseCertificateOptions& options,
+ CertErrors* errors) {
scoped_refptr<ParsedCertificate> result(new ParsedCertificate);
switch (source) {
@@ -44,7 +94,7 @@ scoped_refptr<ParsedCertificate> ParsedCertificate::CreateFromCertificateData(
if (!ParseCertificate(result->cert_, &result->tbs_certificate_tlv_,
&result->signature_algorithm_tlv_,
- &result->signature_value_)) {
+ &result->signature_value_, errors)) {
return nullptr;
}
@@ -149,26 +199,4 @@ scoped_refptr<ParsedCertificate> ParsedCertificate::CreateFromCertificateData(
return result;
}
-scoped_refptr<ParsedCertificate> ParsedCertificate::CreateFromCertificateCopy(
- const base::StringPiece& data,
- const ParseCertificateOptions& options) {
- return ParsedCertificate::CreateFromCertificateData(
- reinterpret_cast<const uint8_t*>(data.data()), data.size(),
- DataSource::INTERNAL_COPY, options);
-}
-
-bool ParsedCertificate::CreateAndAddToVector(
- const uint8_t* data,
- size_t length,
- DataSource source,
- const ParseCertificateOptions& options,
- ParsedCertificateList* chain) {
- scoped_refptr<ParsedCertificate> cert(
- CreateFromCertificateData(data, length, source, options));
- if (!cert)
- return false;
- chain->push_back(std::move(cert));
- return true;
-}
-
} // namespace net
« no previous file with comments | « net/cert/internal/parsed_certificate.h ('k') | net/cert/internal/path_builder_pkits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698