summaryrefslogtreecommitdiff
path: root/chromium/net/der
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-05-09 14:22:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-05-09 15:11:45 +0000
commit2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch)
treee75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/net/der
parenta4f3d46271c57e8155ba912df46a05559d14726e (diff)
downloadqtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion. Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/net/der')
-rw-r--r--chromium/net/der/input.cc16
-rw-r--r--chromium/net/der/input.h9
-rw-r--r--chromium/net/der/input_unittest.cc10
-rw-r--r--chromium/net/der/parser.cc14
-rw-r--r--chromium/net/der/parser.h18
-rw-r--r--chromium/net/der/tag.cc8
-rw-r--r--chromium/net/der/tag.h5
7 files changed, 53 insertions, 27 deletions
diff --git a/chromium/net/der/input.cc b/chromium/net/der/input.cc
index 871f9f4ec7d..49955905fa2 100644
--- a/chromium/net/der/input.cc
+++ b/chromium/net/der/input.cc
@@ -24,12 +24,6 @@ Input::Input(const base::StringPiece& in)
Input::Input(const std::string* s) : Input(base::StringPiece(*s)) {}
-bool Input::Equals(const Input& other) const {
- if (len_ != other.len_)
- return false;
- return memcmp(data_, other.data_, len_) == 0;
-}
-
std::string Input::AsString() const {
return std::string(reinterpret_cast<const char*>(data_), len_);
}
@@ -38,6 +32,16 @@ base::StringPiece Input::AsStringPiece() const {
return base::StringPiece(reinterpret_cast<const char*>(data_), len_);
}
+bool operator==(const Input& lhs, const Input& rhs) {
+ if (lhs.Length() != rhs.Length())
+ return false;
+ return memcmp(lhs.UnsafeData(), rhs.UnsafeData(), lhs.Length()) == 0;
+}
+
+bool operator!=(const Input& lhs, const Input& rhs) {
+ return !(lhs == rhs);
+}
+
bool operator<(const Input& lhs, const Input& rhs) {
return std::lexicographical_compare(
lhs.UnsafeData(), lhs.UnsafeData() + lhs.Length(), rhs.UnsafeData(),
diff --git a/chromium/net/der/input.h b/chromium/net/der/input.h
index 9c3f5ca87a4..121a9e0770a 100644
--- a/chromium/net/der/input.h
+++ b/chromium/net/der/input.h
@@ -63,9 +63,6 @@ class NET_EXPORT_PRIVATE Input {
// Returns the length in bytes of an Input's data.
size_t Length() const { return len_; }
- // Return true if the Input's data and |other|'s data are byte-wise equal.
- bool Equals(const Input& other) const;
-
// Returns a pointer to the Input's data. This method is marked as "unsafe"
// because access to the Input's data should be done through ByteReader
// instead. This method should only be used where using a ByteReader truly
@@ -91,6 +88,12 @@ class NET_EXPORT_PRIVATE Input {
size_t len_;
};
+// Return true if |lhs|'s data and |rhs|'s data are byte-wise equal.
+NET_EXPORT_PRIVATE bool operator==(const Input& lhs, const Input& rhs);
+
+// Return true if |lhs|'s data and |rhs|'s data are not byte-wise equal.
+NET_EXPORT_PRIVATE bool operator!=(const Input& lhs, const Input& rhs);
+
// Returns true if |lhs|'s data is lexicographically less than |rhs|'s data.
NET_EXPORT_PRIVATE bool operator<(const Input& lhs, const Input& rhs);
diff --git a/chromium/net/der/input_unittest.cc b/chromium/net/der/input_unittest.cc
index e7193b08b52..6fcb436606f 100644
--- a/chromium/net/der/input_unittest.cc
+++ b/chromium/net/der/input_unittest.cc
@@ -16,16 +16,16 @@ const uint8_t kInput2[] = {'t', 'e', 'a', 'l'};
TEST(InputTest, Equals) {
Input test(kInput);
Input test2(kInput);
- EXPECT_TRUE(test.Equals(test2));
+ EXPECT_EQ(test, test2);
uint8_t input_copy[arraysize(kInput)] = {0};
memcpy(input_copy, kInput, arraysize(kInput));
Input test_copy(input_copy);
- EXPECT_TRUE(test.Equals(test_copy));
+ EXPECT_EQ(test, test_copy);
Input test_truncated(kInput, arraysize(kInput) - 1);
- EXPECT_FALSE(test.Equals(test_truncated));
- EXPECT_FALSE(test_truncated.Equals(test));
+ EXPECT_NE(test, test_truncated);
+ EXPECT_NE(test_truncated, test);
}
TEST(InputTest, LessThan) {
@@ -53,7 +53,7 @@ TEST(InputTest, StaticArray) {
EXPECT_EQ(arraysize(kInput), input.Length());
Input input2(kInput);
- EXPECT_TRUE(input.Equals(input2));
+ EXPECT_EQ(input, input2);
}
TEST(ByteReaderTest, NoReadPastEnd) {
diff --git a/chromium/net/der/parser.cc b/chromium/net/der/parser.cc
index 6419549cf04..0cb2600f5e6 100644
--- a/chromium/net/der/parser.cc
+++ b/chromium/net/der/parser.cc
@@ -179,6 +179,13 @@ bool Parser::ReadSequence(Parser* out) {
return ReadConstructed(kSequence, out);
}
+bool Parser::ReadUint8(uint8_t* out) {
+ Input encoded_int;
+ if (!ReadTag(kInteger, &encoded_int))
+ return false;
+ return ParseUint8(encoded_int, out);
+}
+
bool Parser::ReadUint64(uint64_t* out) {
Input encoded_int;
if (!ReadTag(kInteger, &encoded_int))
@@ -193,6 +200,13 @@ bool Parser::ReadBitString(BitString* bit_string) {
return ParseBitString(value, bit_string);
}
+bool Parser::ReadGeneralizedTime(GeneralizedTime* out) {
+ Input value;
+ if (!ReadTag(kGeneralizedTime, &value))
+ return false;
+ return ParseGeneralizedTime(value, out);
+}
+
} // namespace der
} // namespace net
diff --git a/chromium/net/der/parser.h b/chromium/net/der/parser.h
index 2192371d6c6..d18728e1858 100644
--- a/chromium/net/der/parser.h
+++ b/chromium/net/der/parser.h
@@ -19,6 +19,7 @@ namespace net {
namespace der {
class BitString;
+struct GeneralizedTime;
// Parses a DER-encoded ASN.1 structure. DER (distinguished encoding rules)
// encodes each data value with a tag, length, and value (TLV). The tag
@@ -146,10 +147,19 @@ class NET_EXPORT Parser {
// to be 0x30 (SEQUENCE).
bool ReadSequence(Parser* out) WARN_UNUSED_RESULT;
+ // Expects the current tag to be kInteger, and calls ParseUint8 on the
+ // current value. Note that DER-encoded integers are arbitrary precision,
+ // so this method will fail for valid input that represents an integer
+ // outside the range of an uint8_t.
+ //
+ // Note that on failure the Parser is left in an undefined state (the
+ // input may or may not have been advanced).
+ bool ReadUint8(uint8_t* out) WARN_UNUSED_RESULT;
+
// Expects the current tag to be kInteger, and calls ParseUint64 on the
// current value. Note that DER-encoded integers are arbitrary precision,
// so this method will fail for valid input that represents an integer
- // outside the range of an int64_t.
+ // outside the range of an uint64_t.
//
// Note that on failure the Parser is left in an undefined state (the
// input may or may not have been advanced).
@@ -161,6 +171,12 @@ class NET_EXPORT Parser {
// input may or may not have been advanced).
bool ReadBitString(BitString* out) WARN_UNUSED_RESULT;
+ // Reads a GeneralizeTime. On success fills |out| and returns true.
+ //
+ // Note that on failure the Parser is left in an undefined state (the
+ // input may or may not have been advanced).
+ bool ReadGeneralizedTime(GeneralizedTime* out) WARN_UNUSED_RESULT;
+
// Lower level methods. The previous methods couple reading data from the
// input with advancing the Parser's internal pointer to the next TLV; these
// lower level methods decouple those two steps into methods that read from
diff --git a/chromium/net/der/tag.cc b/chromium/net/der/tag.cc
index 99acf8cdfd8..a8240243943 100644
--- a/chromium/net/der/tag.cc
+++ b/chromium/net/der/tag.cc
@@ -20,18 +20,10 @@ Tag ContextSpecificPrimitive(uint8_t base) {
return (base & kTagNumberMask) | kTagPrimitive | kTagContextSpecific;
}
-bool IsContextSpecific(Tag tag) {
- return (tag & kTagClassMask) == kTagContextSpecific;
-}
-
bool IsConstructed(Tag tag) {
return (tag & kTagConstructionMask) == kTagConstructed;
}
-uint8_t GetTagNumber(Tag tag) {
- return tag & kTagNumberMask;
-}
-
} // namespace der
} // namespace net
diff --git a/chromium/net/der/tag.h b/chromium/net/der/tag.h
index cb18ac6a7c1..a168df66686 100644
--- a/chromium/net/der/tag.h
+++ b/chromium/net/der/tag.h
@@ -31,6 +31,7 @@ const Tag kOid = 0x06;
const Tag kEnumerated = 0x0A;
const Tag kUtf8String = 0x0C;
const Tag kPrintableString = 0x13;
+const Tag kTeletexString = 0x14;
const Tag kIA5String = 0x16;
const Tag kUtcTime = 0x17;
const Tag kGeneralizedTime = 0x18;
@@ -67,12 +68,8 @@ NET_EXPORT Tag ContextSpecificConstructed(uint8_t class_number);
NET_EXPORT Tag ContextSpecificPrimitive(uint8_t base);
-NET_EXPORT bool IsContextSpecific(Tag tag);
-
NET_EXPORT bool IsConstructed(Tag tag);
-NET_EXPORT uint8_t GetTagNumber(Tag tag);
-
} // namespace der
} // namespace net