| Index: Source/modules/crypto/SubtleCrypto.cpp
|
| diff --git a/Source/modules/crypto/SubtleCrypto.cpp b/Source/modules/crypto/SubtleCrypto.cpp
|
| index 492bf904befa56a364c5cf855449f1af7d15816b..6d749022b6e169f70556aa978bee645b99d2ee3f 100644
|
| --- a/Source/modules/crypto/SubtleCrypto.cpp
|
| +++ b/Source/modules/crypto/SubtleCrypto.cpp
|
| @@ -150,6 +150,9 @@ ScriptPromise SubtleCrypto::generateKey(const Dictionary& rawAlgorithm, bool ext
|
| if (!parseAlgorithm(rawAlgorithm, GenerateKey, algorithm, result.get()))
|
| return promise;
|
|
|
| + if (!verifyUsagesAreConsistentForAlgorithm(algorithm.id(), keyUsages, result.get()))
|
| + return promise;
|
| +
|
| blink::Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages, result->result());
|
| return promise;
|
| }
|
| @@ -174,6 +177,9 @@ ScriptPromise SubtleCrypto::importKey(const String& rawFormat, ArrayBufferView*
|
| if (!parseAlgorithm(rawAlgorithm, ImportKey, algorithm, result.get()))
|
| return promise;
|
|
|
| + if (!verifyUsagesAreConsistentForAlgorithm(algorithm.id(), keyUsages, result.get()))
|
| + return promise;
|
| +
|
| const unsigned char* keyDataBytes = static_cast<unsigned char*>(keyData->baseAddress());
|
|
|
| blink::Platform::current()->crypto()->importKey(format, keyDataBytes, keyData->byteLength(), algorithm, extractable, keyUsages, result->result());
|
| @@ -258,6 +264,9 @@ ScriptPromise SubtleCrypto::unwrapKey(const String& rawFormat, ArrayBufferView*
|
| if (!parseAlgorithm(rawUnwrappedKeyAlgorithm, ImportKey, unwrappedKeyAlgorithm, result.get()))
|
| return promise;
|
|
|
| + if (!verifyUsagesAreConsistentForAlgorithm(unwrappedKeyAlgorithm.id(), keyUsages, result.get()))
|
| + return promise;
|
| +
|
| if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, UnwrapKey, result.get()))
|
| return promise;
|
|
|
|
|