import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; const root = process.cwd(); const headerPath = path.join( root, ".local-toolchain/node-v22.22.2-linux-x64/include/node/openssl/archs/linux-elf/asm/include/openssl/core_names.h", ); const source = fs.readFileSync(headerPath, "utf8"); function expectPattern(pattern, message) { assert.match(source, pattern, message); } function expectCount(pattern, expected, message) { const matches = source.match(new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`)) ?? []; assert.equal(matches.length, expected, message); } expectPattern(/Generated by Makefile from include\/openssl\/core_names\.h\.in/, "header should remain generated from the upstream template"); expectPattern(/^#define OSSL_CIPHER_CTS_MODE_CS1 "CS1"$/m, "CTS mode CS1 constant should exist"); expectPattern(/^#define OSSL_CIPHER_NAME_AES_256_GCM_SIV "AES-256-GCM-SIV"$/m, "AES-256-GCM-SIV cipher name should exist"); expectPattern(/^#define OSSL_DIGEST_NAME_SHA3_512 "SHA3-512"$/m, "SHA3-512 digest name should exist"); expectPattern(/^#define OSSL_MAC_NAME_HMAC "HMAC"$/m, "HMAC MAC name should exist"); expectPattern(/^#define OSSL_KDF_NAME_SCRYPT "SCRYPT"$/m, "SCRYPT KDF name should exist"); expectPattern(/^#define OSSL_PKEY_RSA_PAD_MODE_OAEP "oaep"$/m, "RSA OAEP padding mode should exist"); expectPattern(/^#define OSSL_PKEY_EC_GROUP_CHECK_NAMED_NIST "named-nist"$/m, "EC named-nist group check value should exist"); expectPattern(/^# define OSSL_ASYM_CIPHER_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST$/m, "digest alias should target the shared pkey macro"); expectPattern(/^# define OSSL_CIPHER_PARAM_AEAD_IVLEN OSSL_CIPHER_PARAM_IVLEN$/m, "AEAD IV length alias should target the base IV length macro"); expectCount(/^#define OSSL_CIPHER_CTS_MODE_CS[123] "CS[123]"$/gm, 3, "exactly three CTS mode values should be defined"); expectCount(/^#define OSSL_DIGEST_NAME_SHA2_512 "SHA2-512"$/gm, 1, "SHA2-512 digest constant should not be duplicated"); console.log(`ok: ${path.relative(root, headerPath)}`);