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

Unified Diff: net/cert/asn1_util.cc

Issue 1573243011: Refactor der::Input helper methods into new constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 11 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 | « no previous file | net/cert/internal/certificate_policies_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/asn1_util.cc
diff --git a/net/cert/asn1_util.cc b/net/cert/asn1_util.cc
index 7f2ebc9345d41e5c86ecaf7226ebcb22f8012945..315ca75e648c527f500af42178a5a54fd68773ed 100644
--- a/net/cert/asn1_util.cc
+++ b/net/cert/asn1_util.cc
@@ -70,26 +70,17 @@ bool SeekToSPKI(der::Input in, der::Parser* tbs_certificate) {
return true;
}
-der::Input InputFromStringPiece(base::StringPiece in) {
- return der::Input(reinterpret_cast<const uint8_t*>(in.data()), in.length());
-}
-
-base::StringPiece StringPieceFromInput(der::Input in) {
- return base::StringPiece(reinterpret_cast<const char*>(in.UnsafeData()),
- in.Length());
-}
-
} // namespace
bool ExtractSPKIFromDERCert(base::StringPiece cert,
base::StringPiece* spki_out) {
der::Parser parser;
- if (!SeekToSPKI(InputFromStringPiece(cert), &parser))
+ if (!SeekToSPKI(der::Input(cert), &parser))
return false;
der::Input spki;
if (!parser.ReadRawTLV(&spki))
return false;
- *spki_out = StringPieceFromInput(spki);
+ *spki_out = spki.AsStringPiece();
return true;
}
@@ -105,7 +96,7 @@ bool ExtractSubjectPublicKeyFromSPKI(base::StringPiece spki,
// parameters ANY DEFINED BY algorithm OPTIONAL }
// Step into SubjectPublicKeyInfo sequence.
- der::Parser parser(InputFromStringPiece(spki));
+ der::Parser parser((der::Input(spki)));
der::Parser spki_parser;
if (!parser.ReadSequence(&spki_parser))
return false;
@@ -118,7 +109,7 @@ bool ExtractSubjectPublicKeyFromSPKI(base::StringPiece spki,
der::Input spk;
if (!spki_parser.ReadTag(der::kBitString, &spk))
return false;
- *spk_out = StringPieceFromInput(spk);
+ *spk_out = spk.AsStringPiece();
return true;
}
@@ -130,7 +121,7 @@ bool ExtractCRLURLsFromDERCert(base::StringPiece cert,
bool present;
der::Parser tbs_cert_parser;
- if (!SeekToSPKI(InputFromStringPiece(cert), &tbs_cert_parser))
+ if (!SeekToSPKI(der::Input(cert), &tbs_cert_parser))
return false;
// From RFC 5280, section 4.1
@@ -281,7 +272,7 @@ bool ExtractCRLURLsFromDERCert(base::StringPiece cert,
}
if (present) {
// This does not validate that |url| is a valid IA5String.
- tmp_urls_out.push_back(StringPieceFromInput(url));
+ tmp_urls_out.push_back(url.AsStringPiece());
} else {
der::Tag unused_tag;
der::Input unused_value;
« no previous file with comments | « no previous file | net/cert/internal/certificate_policies_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698