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

Side by Side Diff: net/base/x509_cert_types.cc

Issue 6793026: Initial support for HSTS certificate locking. This isn't a finished work, but (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/x509_cert_types.h" 5 #include "net/base/x509_cert_types.h"
6 6
7 #include "net/base/x509_certificate.h" 7 #include "net/base/x509_certificate.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
11 #include "base/string_util.h"
11 #include "base/time.h" 12 #include "base/time.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 namespace { 16 namespace {
16 17
17 // Helper for ParseCertificateDate. |*field| must contain at least 18 // Helper for ParseCertificateDate. |*field| must contain at least
18 // |field_len| characters. |*field| will be advanced by |field_len| on exit. 19 // |field_len| characters. |*field| will be advanced by |field_len| on exit.
19 // |*ok| is set to false if there is an error in parsing the number, but left 20 // |*ok| is set to false if there is an error in parsing the number, but left
20 // untouched otherwise. Returns the parsed integer. 21 // untouched otherwise. Returns the parsed integer.
21 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { 22 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) {
22 int result = 0; 23 int result = 0;
23 *ok &= base::StringToInt(*field, *field + field_len, &result); 24 *ok &= base::StringToInt(*field, *field + field_len, &result);
24 *field += field_len; 25 *field += field_len;
25 return result; 26 return result;
26 } 27 }
27 28
28 } // namespace 29 } // namespace
29 30
31 std::string SHA1Fingerprint::GetString() const {
32 std::string hash;
33 for (size_t i = 0; i < sizeof(data); ++i)
34 hash += StringPrintf("%02x", data[i]);
35 return hash;
36 }
37
30 CertPrincipal::CertPrincipal() { 38 CertPrincipal::CertPrincipal() {
31 } 39 }
32 40
33 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} 41 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {}
34 42
35 CertPrincipal::~CertPrincipal() { 43 CertPrincipal::~CertPrincipal() {
36 } 44 }
37 45
38 std::string CertPrincipal::GetDisplayName() const { 46 std::string CertPrincipal::GetDisplayName() const {
39 if (!common_name.empty()) 47 if (!common_name.empty())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 valid &= exploded.HasValidValues(); 125 valid &= exploded.HasValidValues();
118 126
119 if (!valid) 127 if (!valid)
120 return false; 128 return false;
121 129
122 *time = base::Time::FromUTCExploded(exploded); 130 *time = base::Time::FromUTCExploded(exploded);
123 return true; 131 return true;
124 } 132 }
125 133
126 } // namespace net 134 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698