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

Unified Diff: components/gcm_driver/crypto/encryption_header_parsers.cc

Issue 1243563002: Teach the GCM Driver how to decrypt incoming messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-push-keys
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/crypto/encryption_header_parsers.cc
diff --git a/components/gcm_driver/crypto/encryption_header_parsers.cc b/components/gcm_driver/crypto/encryption_header_parsers.cc
index 6a45792e85b04f480f1d095be40768f067306294..f320a101e69043554086d0d4c098085dad6b587a 100644
--- a/components/gcm_driver/crypto/encryption_header_parsers.cc
+++ b/components/gcm_driver/crypto/encryption_header_parsers.cc
@@ -56,24 +56,6 @@ bool ParseMultipleNameValueListsHeader(const std::string& input,
return true;
}
-// TODO(peter): Generalize a base64url implementation.
-// See https://tools.ietf.org/html/rfc4648#section-5
-bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
- if (input.find_first_of("+/") != std::string::npos)
- return false;
-
- // Add padding.
- size_t padded_size = (input.size() + 3) - (input.size() + 3) % 4;
- std::string padded_input(input);
- padded_input.resize(padded_size, '=');
-
- // Convert to standard base64 alphabet.
- base::ReplaceChars(padded_input, "-", "+", &padded_input);
- base::ReplaceChars(padded_input, "_", "/", &padded_input);
-
- return base::Base64Decode(padded_input, output);
-}
-
// Parses the "salt" field of the Encryption header. Must be a base64url
// encoded string that decodes to a string exactly 16 bytes in length.
bool ParseSalt(const std::string& value, std::string* output) {
@@ -196,4 +178,22 @@ bool ParseEncryptionKeyHeader(const std::string& input,
return true;
}
+// TODO(peter): Generalize a base64url implementation.
+// See https://tools.ietf.org/html/rfc4648#section-5
+bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
+ if (input.find_first_of("+/") != std::string::npos)
+ return false;
+
+ // Add padding.
+ size_t padded_size = (input.size() + 3) - (input.size() + 3) % 4;
+ std::string padded_input(input);
+ padded_input.resize(padded_size, '=');
+
+ // Convert to standard base64 alphabet.
+ base::ReplaceChars(padded_input, "-", "+", &padded_input);
+ base::ReplaceChars(padded_input, "_", "/", &padded_input);
+
+ return base::Base64Decode(padded_input, output);
+}
+
} // namespace gcm

Powered by Google App Engine
This is Rietveld 408576698