efiencrypt 0.0.0

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 DivDE divde@musicociel.fr
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # efiencrypt
2
+
3
+ **Encrypts an EFI binary using a hash derived from user-defined data (random data, disk sectors, SMBIOS fields, ...)**
4
+
5
+ `efiencrypt` is a small utility that:
6
+
7
+ - Computes a cryptographic key: the SHA-256 hash of a collection of "hash components" (random data, disk sectors, SMBIOS fields, ...).
8
+ - Encrypts an input EFI binary with this cryptographic key (using AES-256-CBC)
9
+ - Generates code that
10
+ - embeds the encrypted EFI binary, the random hash components and the random initialization vector
11
+ - computes again the cryptographic key from the various "hash components" at boot time, thanks to the code coming from [this fast SHA-256 implementation](https://www.nayuki.io/page/fast-sha2-hashes-in-x86-assembly)
12
+ - decrypts the encrypted EFI binary, thanks to the code coming from [this fast AES implementation](https://github.com/SIIR3X/aes-ni)
13
+ - Builds the code with [GNU-EFI](https://sourceforge.net/projects/gnu-efi/)
14
+
15
+ The resulting EFI can be booted with QEMU or any UEFI firmware.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Install globally (so that `efiencrypt` becomes a CLI command)
21
+ npm install -g efiencrypt
22
+
23
+ # Or use it locally in a project
24
+ npm install efiencrypt
25
+ ```
26
+
27
+ The `efiencrypt` command is exposed on the path when installed globally.
28
+
29
+ ## Usage
30
+
31
+ ### CLI
32
+
33
+ Check `efiencrypt --help` for the full list of options.
34
+
35
+ Simplest usage:
36
+
37
+ ```bash
38
+ # Use the default random 32-bytes hash component:
39
+ efiencrypt -i input.efi -o output.efi
40
+ ```
41
+
42
+ Usage with SMBIOS dump:
43
+
44
+ ```bash
45
+ # Extracts smbios data from the computer:
46
+ dmidecode --dump-bin smbios.bin
47
+ # Use the default system-serial-number and system-uuid SMBIOS fields:
48
+ efiencrypt -i input.efi -s smbios.bin -o output.efi
49
+ ```
50
+
51
+ Usage with a configuration file:
52
+
53
+ ```bash
54
+ efiencrypt -c config.ts
55
+ ```
56
+
57
+ Options passed on the command line override values in the config file.
58
+
59
+ ### Configuration file
60
+
61
+ The configuration file can be a `.json`, `.js` or even `.ts` file (any file accepted in [`require`](https://nodejs.org/api/modules.html#requireid) by node.js).
62
+
63
+ It should export a `Config` object.
64
+
65
+ See [`test/config.ts`](test/config.ts) for a comprehensive example.
66
+
67
+ ```ts
68
+ // config.ts
69
+ import type { Config } from "efiencrypt";
70
+
71
+ const config: Config = {
72
+ inputFile: "input.efi",
73
+ outputFile: "output.efi",
74
+ hashComponents: [
75
+ { type: "random", length: 64 },
76
+ // ...
77
+ ],
78
+ };
79
+
80
+ export default config;
81
+ ```
82
+
83
+ ### API
84
+
85
+ The package exports a `build` function to run the build programmatically:
86
+
87
+ ```ts
88
+ import { build } from "efiencrypt";
89
+
90
+ await build({
91
+ inputFile: "input.efi",
92
+ outputFile: "output.efi",
93
+ hashComponents: [
94
+ { type: "random", length: 64 },
95
+ // ...
96
+ ],
97
+ });
98
+ ```