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

Unified Diff: net/cert/jwk_serializer_unittest.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/jwk_serializer_openssl.cc ('k') | net/cert/mock_cert_verifier.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/jwk_serializer_unittest.cc
diff --git a/net/cert/jwk_serializer_unittest.cc b/net/cert/jwk_serializer_unittest.cc
index 6fa318f3637e91cc90d5f2da2728f67609a13018..791fd2761b3b89577ba758fd9393867b4ba3aa82 100644
--- a/net/cert/jwk_serializer_unittest.cc
+++ b/net/cert/jwk_serializer_unittest.cc
@@ -20,12 +20,13 @@ namespace net {
// The 0x04 in the BIT STRING is the prefix for an uncompressed, X9.62
// public key. Following that are the two field elements as 32-byte,
// big-endian numbers, as required by the Channel ID.
-static const unsigned char kP256SpkiPrefix[] = {
- 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
- 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
- 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
- 0x42, 0x00, 0x04
-};
+// static const unsigned char kP256SpkiPrefix[] = {
+// 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
+// 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
+// 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
+// 0x42, 0x00, 0x04
+//};
+static const unsigned int kP256SpkiPrefixSize = 27U;
static const unsigned int kEcCoordinateSize = 32U;
// This is a valid P-256 public key.
@@ -81,18 +82,15 @@ TEST(JwkSerializerTest, ConvertSpkiFromDerToJwkEc) {
std::string decoded_coordinate;
EXPECT_TRUE(base::Base64Decode(string_value, &decoded_coordinate));
EXPECT_EQ(kEcCoordinateSize, decoded_coordinate.size());
- EXPECT_EQ(0,
- memcmp(decoded_coordinate.data(),
- kSpkiEc + sizeof(kP256SpkiPrefix),
- kEcCoordinateSize));
+ EXPECT_EQ(0, memcmp(decoded_coordinate.data(), kSpkiEc + kP256SpkiPrefixSize,
+ kEcCoordinateSize));
EXPECT_TRUE(public_key_jwk.GetString("y", &string_value));
EXPECT_TRUE(base::Base64Decode(string_value, &decoded_coordinate));
EXPECT_EQ(kEcCoordinateSize, decoded_coordinate.size());
- EXPECT_EQ(0,
- memcmp(decoded_coordinate.data(),
- kSpkiEc + sizeof(kP256SpkiPrefix) + kEcCoordinateSize,
- kEcCoordinateSize));
+ EXPECT_EQ(0, memcmp(decoded_coordinate.data(),
+ kSpkiEc + kP256SpkiPrefixSize + kEcCoordinateSize,
+ kEcCoordinateSize));
// Test the result of a corner case: leading 0s in the x, y coordinates are
// not trimmed, but the point is fixed-length encoded.
@@ -108,18 +106,17 @@ TEST(JwkSerializerTest, ConvertSpkiFromDerToJwkEc) {
EXPECT_TRUE(public_key_jwk.GetString("x", &string_value));
EXPECT_TRUE(base::Base64Decode(string_value, &decoded_coordinate));
EXPECT_EQ(kEcCoordinateSize, decoded_coordinate.size());
- EXPECT_EQ(0,
- memcmp(decoded_coordinate.data(),
- kSpkiEcWithLeadingZero + sizeof(kP256SpkiPrefix),
- kEcCoordinateSize));
+ EXPECT_EQ(0, memcmp(decoded_coordinate.data(),
+ kSpkiEcWithLeadingZero + kP256SpkiPrefixSize,
+ kEcCoordinateSize));
EXPECT_TRUE(public_key_jwk.GetString("y", &string_value));
EXPECT_TRUE(base::Base64Decode(string_value, &decoded_coordinate));
EXPECT_EQ(kEcCoordinateSize, decoded_coordinate.size());
- EXPECT_EQ(0, memcmp(
- decoded_coordinate.data(),
- kSpkiEcWithLeadingZero + sizeof(kP256SpkiPrefix) + kEcCoordinateSize,
- kEcCoordinateSize));
+ EXPECT_EQ(0, memcmp(decoded_coordinate.data(),
+ kSpkiEcWithLeadingZero + kP256SpkiPrefixSize +
+ kEcCoordinateSize,
+ kEcCoordinateSize));
}
} // namespace net
« no previous file with comments | « net/cert/jwk_serializer_openssl.cc ('k') | net/cert/mock_cert_verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698