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

Unified Diff: content/renderer/webcrypto/webcrypto_impl_nss.cc

Issue 25032003: Revert "[webcrypto] Add decrypt() for AES-CBC." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/renderer/webcrypto/webcrypto_impl.cc ('k') | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl.cc ('k') | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698