Index: content/child/webcrypto/platform_crypto_openssl.cc |
diff --git a/content/child/webcrypto/platform_crypto_openssl.cc b/content/child/webcrypto/platform_crypto_openssl.cc |
index e990e6a6fd8648a61a57d868fd6b4640f41cefa2..34abcd8f108d63b2eb9050f912a098e4ffb0e75f 100644 |
--- a/content/child/webcrypto/platform_crypto_openssl.cc |
+++ b/content/child/webcrypto/platform_crypto_openssl.cc |
@@ -36,6 +36,11 @@ class SymKey : public Key { |
virtual SymKey* AsSymKey() OVERRIDE { return this; } |
virtual PublicKey* AsPublicKey() OVERRIDE { return NULL; } |
virtual PrivateKey* AsPrivateKey() OVERRIDE { return NULL; } |
+ virtual bool ThreadSafeSerializeForClone( |
+ blink::WebVector<uint8>* key_data) OVERRIDE { |
+ key_data->assign(Uint8VectorStart(key_), key_.size()); |
+ return true; |
+ } |
const std::vector<unsigned char>& key() const { return key_; } |
@@ -83,7 +88,7 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt mode, |
SymKey* key, |
const CryptoData& iv, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
CipherOperation cipher_operation = |
(mode == ENCRYPT) ? kDoEncrypt : kDoDecrypt; |
@@ -122,10 +127,9 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt mode, |
output_max_len += AES_BLOCK_SIZE - remainder; |
DCHECK_GT(output_max_len, data.byte_length()); |
- *buffer = blink::WebArrayBuffer::create(output_max_len, 1); |
+ buffer->resize(output_max_len); |
- unsigned char* const buffer_data = |
- reinterpret_cast<unsigned char*>(buffer->data()); |
+ unsigned char* const buffer_data = Uint8VectorStart(buffer); |
int output_len = 0; |
if (!EVP_CipherUpdate(context.get(), |
@@ -145,7 +149,7 @@ Status AesCbcEncryptDecrypt(EncryptOrDecrypt mode, |
static_cast<unsigned int>(final_output_chunk_len); |
DCHECK_LE(final_output_len, output_max_len); |
- ShrinkBuffer(buffer, final_output_len); |
+ buffer->resize(final_output_len); |
return Status::Success(); |
} |
@@ -184,16 +188,12 @@ class DigestorOpenSSL : public blink::WebCryptoDigestor { |
return true; |
} |
- Status FinishWithWebArrayAndStatus(blink::WebArrayBuffer* result) { |
+ Status FinishWithVectorAndStatus(std::vector<uint8>* result) { |
const int hash_expected_size = EVP_MD_CTX_size(digest_context_.get()); |
- *result = blink::WebArrayBuffer::create(hash_expected_size, 1); |
- unsigned char* const hash_buffer = |
- static_cast<unsigned char* const>(result->data()); |
+ result->resize(hash_expected_size); |
+ unsigned char* const hash_buffer = Uint8VectorStart(result); |
unsigned int hash_buffer_size; // ignored |
- Status error = FinishInternal(hash_buffer, &hash_buffer_size); |
- if (!error.IsSuccess()) |
- result->reset(); |
- return error; |
+ return FinishInternal(hash_buffer, &hash_buffer_size); |
} |
private: |
@@ -239,8 +239,8 @@ class DigestorOpenSSL : public blink::WebCryptoDigestor { |
unsigned char result_[EVP_MAX_MD_SIZE]; |
}; |
-Status ExportKeyRaw(SymKey* key, blink::WebArrayBuffer* buffer) { |
- *buffer = CreateArrayBuffer(Uint8VectorStart(key->key()), key->key().size()); |
+Status ExportKeyRaw(SymKey* key, std::vector<uint8>* buffer) { |
+ *buffer = key->key(); |
return Status::Success(); |
} |
@@ -250,19 +250,19 @@ Status EncryptDecryptAesCbc(EncryptOrDecrypt mode, |
SymKey* key, |
const CryptoData& data, |
const CryptoData& iv, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): inline the function here. |
return AesCbcEncryptDecrypt(mode, key, iv, data, buffer); |
} |
Status DigestSha(blink::WebCryptoAlgorithmId algorithm, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
DigestorOpenSSL digestor(algorithm); |
Status error = digestor.ConsumeWithStatus(data.bytes(), data.byte_length()); |
if (!error.IsSuccess()) |
return error; |
- return digestor.FinishWithWebArrayAndStatus(buffer); |
+ return digestor.FinishWithVectorAndStatus(buffer); |
} |
scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
@@ -335,9 +335,7 @@ Status ImportKeyRaw(const blink::WebCryptoAlgorithm& algorithm, |
Status SignHmac(SymKey* key, |
const blink::WebCryptoAlgorithm& hash, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
- blink::WebArrayBuffer result; |
- |
+ std::vector<uint8>* buffer) { |
const EVP_MD* digest_algorithm = GetDigest(hash.id()); |
if (!digest_algorithm) |
return Status::ErrorUnsupported(); |
@@ -353,9 +351,9 @@ Status SignHmac(SymKey* key, |
const unsigned char null_key[] = {}; |
const void* const raw_key_voidp = raw_key.size() ? &raw_key[0] : null_key; |
- result = blink::WebArrayBuffer::create(hmac_expected_length, 1); |
+ buffer->resize(hmac_expected_length); |
crypto::ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> hmac_result( |
- reinterpret_cast<unsigned char*>(result.data()), hmac_expected_length); |
+ Uint8VectorStart(buffer), hmac_expected_length); |
crypto::OpenSSLErrStackTracer(FROM_HERE); |
@@ -370,7 +368,6 @@ Status SignHmac(SymKey* key, |
if (!success || hmac_actual_length != hmac_expected_length) |
return Status::OperationError(); |
- *buffer = result; |
return Status::Success(); |
} |
@@ -391,7 +388,7 @@ Status EncryptDecryptAesGcm(EncryptOrDecrypt mode, |
const CryptoData& iv, |
const CryptoData& additional_data, |
unsigned int tag_length_bits, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -399,14 +396,14 @@ Status EncryptDecryptAesGcm(EncryptOrDecrypt mode, |
// Guaranteed that key is valid. |
Status EncryptRsaEsPkcs1v1_5(PublicKey* key, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
Status DecryptRsaEsPkcs1v1_5(PrivateKey* key, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -414,7 +411,7 @@ Status DecryptRsaEsPkcs1v1_5(PrivateKey* key, |
Status SignRsaSsaPkcs1v1_5(PrivateKey* key, |
const blink::WebCryptoAlgorithm& hash, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -447,14 +444,14 @@ Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm, |
return Status::ErrorUnsupported(); |
} |
-Status ExportKeySpki(PublicKey* key, blink::WebArrayBuffer* buffer) { |
+Status ExportKeySpki(PublicKey* key, std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
Status ExportKeyPkcs8(PrivateKey* key, |
const blink::WebCryptoKeyAlgorithm& key_algorithm, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -468,7 +465,7 @@ Status ExportRsaPublicKey(PublicKey* key, |
Status WrapSymKeyAesKw(SymKey* wrapping_key, |
SymKey* key, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -485,14 +482,14 @@ Status UnwrapSymKeyAesKw(const CryptoData& wrapped_key_data, |
Status DecryptAesKw(SymKey* key, |
const CryptoData& data, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
Status WrapSymKeyRsaEs(PublicKey* wrapping_key, |
SymKey* key, |
- blink::WebArrayBuffer* buffer) { |
+ std::vector<uint8>* buffer) { |
// TODO(eroman): http://crbug.com/267888 |
return Status::ErrorUnsupported(); |
} |
@@ -507,6 +504,17 @@ Status UnwrapSymKeyRsaEs(const CryptoData& wrapped_key_data, |
return Status::ErrorUnsupported(); |
} |
+bool ThreadSafeDeserializeKeyForClone( |
+ const blink::WebCryptoKeyAlgorithm& algorithm, |
+ blink::WebCryptoKeyType type, |
+ bool extractable, |
+ blink::WebCryptoKeyUsageMask usages, |
+ const CryptoData& key_data, |
+ blink::WebCryptoKey* key) { |
+ // TODO(eroman): http://crbug.com/267888 |
+ return false; |
+} |
+ |
} // namespace platform |
} // namespace webcrypto |