| OLD | NEW | 
|---|
| 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 "net/der/input.h" | 7 #include "net/der/input.h" | 
| 8 #include "net/der/parse_values.h" | 8 #include "net/der/parse_values.h" | 
| 9 #include "net/der/parser.h" | 9 #include "net/der/parser.h" | 
| 10 | 10 | 
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 346     return false; | 346     return false; | 
| 347 | 347 | 
| 348   // By definition the input was a single TBSCertificate, so there shouldn't be | 348   // By definition the input was a single TBSCertificate, so there shouldn't be | 
| 349   // unconsumed data. | 349   // unconsumed data. | 
| 350   if (parser.HasMore()) | 350   if (parser.HasMore()) | 
| 351     return false; | 351     return false; | 
| 352 | 352 | 
| 353   return true; | 353   return true; | 
| 354 } | 354 } | 
| 355 | 355 | 
|  | 356 // From RFC 5280: | 
|  | 357 // | 
|  | 358 //    Extension  ::=  SEQUENCE  { | 
|  | 359 //            extnID      OBJECT IDENTIFIER, | 
|  | 360 //            critical    BOOLEAN DEFAULT FALSE, | 
|  | 361 //            extnValue   OCTET STRING | 
|  | 362 //                        -- contains the DER encoding of an ASN.1 value | 
|  | 363 //                        -- corresponding to the extension type identified | 
|  | 364 //                        -- by extnID | 
|  | 365 //            } | 
|  | 366 bool ParseExtension(const der::Input& extension_tlv, ParsedExtension* out) { | 
|  | 367   der::Parser parser(extension_tlv); | 
|  | 368 | 
|  | 369   //    Extension  ::=  SEQUENCE  { | 
|  | 370   der::Parser extension_parser; | 
|  | 371   if (!parser.ReadSequence(&extension_parser)) | 
|  | 372     return false; | 
|  | 373 | 
|  | 374   //            extnID      OBJECT IDENTIFIER, | 
|  | 375   if (!extension_parser.ReadTag(der::kOid, &out->oid)) | 
|  | 376     return false; | 
|  | 377 | 
|  | 378   //            critical    BOOLEAN DEFAULT FALSE, | 
|  | 379   out->critical = false; | 
|  | 380   bool has_critical; | 
|  | 381   der::Input critical; | 
|  | 382   if (!extension_parser.ReadOptionalTag(der::kBool, &critical, &has_critical)) | 
|  | 383     return false; | 
|  | 384   if (has_critical) { | 
|  | 385     if (!der::ParseBool(critical, &out->critical)) | 
|  | 386       return false; | 
|  | 387     if (!out->critical) | 
|  | 388       return false;  // DER-encoding requires DEFAULT values be omitted. | 
|  | 389   } | 
|  | 390 | 
|  | 391   //            extnValue   OCTET STRING | 
|  | 392   if (!extension_parser.ReadTag(der::kOctetString, &out->value)) | 
|  | 393     return false; | 
|  | 394 | 
|  | 395   // The Extension type does not have an extension point (everything goes in | 
|  | 396   // extnValue). | 
|  | 397   if (extension_parser.HasMore()) | 
|  | 398     return false; | 
|  | 399 | 
|  | 400   // By definition the input was a single Extension sequence, so there shouldn't | 
|  | 401   // be unconsumed data. | 
|  | 402   if (parser.HasMore()) | 
|  | 403     return false; | 
|  | 404 | 
|  | 405   return true; | 
|  | 406 } | 
|  | 407 | 
| 356 }  // namespace net | 408 }  // namespace net | 
| OLD | NEW | 
|---|