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(); |
} |