efiencrypt 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # efiencrypt
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/efiencrypt)](https://www.npmjs.com/package/efiencrypt)
4
+
3
5
  **Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)**
4
6
 
5
7
  `efiencrypt` is a small utility that:
@@ -2382,7 +2382,7 @@ const spawnProcess = (command, args, options) => new Promise((resolve, reject) =
2382
2382
  if (!code && !signal) {
2383
2383
  resolve();
2384
2384
  } else {
2385
- throw new Error("Command failed");
2385
+ reject(new Error("Command failed"));
2386
2386
  }
2387
2387
  });
2388
2388
  });
@@ -2414,7 +2414,7 @@ const build = async (config) => {
2414
2414
  await genCode(config);
2415
2415
  }
2416
2416
  if (!config.skipExtract) {
2417
- const extract = (await import("./extract-BW1V8DVW.js")).extract;
2417
+ const extract = (await import("./extract-BvhlZgSs.js")).extract;
2418
2418
  await extract(config.buildFolder);
2419
2419
  }
2420
2420
  if (!config.skipMake) {
package/efiencrypt CHANGED
@@ -5,7 +5,7 @@ import require$$2, { join, resolve } from "node:path";
5
5
  import require$$3 from "node:fs";
6
6
  import require$$4 from "node:process";
7
7
  import { createRequire } from "node:module";
8
- import { b as build } from "./build-laCVTTyp.js";
8
+ import { b as build } from "./build-CUHiK1Y8.js";
9
9
  function getDefaultExportFromCjs(x) {
10
10
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
11
11
  }
@@ -3458,7 +3458,7 @@ const {
3458
3458
  Help
3459
3459
  } = commander;
3460
3460
  const name = "efiencrypt";
3461
- const version = "1.0.0";
3461
+ const version = "1.0.1";
3462
3462
  const description = "Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)";
3463
3463
  program.name(name).description(description).showHelpAfterError(true).option("-c, --config-file <configFile>", "configuration file").option("-i, --input-file <inputFile>", "path to the input efi file to embed").option("-o, --output-file <outputFile>", "path to the output efi file to write").option("-s, --smbios <smbios>", "path to the input smbios dump file").option("-b, --build-folder <buildFolder>", "folder where to build the code").option("--skip-gen-code", "skip generating code").option("--skip-extract", "skip extracting source code").option("--skip-make", "skip calling make").version(version).action(async (options) => {
3464
3464
  try {
@@ -11758,7 +11758,7 @@ ENTRY(efi_call10)
11758
11758
  const __vite_glob_0_175 = '/*++\n\nCopyright (c) 1998 Intel Corporation\n\nModule Name:\n\n initplat.c\n\nAbstract:\n\n\n\n\nRevision History\n\n--*/\n\n#include "lib.h"\n\nVOID\nInitializeLibPlatform (\n IN EFI_HANDLE ImageHandle EFI_UNUSED,\n IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED\n )\n{\n}\n\n';
11759
11759
  const __vite_glob_0_176 = '/*++\n\nCopyright (c) 1998 Intel Corporation\n\nModule Name:\n\n math.c\n\nAbstract:\n\n\n\n\nRevision History\n\n--*/\n\n#include "lib.h"\n\n\n//\n// Declare runtime functions\n//\n\n#ifdef RUNTIME_CODE\n#ifndef __GNUC__\n#pragma RUNTIME_CODE(LShiftU64)\n#pragma RUNTIME_CODE(RShiftU64)\n#pragma RUNTIME_CODE(MultU64x32)\n#pragma RUNTIME_CODE(DivU64x32)\n#endif\n#endif\n\n//\n//\n//\n\nUINT64\nLShiftU64 (\n IN UINT64 Operand,\n IN UINTN Count\n )\n// Left shift 64bit by 32bit and get a 64bit result\n{\n#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)\n return Operand << Count;\n#else\n UINT64 Result;\n _asm {\n mov eax, dword ptr Operand[0]\n mov edx, dword ptr Operand[4]\n mov ecx, Count\n and ecx, 63\n\n shld edx, eax, cl\n shl eax, cl\n\n cmp ecx, 32\n jc short ls10\n\n mov edx, eax\n xor eax, eax\n\nls10:\n mov dword ptr Result[0], eax\n mov dword ptr Result[4], edx\n }\n\n return Result;\n#endif\n}\n\nUINT64\nRShiftU64 (\n IN UINT64 Operand,\n IN UINTN Count\n )\n// Right shift 64bit by 32bit and get a 64bit result\n{\n#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)\n return Operand >> Count;\n#else\n UINT64 Result;\n _asm {\n mov eax, dword ptr Operand[0]\n mov edx, dword ptr Operand[4]\n mov ecx, Count\n and ecx, 63\n\n shrd eax, edx, cl\n shr edx, cl\n\n cmp ecx, 32\n jc short rs10\n\n mov eax, edx\n xor edx, edx\n\nrs10:\n mov dword ptr Result[0], eax\n mov dword ptr Result[4], edx\n }\n\n return Result;\n#endif\n}\n\n\nUINT64\nMultU64x32 (\n IN UINT64 Multiplicand,\n IN UINTN Multiplier\n )\n// Multiple 64bit by 32bit and get a 64bit result\n{\n#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)\n return Multiplicand * Multiplier;\n#else\n UINT64 Result;\n _asm {\n mov eax, dword ptr Multiplicand[0]\n mul Multiplier\n mov dword ptr Result[0], eax\n mov dword ptr Result[4], edx\n mov eax, dword ptr Multiplicand[4]\n mul Multiplier\n add dword ptr Result[4], eax\n }\n\n return Result;\n#endif\n}\n\nUINT64\nDivU64x32 (\n IN UINT64 Dividend,\n IN UINTN Divisor,\n OUT UINTN *Remainder OPTIONAL\n )\n// divide 64bit by 32bit and get a 64bit result\n// N.B. only works for 31bit divisors!!\n{\n#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)\n if (Remainder)\n *Remainder = Dividend % Divisor;\n return Dividend / Divisor;\n#else\n UINT32 Rem;\n UINT32 bit; \n\n ASSERT (Divisor != 0);\n ASSERT ((Divisor >> 31) == 0);\n\n //\n // For each bit in the dividend\n //\n\n Rem = 0;\n for (bit=0; bit < 64; bit++) {\n _asm {\n shl dword ptr Dividend[0], 1 ; shift rem:dividend left one\n rcl dword ptr Dividend[4], 1 \n rcl dword ptr Rem, 1 \n\n mov eax, Rem\n cmp eax, Divisor ; Is Rem >= Divisor?\n cmc ; No - do nothing\n sbb eax, eax ; Else, \n sub dword ptr Dividend[0], eax ; set low bit in dividen\n and eax, Divisor ; and\n sub Rem, eax ; subtract divisor \n }\n }\n\n if (Remainder) {\n *Remainder = Rem;\n }\n\n return Dividend;\n#endif\n}\n';
11760
11760
  const __vite_glob_0_177 = ' .text\n .globl setjmp\n#ifndef __MINGW32__\n .type setjmp, @function\n#else\n .def setjmp; .scl 2; .type 32; .endef\n#endif\nsetjmp:\n pop %rsi\n movq %rbx,0x00(%rdi)\n movq %rsp,0x08(%rdi)\n push %rsi\n movq %rbp,0x10(%rdi)\n movq %r12,0x18(%rdi)\n movq %r13,0x20(%rdi)\n movq %r14,0x28(%rdi)\n movq %r15,0x30(%rdi)\n movq %rsi,0x38(%rdi)\n xor %rax,%rax\n ret\n\n .globl longjmp\n#ifndef __MINGW32__\n .type longjmp, @function\n#else\n .def longjmp; .scl 2; .type 32; .endef\n#endif\nlongjmp:\n movl %esi, %eax\n movq 0x00(%rdi), %rbx\n movq 0x08(%rdi), %rsp\n movq 0x10(%rdi), %rbp\n movq 0x18(%rdi), %r12\n movq 0x20(%rdi), %r13\n movq 0x28(%rdi), %r14\n movq 0x30(%rdi), %r15\n xor %rdx,%rdx\n mov $1,%rcx\n cmp %rax,%rdx\n cmove %rcx,%rax\n jmp *0x38(%rdi)\n\n#if defined(__ELF__) && defined(__linux__)\n .section .note.GNU-stack,"",%progbits\n#endif\n';
11761
- const __vite_glob_0_178 = '#include <efi.h>\n#include <efilib.h>\n#include "aes.h"\n#include "gen-code.h"\n\nwchar_t *errorMsg = L"Error %d: %r\\n";\n\nEFI_STATUS\nefi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)\n{\n EFI_STATUS status = 0;\n\n InitializeLib(image_handle, system_table);\n\n UINT8 *payload = AllocatePool(enc_payload_len);\n CHECK_ERROR(!payload);\n\n sha256_context_t hash;\n sha256_init(&hash);\n status = gen_compute_hash(&hash, image_handle);\n sha256_finalize(&hash);\n\n aes_context_t decCTX;\n aes_context_init(&decCTX, (uint8_t *)hash.hash);\n aes_cbc_decrypt(\n &decCTX,\n iv,\n enc_payload,\n enc_payload_len,\n payload);\n sha256_init(&hash); // erase the key just after decryption\n size_t payload_len = aes_remove_padding(payload, enc_payload_len);\n\n EFI_HANDLE payloadHandle = NULL;\n status = uefi_call_wrapper(gBS->LoadImage, 6,\n FALSE,\n image_handle,\n NULL,\n payload,\n payload_len,\n &payloadHandle);\n CHECK_ERROR(!payloadHandle);\n\n FREE_POOL(payload);\n\n status = uefi_call_wrapper(gBS->StartImage, 3, payloadHandle, NULL, NULL);\n CHECK_ERROR(0);\n\n return 0;\n}\n';
11761
+ const __vite_glob_0_178 = '#include <efi.h>\n#include <efilib.h>\n#include "aes.h"\n#include "gen-code.h"\n\nwchar_t *errorMsg = L"Error %d: %r\\n";\n\nEFI_STATUS\nefi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)\n{\n EFI_STATUS status = 0;\n\n InitializeLib(image_handle, system_table);\n\n UINT8 *payload = AllocatePool(enc_payload_len);\n CHECK_ERROR(!payload);\n\n sha256_context_t hash;\n sha256_init(&hash);\n status = gen_compute_hash(&hash, image_handle);\n sha256_finalize(&hash);\n\n aes_context_t decCTX;\n aes_context_init(&decCTX, (uint8_t *)hash.hash);\n aes_cbc_decrypt(\n &decCTX,\n iv,\n enc_payload,\n enc_payload_len,\n payload);\n sha256_init(&hash); // erase the key just after decryption\n size_t payload_len = aes_remove_padding(payload, enc_payload_len);\n\n EFI_GUID GUID_LOADED_IMAGE = EFI_LOADED_IMAGE_PROTOCOL_GUID;\n EFI_GUID GUID_DEVICE_PATH = EFI_DEVICE_PATH_PROTOCOL_GUID;\n EFI_LOADED_IMAGE_PROTOCOL *loadedImage = NULL;\n EFI_DEVICE_PATH_PROTOCOL *bootDevice = NULL;\n HANDLE_PROTOCOL(image_handle, GUID_LOADED_IMAGE, &loadedImage);\n if (loadedImage) {\n HANDLE_PROTOCOL(loadedImage->DeviceHandle, GUID_DEVICE_PATH, &bootDevice);\n }\n\n EFI_HANDLE payloadHandle = NULL;\n status = uefi_call_wrapper(gBS->LoadImage, 6,\n FALSE,\n image_handle,\n bootDevice,\n payload,\n payload_len,\n &payloadHandle);\n CHECK_ERROR(!payloadHandle);\n\n FREE_POOL(payload);\n\n status = uefi_call_wrapper(gBS->StartImage, 3, payloadHandle, NULL, NULL);\n CHECK_ERROR(0);\n\n return 0;\n}\n';
11762
11762
  const __vite_glob_0_179 = `/*
11763
11763
  * SHA-256 hash in x86-64 assembly
11764
11764
  *
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b } from "./build-laCVTTyp.js";
1
+ import { b } from "./build-CUHiK1Y8.js";
2
2
  export {
3
3
  b as build
4
4
  };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"efiencrypt","version":"1.0.0","description":"Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)","type":"module","license":"MIT","bin":{"efiencrypt":"efiencrypt"},"repository":{"url":"https://github.com/davdiv/efiencrypt"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./smbios":{"types":"./smbios.d.ts","default":"./smbios.js"},"./schema.json":"./schema.json"}}
1
+ {"name":"efiencrypt","version":"1.0.1","description":"Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)","type":"module","license":"MIT","bin":{"efiencrypt":"efiencrypt"},"repository":{"url":"https://github.com/davdiv/efiencrypt"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./smbios":{"types":"./smbios.d.ts","default":"./smbios.js"},"./schema.json":"./schema.json"}}