From 2ade8a8a544e155dac374e35a8fd1440104fa45a Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Tue, 25 Mar 2014 04:11:06 +0000 Subject: [webcrypto] Refactor to use WebCryptoKeyAlgorithm create* functions. BUG=245025 Review URL: https://codereview.chromium.org/210583003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259143 0039d316-1c4b-4281-b951-d872f2087c98 --- content/child/webcrypto/platform_crypto_nss.cc | 20 +++++++++----------- content/child/webcrypto/webcrypto_util.cc | 10 ++++------ 2 files changed, 13 insertions(+), 17 deletions(-) (limited to 'content') diff --git a/content/child/webcrypto/platform_crypto_nss.cc b/content/child/webcrypto/platform_crypto_nss.cc index 5192cf4..a9387e7 100644 --- a/content/child/webcrypto/platform_crypto_nss.cc +++ b/content/child/webcrypto/platform_crypto_nss.cc @@ -414,22 +414,20 @@ bool CreatePublicKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, switch (algorithm.paramsType()) { case blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams: case blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams: - *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( + *key_algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed( algorithm.id(), - new blink::WebCryptoRsaHashedKeyAlgorithmParams( - modulus_length_bits, - public_exponent.bytes(), - public_exponent.byte_length(), - GetInnerHashAlgorithm(algorithm))); + modulus_length_bits, + public_exponent.bytes(), + public_exponent.byte_length(), + GetInnerHashAlgorithm(algorithm).id()); return true; case blink::WebCryptoAlgorithmParamsTypeRsaKeyGenParams: case blink::WebCryptoAlgorithmParamsTypeNone: - *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( + *key_algorithm = blink::WebCryptoKeyAlgorithm::createRsa( algorithm.id(), - new blink::WebCryptoRsaKeyAlgorithmParams( - modulus_length_bits, - public_exponent.bytes(), - public_exponent.byte_length())); + modulus_length_bits, + public_exponent.bytes(), + public_exponent.byte_length()); return true; default: return false; diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc index 294c4b2..d7326f9 100644 --- a/content/child/webcrypto/webcrypto_util.cc +++ b/content/child/webcrypto/webcrypto_util.cc @@ -205,18 +205,16 @@ bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, return false; if (keylen_bytes > UINT_MAX / 8) return false; - *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( - algorithm.id(), - new blink::WebCryptoHmacKeyAlgorithmParams(hash, keylen_bytes * 8)); + *key_algorithm = + blink::WebCryptoKeyAlgorithm::createHmac(hash.id(), keylen_bytes * 8); return true; } case blink::WebCryptoAlgorithmIdAesKw: case blink::WebCryptoAlgorithmIdAesCbc: case blink::WebCryptoAlgorithmIdAesCtr: case blink::WebCryptoAlgorithmIdAesGcm: - *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( - algorithm.id(), - new blink::WebCryptoAesKeyAlgorithmParams(keylen_bytes * 8)); + *key_algorithm = blink::WebCryptoKeyAlgorithm::createAes( + algorithm.id(), keylen_bytes * 8); return true; default: return false; -- cgit v1.1