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

Side by Side Diff: net/cert/internal/parse_certificate.cc

Issue 1969293002: Remove net::ParsedCertificate struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « net/cert/internal/parse_certificate.h ('k') | net/cert/internal/parse_certificate_fuzzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_certificate.h" 5 #include "net/cert/internal/parse_certificate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "net/der/input.h" 9 #include "net/der/input.h"
10 #include "net/der/parse_values.h" 10 #include "net/der/parse_values.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // guarantees they are all zero. 143 // guarantees they are all zero.
144 for (size_t i = 0; i < bits.bytes().Length(); ++i) { 144 for (size_t i = 0; i < bits.bytes().Length(); ++i) {
145 if (bits.bytes().UnsafeData()[i] != 0) 145 if (bits.bytes().UnsafeData()[i] != 0)
146 return false; 146 return false;
147 } 147 }
148 return true; 148 return true;
149 } 149 }
150 150
151 } // namespace 151 } // namespace
152 152
153 ParsedCertificate::ParsedCertificate() {}
154
155 ParsedCertificate::~ParsedCertificate() {}
156
157 ParsedTbsCertificate::ParsedTbsCertificate() {} 153 ParsedTbsCertificate::ParsedTbsCertificate() {}
158 154
159 ParsedTbsCertificate::~ParsedTbsCertificate() {} 155 ParsedTbsCertificate::~ParsedTbsCertificate() {}
160 156
161 bool VerifySerialNumber(const der::Input& value) { 157 bool VerifySerialNumber(const der::Input& value) {
162 bool unused_negative; 158 bool unused_negative;
163 if (!der::IsValidInteger(value, &unused_negative)) 159 if (!der::IsValidInteger(value, &unused_negative))
164 return false; 160 return false;
165 161
166 // Check if the serial number is too long per RFC 5280. 162 // Check if the serial number is too long per RFC 5280.
167 if (value.Length() > 20) 163 if (value.Length() > 20)
168 return false; 164 return false;
169 165
170 return true; 166 return true;
171 } 167 }
172 168
173 bool ParseCertificate(const der::Input& certificate_tlv, 169 bool ParseCertificate(const der::Input& certificate_tlv,
174 ParsedCertificate* out) { 170 der::Input* out_tbs_certificate_tlv,
171 der::Input* out_signature_algorithm_tlv,
172 der::BitString* out_signature_value) {
175 der::Parser parser(certificate_tlv); 173 der::Parser parser(certificate_tlv);
176 174
177 // Certificate ::= SEQUENCE { 175 // Certificate ::= SEQUENCE {
178 der::Parser certificate_parser; 176 der::Parser certificate_parser;
179 if (!parser.ReadSequence(&certificate_parser)) 177 if (!parser.ReadSequence(&certificate_parser))
180 return false; 178 return false;
181 179
182 // tbsCertificate TBSCertificate, 180 // tbsCertificate TBSCertificate,
183 if (!ReadSequenceTLV(&certificate_parser, &out->tbs_certificate_tlv)) 181 if (!ReadSequenceTLV(&certificate_parser, out_tbs_certificate_tlv))
184 return false; 182 return false;
185 183
186 // signatureAlgorithm AlgorithmIdentifier, 184 // signatureAlgorithm AlgorithmIdentifier,
187 if (!ReadSequenceTLV(&certificate_parser, &out->signature_algorithm_tlv)) 185 if (!ReadSequenceTLV(&certificate_parser, out_signature_algorithm_tlv))
188 return false; 186 return false;
189 187
190 // signatureValue BIT STRING } 188 // signatureValue BIT STRING }
191 if (!certificate_parser.ReadBitString(&out->signature_value)) 189 if (!certificate_parser.ReadBitString(out_signature_value))
192 return false; 190 return false;
193 191
194 // There isn't an extension point at the end of Certificate. 192 // There isn't an extension point at the end of Certificate.
195 if (certificate_parser.HasMore()) 193 if (certificate_parser.HasMore())
196 return false; 194 return false;
197 195
198 // By definition the input was a single Certificate, so there shouldn't be 196 // By definition the input was a single Certificate, so there shouldn't be
199 // unconsumed data. 197 // unconsumed data.
200 if (parser.HasMore()) 198 if (parser.HasMore())
201 return false; 199 return false;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // 571 //
574 // When the keyUsage extension appears in a certificate, at least 572 // When the keyUsage extension appears in a certificate, at least
575 // one of the bits MUST be set to 1. 573 // one of the bits MUST be set to 1.
576 if (BitStringIsAllZeros(*key_usage)) 574 if (BitStringIsAllZeros(*key_usage))
577 return false; 575 return false;
578 576
579 return true; 577 return true;
580 } 578 }
581 579
582 } // namespace net 580 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/parse_certificate.h ('k') | net/cert/internal/parse_certificate_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698