xref: /third_party/node/test/fixtures/crypto/hmac.js (revision 1cb0ef41)
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cimodule.exports = function () {
41cb0ef41Sopenharmony_ci  const plaintext = Buffer.from(
51cb0ef41Sopenharmony_ci    '5f4dba4f320c0ce876725afce5fbd25bf83e5a7125a08cafe73c3ebac421779df9d55d' +
61cb0ef41Sopenharmony_ci    '180c3ae9942645e1d82fee8c9d294b3cb1a08a9931201b3c0e81fc47cacf8315a2af66' +
71cb0ef41Sopenharmony_ci    '324113c3b66230c34608c4f4593634ce02b267362277f0a840ca74bc3d1a6236952c5e' +
81cb0ef41Sopenharmony_ci    'd7aaf8a8fecbddfa7584e6978cea5d2a5b9fb7f1b48c8b0be58a305202754d83761073' +
91cb0ef41Sopenharmony_ci    '74793cf026aaee5300727d836cd71e71b345ddb2e44446ffc5b901635413890d910ea3' +
101cb0ef41Sopenharmony_ci    '80984a90191031323f16dbcc9d6be168b84885384ca03e12600ac1c248028af3726cc9' +
111cb0ef41Sopenharmony_ci    '3463882ea8c02aab', 'hex');
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci  const raw = {
141cb0ef41Sopenharmony_ci    'SHA-1': Buffer.from('47a20746d17179db65e0a79dedffc7fdf181081b', 'hex'),
151cb0ef41Sopenharmony_ci    'SHA-256': Buffer.from(
161cb0ef41Sopenharmony_ci      'e588ec0811463d767241df1074b47ae4071b51f2ce36537ba69ccdc3fdc2b7a8',
171cb0ef41Sopenharmony_ci      'hex'),
181cb0ef41Sopenharmony_ci    'SHA-384': Buffer.from(
191cb0ef41Sopenharmony_ci      '6b1da28eab1f582ad9718effe05e23d5fd2c9877a2d9443f90bec093bece2ea7' +
201cb0ef41Sopenharmony_ci      'd2354cd0bdc5e147d2e9009373494488', 'hex'),
211cb0ef41Sopenharmony_ci    'SHA-512': Buffer.from(
221cb0ef41Sopenharmony_ci      '5dcc359443aaf652fa1375d6b3e61fdcf29bb4a28bd5d3dcfa40f82f906bb280' +
231cb0ef41Sopenharmony_ci      '0455db03b5d31fb972a15a6d0103a24e56d156a119c0e5a1e92a44c3c5657cf9',
241cb0ef41Sopenharmony_ci      'hex')
251cb0ef41Sopenharmony_ci  }
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci  const signatures = {
281cb0ef41Sopenharmony_ci    'SHA-1': Buffer.from('0533902a99f8524ee50af01d38dedce133d98ca0', 'hex'),
291cb0ef41Sopenharmony_ci    'SHA-256': Buffer.from(
301cb0ef41Sopenharmony_ci      '85a40cea2e078c2827a3953ffb66c27b291a472b0d70a0000b45d823803eeb54',
311cb0ef41Sopenharmony_ci      'hex'),
321cb0ef41Sopenharmony_ci    'SHA-384': Buffer.from(
331cb0ef41Sopenharmony_ci      '217c3d50f0ba9a6d6eae1efdd7a518fe2e3880b582a40d061e9099c1e026ef58' +
341cb0ef41Sopenharmony_ci      '82548b5d5cecdd5598d99b6b6f3057ff', 'hex'),
351cb0ef41Sopenharmony_ci    'SHA-512': Buffer.from(
361cb0ef41Sopenharmony_ci      '61fb278c3ffb0cce2bf1cf723ddfd8ef1f931c0c618c25907324605939e3f9a2' +
371cb0ef41Sopenharmony_ci      'c6f4af690bda3407dc2f5770f6a0a44b954d64a332e3ee0821abf82b7f3e99c1',
381cb0ef41Sopenharmony_ci      'hex')
391cb0ef41Sopenharmony_ci  }
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci  const vectors = [];
421cb0ef41Sopenharmony_ci  Object.keys(raw).forEach((hash) => {
431cb0ef41Sopenharmony_ci    vectors.push({
441cb0ef41Sopenharmony_ci      hash,
451cb0ef41Sopenharmony_ci      keyBuffer: raw[hash],
461cb0ef41Sopenharmony_ci      plaintext,
471cb0ef41Sopenharmony_ci      signature: signatures[hash]
481cb0ef41Sopenharmony_ci    });
491cb0ef41Sopenharmony_ci  });
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci  return vectors;
521cb0ef41Sopenharmony_ci};
53