| Index: content/renderer/webcrypto/webcrypto_impl_nss.cc
|
| diff --git a/content/renderer/webcrypto/webcrypto_impl_nss.cc b/content/renderer/webcrypto/webcrypto_impl_nss.cc
|
| index 7b8917d16e97eebc23365b9293a1f412fd137039..6a62cb8f88f047954913a3468fe20b2601af489e 100644
|
| --- a/content/renderer/webcrypto/webcrypto_impl_nss.cc
|
| +++ b/content/renderer/webcrypto/webcrypto_impl_nss.cc
|
| @@ -84,17 +84,23 @@ void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size) {
|
| *buffer = new_buffer;
|
| }
|
|
|
| -bool AesCbcEncryptDecrypt(
|
| - CK_ATTRIBUTE_TYPE operation,
|
| +} // namespace
|
| +
|
| +void WebCryptoImpl::Init() {
|
| + crypto::EnsureNSSInit();
|
| +}
|
| +
|
| +bool WebCryptoImpl::EncryptInternal(
|
| const WebKit::WebCryptoAlgorithm& algorithm,
|
| const WebKit::WebCryptoKey& key,
|
| const unsigned char* data,
|
| unsigned data_size,
|
| WebKit::WebArrayBuffer* buffer) {
|
| - DCHECK_EQ(WebKit::WebCryptoAlgorithmIdAesCbc, algorithm.id());
|
| + if (algorithm.id() != WebKit::WebCryptoAlgorithmIdAesCbc)
|
| + return false;
|
| +
|
| DCHECK_EQ(algorithm.id(), key.algorithm().id());
|
| DCHECK_EQ(WebKit::WebCryptoKeyTypeSecret, key.type());
|
| - DCHECK(operation == CKA_ENCRYPT || operation == CKA_DECRYPT);
|
|
|
| SymKeyHandle* sym_key = reinterpret_cast<SymKeyHandle*>(key.handle());
|
|
|
| @@ -112,7 +118,7 @@ bool AesCbcEncryptDecrypt(
|
| return false;
|
|
|
| crypto::ScopedPK11Context context(PK11_CreateContextBySymKey(
|
| - CKM_AES_CBC_PAD, operation, sym_key->key(), param.get()));
|
| + CKM_AES_CBC_PAD, CKA_ENCRYPT, sym_key->key(), param.get()));
|
|
|
| if (!context.get())
|
| return false;
|
| @@ -127,8 +133,6 @@ bool AesCbcEncryptDecrypt(
|
| return false;
|
| }
|
|
|
| - // TODO(eroman): Refine the output buffer size. It can be computed exactly for
|
| - // encryption, and can be smaller for decryption.
|
| unsigned output_max_len = data_size + AES_BLOCK_SIZE;
|
| CHECK_GT(output_max_len, data_size);
|
|
|
| @@ -158,40 +162,6 @@ bool AesCbcEncryptDecrypt(
|
| return true;
|
| }
|
|
|
| -} // namespace
|
| -
|
| -void WebCryptoImpl::Init() {
|
| - crypto::EnsureNSSInit();
|
| -}
|
| -
|
| -bool WebCryptoImpl::EncryptInternal(
|
| - const WebKit::WebCryptoAlgorithm& algorithm,
|
| - const WebKit::WebCryptoKey& key,
|
| - const unsigned char* data,
|
| - unsigned data_size,
|
| - WebKit::WebArrayBuffer* buffer) {
|
| - if (algorithm.id() == WebKit::WebCryptoAlgorithmIdAesCbc) {
|
| - return AesCbcEncryptDecrypt(
|
| - CKA_ENCRYPT, algorithm, key, data, data_size, buffer);
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| -bool WebCryptoImpl::DecryptInternal(
|
| - const WebKit::WebCryptoAlgorithm& algorithm,
|
| - const WebKit::WebCryptoKey& key,
|
| - const unsigned char* data,
|
| - unsigned data_size,
|
| - WebKit::WebArrayBuffer* buffer) {
|
| - if (algorithm.id() == WebKit::WebCryptoAlgorithmIdAesCbc) {
|
| - return AesCbcEncryptDecrypt(
|
| - CKA_DECRYPT, algorithm, key, data, data_size, buffer);
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| bool WebCryptoImpl::DigestInternal(
|
| const WebKit::WebCryptoAlgorithm& algorithm,
|
| const unsigned char* data,
|
|
|