Tests deriveKey() with various bad parameters for ECDH On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". Importing the private key... Importing the public key... Deriving an AES key with no length... error is: TypeError: Failed to execute 'deriveKey' on 'SubtleCrypto': AesDerivedKeyParams: length: Missing required property Deriving an AES key with bad length... error is: OperationError: AES key length must be 128 or 256 bits Deriving an AES key with unsupported length... error is: OperationError: 192-bit AES keys are not supported Deriving an AES-CBC key with unsupported usage (sign)... error is: SyntaxError: Cannot create a key using the specified key usages. Deriving using an ECDH key that has deriveBits but NOT deriveKey... usage error is: InvalidAccessError: key.usages does not permit this operation Deriving using public instead of private key... error is: InvalidAccessError: key.usages does not permit this operation Deriving using private instead of public key... error is: InvalidAccessError: The public parameter for ECDH key derivation is not a public EC key Deriving a key larger than the field size of P-521... error is: OperationError: Length specified for ECDH key derivation is too large. Maximum allowed is 528 bits Deriving a zero-length HMAC key... error is: TypeError: HMAC key length must not be zero Deriving a key larger than field size of P-521, by requesting an HMAC SHA-512 key with no length... error is: OperationError: Length specified for ECDH key derivation is too large. Maximum allowed is 528 bits Deriving a key using mismatched curves on public/private keys... error is: InvalidAccessError: The public parameter for ECDH key derivation is for a different named curve Deriving a key using a public EC key for different algorithm (ECDSA)... error is: InvalidAccessError: The public parameter for ECDH key derivation must be for ECDH Deriving a key using an AES key for public key... error is: InvalidAccessError: The public parameter for ECDH key derivation is not a public EC key Deriving a key without specifying the "public" parameter... error is: TypeError: Failed to execute 'deriveKey' on 'SubtleCrypto': EcdhKeyDeriveParams: public: Missing required property Deriving a key having specified a bogus "public" parameter... error is: TypeError: Failed to execute 'deriveKey' on 'SubtleCrypto': EcdhKeyDeriveParams: public: Must be a CryptoKey Deriving an ECDH key using ECDH... error is: NotSupportedError: Failed to execute 'deriveKey' on 'SubtleCrypto': ECDH: Unsupported operation: get key length Deriving an RSA-OAEP key using ECDH... error is: NotSupportedError: Failed to execute 'deriveKey' on 'SubtleCrypto': RSA-OAEP: Unsupported operation: get key length PASS successfullyParsed is true TEST COMPLETE