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

Unified Diff: content/child/webcrypto/nss/hmac_nss.cc

Issue 512023002: Refactor the interface for generating keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a new return type "GenerateKeyPairResult" to encapsulate secretkey vs keypair Created 6 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
Index: content/child/webcrypto/nss/hmac_nss.cc
diff --git a/content/child/webcrypto/nss/hmac_nss.cc b/content/child/webcrypto/nss/hmac_nss.cc
index 40dadbe8a399e6dcbdbc4d5ec20dcd7b68e08aad..ab03222070cdb620c46e8ae1c4cd56fa73ea4005 100644
--- a/content/child/webcrypto/nss/hmac_nss.cc
+++ b/content/child/webcrypto/nss/hmac_nss.cc
@@ -55,10 +55,14 @@ class HmacImplementation : public AlgorithmImplementation {
public:
HmacImplementation() {}
- virtual Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
- bool extractable,
- blink::WebCryptoKeyUsageMask usage_mask,
- blink::WebCryptoKey* key) const OVERRIDE {
+ virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
+ bool extractable,
+ blink::WebCryptoKeyUsageMask usage_mask,
+ GenerateKeyResult* result) const OVERRIDE {
+ Status status = CheckKeyCreationUsages(kAllKeyUsages, usage_mask);
+ if (status.IsError())
+ return status;
+
const blink::WebCryptoHmacKeyGenParams* params =
algorithm.hmacKeyGenParams();
@@ -68,7 +72,7 @@ class HmacImplementation : public AlgorithmImplementation {
return Status::ErrorUnsupported();
unsigned int keylen_bits = 0;
- Status status = GetHmacKeyGenLengthInBits(params, &keylen_bits);
+ status = GetHmacKeyGenLengthInBits(params, &keylen_bits);
if (status.IsError())
return status;
@@ -78,7 +82,7 @@ class HmacImplementation : public AlgorithmImplementation {
usage_mask,
keylen_bits / 8,
mechanism,
- key);
+ result);
}
virtual Status VerifyKeyUsagesBeforeImportKey(
@@ -93,11 +97,6 @@ class HmacImplementation : public AlgorithmImplementation {
}
}
- virtual Status VerifyKeyUsagesBeforeGenerateKey(
- blink::WebCryptoKeyUsageMask usage_mask) const OVERRIDE {
- return CheckKeyCreationUsages(kAllKeyUsages, usage_mask);
- }
-
virtual Status ImportKeyRaw(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,

Powered by Google App Engine
This is Rietveld 408576698