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

Unified Diff: components/webcrypto/algorithms/hkdf.cc

Issue 2163053002: [webcrypto] Check for empty key usages *after* key creation rather than before, to match the spec's… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/hmac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/hkdf.cc
diff --git a/components/webcrypto/algorithms/hkdf.cc b/components/webcrypto/algorithms/hkdf.cc
index bc10c35bc8a80f15f01011c0d8ef58f2e97a22d5..6b22d248989e80e826fef5170d1a37f8f05d57e6 100644
--- a/components/webcrypto/algorithms/hkdf.cc
+++ b/components/webcrypto/algorithms/hkdf.cc
@@ -29,19 +29,29 @@ class HkdfImplementation : public AlgorithmImplementation {
public:
HkdfImplementation() {}
- Status VerifyKeyUsagesBeforeImportKey(
- blink::WebCryptoKeyFormat format,
- blink::WebCryptoKeyUsageMask usages) const override {
- if (format != blink::WebCryptoKeyFormatRaw)
- return Status::ErrorUnsupportedImportKeyFormat();
- return CheckSecretKeyCreationUsages(kValidUsages, usages);
+ Status ImportKey(blink::WebCryptoKeyFormat format,
+ const CryptoData& key_data,
+ const blink::WebCryptoAlgorithm& algorithm,
+ bool extractable,
+ blink::WebCryptoKeyUsageMask usages,
+ blink::WebCryptoKey* key) const override {
+ switch (format) {
+ case blink::WebCryptoKeyFormatRaw:
+ return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
+ default:
+ return Status::ErrorUnsupportedImportKeyFormat();
+ }
}
Status ImportKeyRaw(const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usages,
- blink::WebCryptoKey* key) const override {
+ blink::WebCryptoKey* key) const {
+ Status status = CheckKeyCreationUsages(kValidUsages, usages);
+ if (status.IsError())
+ return status;
+
return CreateWebCryptoSecretKey(
key_data, blink::WebCryptoKeyAlgorithm::createWithoutParams(
blink::WebCryptoAlgorithmIdHkdf),
« no previous file with comments | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/hmac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698