1 Tests deriveKey() with various bad parameters for ECDH
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 Importing the private key...
7 Importing the public key...
9 Deriving an AES key with no length...
10 error is: TypeError: AesDerivedKeyParams: length: Missing required property
12 Deriving an AES key with bad length...
13 error is: OperationError: AES key length must be 128 or 256 bits
15 Deriving an AES key with unsupported length...
16 error is: OperationError: 192-bit AES keys are not supported
18 Deriving an AES-CBC key with unsupported usage (sign)...
19 error is: SyntaxError: Cannot create a key using the specified key usages.
21 Deriving using an ECDH key that has deriveBits but NOT deriveKey... usage
22 error is: InvalidAccessError: key.usages does not permit this operation
24 Deriving using public instead of private key...
25 error is: InvalidAccessError: key.usages does not permit this operation
27 Deriving using private instead of public key...
28 error is: InvalidAccessError: The public parameter for ECDH key derivation is not a public EC key
30 Deriving a key larger than the field size of P-521...
31 error is: OperationError: Length specified for ECDH key derivation is too large. Maximum allowed is 528 bits
33 Deriving a zero-length HMAC key...
34 error is: TypeError: HMAC key length must not be zero
36 Deriving a key larger than field size of P-521, by requesting an HMAC SHA-512 key with no length...
37 error is: OperationError: Length specified for ECDH key derivation is too large. Maximum allowed is 528 bits
39 Deriving a key using mismatched curves on public/private keys...
40 error is: InvalidAccessError: The public parameter for ECDH key derivation is for a different named curve
42 Deriving a key using a public EC key for different algorithm (ECDSA)...
43 error is: InvalidAccessError: The public parameter for ECDH key derivation must be for ECDH
45 Deriving a key using an AES key for public key...
46 error is: InvalidAccessError: The public parameter for ECDH key derivation is not a public EC key
48 Deriving a key without specifying the "public" parameter...
49 error is: TypeError: EcdhKeyDeriveParams: public: Missing required property
51 Deriving a key having specified a bogus "public" parameter...
52 error is: TypeError: EcdhKeyDeriveParams: public: Must be a CryptoKey
54 Deriving an ECDH key using ECDH...
55 error is: NotSupportedError: ECDH: Unsupported operation: get key length
57 Deriving an RSA-OAEP key using ECDH...
58 error is: NotSupportedError: RSA-OAEP: Unsupported operation: get key length
60 PASS successfullyParsed is true