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

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

Issue 2870323002: Add parsing for RFC 5280's InhibitAnyPolicy. (Closed)
Patch Set: fix comment Created 3 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
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 "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "net/cert/internal/cert_errors.h" 10 #include "net/cert/internal/cert_errors.h"
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 der::Input AdOcspOid() { 544 der::Input AdOcspOid() {
545 // From RFC 5280: 545 // From RFC 5280:
546 // 546 //
547 // id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 } 547 // id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
548 // 548 //
549 // In dotted notation: 1.3.6.1.5.5.7.48.1 549 // In dotted notation: 1.3.6.1.5.5.7.48.1
550 static const uint8_t oid[] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01}; 550 static const uint8_t oid[] = {0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01};
551 return der::Input(oid); 551 return der::Input(oid);
552 } 552 }
553 553
554 der::Input InhibitAnyPolicyOid() {
555 // From RFC 5280:
556 //
557 // id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 }
558 //
559 // In dotted notation: 2.5.29.54
560 static const uint8_t oid[] = {0x55, 0x1d, 0x36};
561 return der::Input(oid);
562 }
563
554 NET_EXPORT bool ParseExtensions( 564 NET_EXPORT bool ParseExtensions(
555 const der::Input& extensions_tlv, 565 const der::Input& extensions_tlv,
556 std::map<der::Input, ParsedExtension>* extensions) { 566 std::map<der::Input, ParsedExtension>* extensions) {
557 der::Parser parser(extensions_tlv); 567 der::Parser parser(extensions_tlv);
558 568
559 // Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension 569 // Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
560 der::Parser extensions_parser; 570 der::Parser extensions_parser;
561 if (!parser.ReadSequence(&extensions_parser)) 571 if (!parser.ReadSequence(&extensions_parser))
562 return false; 572 return false;
563 573
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 out->inhibit_policy_mapping = 0; 797 out->inhibit_policy_mapping = 0;
788 } 798 }
789 799
790 // There should be no remaining data. 800 // There should be no remaining data.
791 if (sequence_parser.HasMore() || parser.HasMore()) 801 if (sequence_parser.HasMore() || parser.HasMore())
792 return false; 802 return false;
793 803
794 return true; 804 return true;
795 } 805 }
796 806
807 // From RFC 5280:
808 //
809 // InhibitAnyPolicy ::= SkipCerts
810 //
811 // SkipCerts ::= INTEGER (0..MAX)
812 bool ParseInhibitAnyPolicy(const der::Input& inhibit_any_policy_tlv,
813 uint8_t* out) {
814 der::Parser parser(inhibit_any_policy_tlv);
815
816 // TODO(eroman): Surface reason for failure if length was longer than uint8.
817 if (!parser.ReadUint8(out))
818 return false;
819
820 // There should be no remaining data.
821 if (parser.HasMore())
822 return false;
823
824 return true;
825 }
826
797 } // namespace net 827 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698