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

Unified Diff: trunk/src/content/child/webcrypto/jwk.cc

Issue 252213003: Revert 266798 "[webcrypto] Make operations run on a background t..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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 | « trunk/src/content/child/webcrypto/jwk.h ('k') | trunk/src/content/child/webcrypto/platform_crypto.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/content/child/webcrypto/jwk.cc
===================================================================
--- trunk/src/content/child/webcrypto/jwk.cc (revision 266902)
+++ trunk/src/content/child/webcrypto/jwk.cc (working copy)
@@ -2,16 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "jwk.h"
-
#include <algorithm>
#include <functional>
#include <map>
-
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
-#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "content/child/webcrypto/crypto_data.h"
#include "content/child/webcrypto/platform_crypto.h"
@@ -303,14 +299,18 @@
}
// Writes a secret/symmetric key to a JWK dictionary.
-void WriteSecretKey(const std::vector<uint8>& raw_key,
+void WriteSecretKey(const blink::WebArrayBuffer& raw_key,
base::DictionaryValue* jwk_dict) {
DCHECK(jwk_dict);
jwk_dict->SetString("kty", "oct");
// For a secret/symmetric key, the only extra JWK field is 'k', containing the
// base64url encoding of the raw key.
- const base::StringPiece key_str(
- reinterpret_cast<const char*>(Uint8VectorStart(raw_key)), raw_key.size());
+ DCHECK(!raw_key.isNull());
+ DCHECK(raw_key.data());
+ DCHECK(raw_key.byteLength());
+ unsigned int key_length_bytes = raw_key.byteLength();
+ const base::StringPiece key_str(static_cast<const char*>(raw_key.data()),
+ key_length_bytes);
jwk_dict->SetString("k", Base64EncodeUrlSafe(key_str));
}
@@ -791,14 +791,14 @@
}
Status ExportKeyJwk(const blink::WebCryptoKey& key,
- std::vector<uint8>* buffer) {
+ blink::WebArrayBuffer* buffer) {
DCHECK(key.extractable());
base::DictionaryValue jwk_dict;
Status status = Status::OperationError();
switch (key.type()) {
case blink::WebCryptoKeyTypeSecret: {
- std::vector<uint8> exported_key;
+ blink::WebArrayBuffer exported_key;
status = ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key);
if (status.IsError())
return status;
@@ -835,7 +835,8 @@
std::string json;
base::JSONWriter::Write(&jwk_dict, &json);
- buffer->assign(json.data(), json.data() + json.size());
+ *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()),
+ json.size());
return Status::Success();
}
« no previous file with comments | « trunk/src/content/child/webcrypto/jwk.h ('k') | trunk/src/content/child/webcrypto/platform_crypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698