MCPcopy Create free account
hub / github.com/nodejs/node / getTestData

Function getTestData

test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/hkdf_vectors.js:2–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1
2function getTestData() {
3
4 // deriveBits and deriveKey take as input:
5 // - derivedKey (actually, a CryptoKey representing a derivedKey)
6 // - salt (BufferSource)
7 // - hash (which one to use)
8 // - iterations (how many times to use it)
9
10 // deriveBits also takes a length. deriveKey uses the length of the output key
11 // - length is the number of bits, NOT octets, but it MUST be a multiple of 8
12 // - note that result of length(n) is first n bits of length(m) if m>n
13
14 // Variations to test:
15 // - empty, short, and fairly long derivedKey
16 // - empty, short, and fairly long salt
17 // - SHA-1, SHA-256, SHA-384, SHA-512 hash
18 // - 1, 1000, and 100000 million iterations
19
20 // Test cases to generate: 3 * 3 * 4 * 3 = 108
21
22 // Error conditions to test:
23 // - length null (OperationError)
24 // - length not a multiple of 8 (OperationError)
25 // - illegal name for hash algorithm (NotSupportedError)
26 // - legal algorithm name but not digest one (e.g., AES-CBC) (NotSupportedError)
27 // - baseKey usages missing "deriveBits" (InvalidAccessError)
28 // - baseKey algorithm does not match HKDF (InvalidAccessError)
29 // - 0 iterations
30
31 var derivedKeyTypes = [
32 {algorithm: {name: "AES-CBC", length: 128}, usages: ["encrypt", "decrypt"]},
33 {algorithm: {name: "AES-CBC", length: 192}, usages: ["encrypt", "decrypt"]},
34 {algorithm: {name: "AES-CBC", length: 256}, usages: ["encrypt", "decrypt"]},
35 {algorithm: {name: "AES-CTR", length: 128}, usages: ["encrypt", "decrypt"]},
36 {algorithm: {name: "AES-CTR", length: 192}, usages: ["encrypt", "decrypt"]},
37 {algorithm: {name: "AES-CTR", length: 256}, usages: ["encrypt", "decrypt"]},
38 {algorithm: {name: "AES-GCM", length: 128}, usages: ["encrypt", "decrypt"]},
39 {algorithm: {name: "AES-GCM", length: 192}, usages: ["encrypt", "decrypt"]},
40 {algorithm: {name: "AES-GCM", length: 256}, usages: ["encrypt", "decrypt"]},
41 {algorithm: {name: "AES-KW", length: 128}, usages: ["wrapKey", "unwrapKey"]},
42 {algorithm: {name: "AES-KW", length: 192}, usages: ["wrapKey", "unwrapKey"]},
43 {algorithm: {name: "AES-KW", length: 256}, usages: ["wrapKey", "unwrapKey"]},
44 {algorithm: {name: "HMAC", hash: "SHA-1", length: 256}, usages: ["sign", "verify"]},
45 {algorithm: {name: "HMAC", hash: "SHA-256", length: 256}, usages: ["sign", "verify"]},
46 {algorithm: {name: "HMAC", hash: "SHA-384", length: 256}, usages: ["sign", "verify"]},
47 {algorithm: {name: "HMAC", hash: "SHA-512", length: 256}, usages: ["sign", "verify"]}
48 ];
49
50 var derivedKeys = {
51 "short": new Uint8Array([80, 64, 115, 115, 119, 48, 114, 100]),
52 "long": new Uint8Array([85, 115, 101, 114, 115, 32, 115, 104, 111, 117, 108, 100, 32, 112, 105, 99, 107, 32, 108, 111, 110, 103, 32, 112, 97, 115, 115, 112, 104, 114, 97, 115, 101, 115, 32, 40, 110, 111, 116, 32, 117, 115, 101, 32, 115, 104, 111, 114, 116, 32, 112, 97, 115, 115, 119, 111, 114, 100, 115, 41, 33]),
53 "empty": new Uint8Array([])
54 };
55
56 var salts = {
57 "normal": new Uint8Array([83, 111, 100, 105, 117, 109, 32, 67, 104, 108, 111, 114, 105, 100, 101, 32, 99, 111, 109, 112, 111, 117, 110, 100]),
58 "empty": new Uint8Array([])
59 };
60

Callers 3

define_testsFunction · 0.70
define_testsFunction · 0.70
define_testsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected