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

Side by Side Diff: components/proximity_auth/cryptauth/base64url_unittest.cc

Issue 1170363002: [Proximity auth] Disallow '+' and '/' in incoming base64-encoded strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar commants Created 5 years, 6 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
« no previous file with comments | « components/proximity_auth/cryptauth/base64url.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/proximity_auth/cryptauth/base64url.h" 5 #include "components/proximity_auth/cryptauth/base64url.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace proximity_auth { 10 namespace proximity_auth {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 std::string decoded; 57 std::string decoded;
58 ASSERT_TRUE(Base64UrlDecode(encoded, &decoded)); 58 ASSERT_TRUE(Base64UrlDecode(encoded, &decoded));
59 59
60 // Decoded strings that encode to special characters are non-printable, so, 60 // Decoded strings that encode to special characters are non-printable, so,
61 // for ease of testing, just compare the web-safe and non-web-safe encodings. 61 // for ease of testing, just compare the web-safe and non-web-safe encodings.
62 std::string non_web_safe_encoded; 62 std::string non_web_safe_encoded;
63 base::Base64Encode(decoded, &non_web_safe_encoded); 63 base::Base64Encode(decoded, &non_web_safe_encoded);
64 EXPECT_EQ("/+Y=", non_web_safe_encoded); 64 EXPECT_EQ("/+Y=", non_web_safe_encoded);
65 } 65 }
66 66
67 TEST(ProximityAuthBase64UrlTest, DecodeBailsOnPlus) {
68 // Note that "_-Y=" is a valid encoded string, as tested above. This test
69 // simply verifies that an otherwise correctly encoded string cannot use '+'
70 // in palce of '-', since the proximity auth code expects websafe encodings.
Ryan Sleevi 2015/06/09 23:14:02 typo: place
71 const std::string encoded = "_+Y=";
72 std::string decoded;
73 EXPECT_FALSE(Base64UrlDecode(encoded, &decoded));
74 }
75
76 TEST(ProximityAuthBase64UrlTest, DecodeBailsOnSlash) {
77 // Note that "_-Y=" is a valid encoded string, as tested above. This test
78 // simply verifies that an otherwise correctly encoded string cannot use '/'
79 // in palce of '_', since the proximity auth code expects websafe encodings.
Ryan Sleevi 2015/06/09 23:14:02 typo: place
80 const std::string encoded = "/-Y=";
81 std::string decoded;
82 EXPECT_FALSE(Base64UrlDecode(encoded, &decoded));
83 }
84
67 } // namespace proximity_auth 85 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/cryptauth/base64url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698