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

Side by Side Diff: net/der/input.cc

Issue 1125333005: RFC 2459 name comparison. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/der/input.h" 8 #include "net/der/input.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 namespace der { 12 namespace der {
13 13
14 Input::Input() : data_(nullptr), len_(0) { 14 Input::Input() : data_(nullptr), len_(0) {
15 } 15 }
16 16
17 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) { 17 Input::Input(const uint8_t* data, size_t len) : data_(data), len_(len) {
18 } 18 }
19 19
20 bool Input::Equals(const Input& other) const { 20 bool Input::Equals(const Input& other) const {
21 if (len_ != other.len_) 21 if (len_ != other.len_)
22 return false; 22 return false;
23 return memcmp(data_, other.data_, len_) == 0; 23 return memcmp(data_, other.data_, len_) == 0;
24 } 24 }
25 25
26 std::string Input::AsString() const {
27 return std::string(reinterpret_cast<const char*>(data_), len_);
28 }
29
26 BitString::BitString(const Input& bytes, uint8_t unused_bits) 30 BitString::BitString(const Input& bytes, uint8_t unused_bits)
27 : bytes_(bytes), unused_bits_(unused_bits) { 31 : bytes_(bytes), unused_bits_(unused_bits) {
28 DCHECK_LT(unused_bits, 8); 32 DCHECK_LT(unused_bits, 8);
29 DCHECK(unused_bits == 0 || bytes.Length() != 0); 33 DCHECK(unused_bits == 0 || bytes.Length() != 0);
30 } 34 }
31 35
32 ByteReader::ByteReader(const Input& in) 36 ByteReader::ByteReader(const Input& in)
33 : data_(in.UnsafeData()), len_(in.Length()) { 37 : data_(in.UnsafeData()), len_(in.Length()) {
34 } 38 }
35 39
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 97
94 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) { 98 Mark::Mark(const uint8_t* ptr) : ptr_(ptr) {
95 } 99 }
96 100
97 Mark::Mark() : ptr_(nullptr) { 101 Mark::Mark() : ptr_(nullptr) {
98 } 102 }
99 103
100 } // namespace der 104 } // namespace der
101 105
102 } // namespace net 106 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698