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

Unified Diff: content/child/webcrypto/webcrypto_util.cc

Issue 504413004: Move base64-urlsafe helpers to jwk.{cc,h} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and add missing headers Created 6 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
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/webcrypto_util.cc
diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc
index 1482bbca228b8ed63dc227b64561d4e465ab7b69..247437775f1112bc03e579b256ecdb10e3fd392f 100644
--- a/content/child/webcrypto/webcrypto_util.cc
+++ b/content/child/webcrypto/webcrypto_util.cc
@@ -4,9 +4,7 @@
#include "content/child/webcrypto/webcrypto_util.h"
-#include "base/base64.h"
#include "base/logging.h"
-#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "content/child/webcrypto/status.h"
#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
@@ -42,36 +40,6 @@ bool BigIntegerToUint(const uint8_t* data,
} // namespace
-// This function decodes unpadded 'base64url' encoded data, as described in
-// RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first
-// change the incoming data to 'base64' encoding by applying the appropriate
-// transformation including adding padding if required, and then call a base64
-// decoder.
-bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
- std::string base64EncodedText(input);
- std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+');
- std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/');
- base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '=');
- return base::Base64Decode(base64EncodedText, output);
-}
-
-// Returns an unpadded 'base64url' encoding of the input data, using the
-// inverse of the process above.
-std::string Base64EncodeUrlSafe(const base::StringPiece& input) {
- std::string output;
- base::Base64Encode(input, &output);
- std::replace(output.begin(), output.end(), '+', '-');
- std::replace(output.begin(), output.end(), '/', '_');
- output.erase(std::remove(output.begin(), output.end(), '='), output.end());
- return output;
-}
-
-std::string Base64EncodeUrlSafe(const std::vector<uint8_t>& input) {
- const base::StringPiece string_piece(
- reinterpret_cast<const char*>(vector_as_array(&input)), input.size());
- return Base64EncodeUrlSafe(string_piece);
-}
-
struct JwkToWebCryptoUsage {
const char* const jwk_key_op;
const blink::WebCryptoKeyUsage webcrypto_usage;
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698