repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

Replace tresor with encrypted dotfile secrets

07a87963319dbd6676e143b7f21d490a91a6673e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (28)

.dotfiles-aes-salt

Added
new file mode 100644
1 +E0Q84ELGtFZoZ6OZi5bVtgKiOGM8HBy6M4MNyFtrtIs=

.gitignore

Modified
1 -tresor/box_do_key
3 1 **/__pycache__
5 -gh/hosts.yml
7 3 nugu/output/
9 5 # Local runtime/package caches
30 26 fonts/.uuid
28 +ssh/known_hosts
29 +ssh/known_hosts.old
32 31 .env
33 32 .envrc
40 39 .*syncthing.*
42 -tresor/*.key
44 41 zed/settings_backup.json
46 42 .trash/

.secrets

Added
new file mode 100644
1 +# repo-relative paths encrypted by bootstripper's dotfiles-aes Git filter
2 +MusicBrainz/Picard.ini
3 +zed/settings.json
4 +ssh/github.key
5 +ssh/box.bugabinga.net.key
6 +ssh/klops.key
7 +ssh/tini.key
8 +ssh/hetzner.key
9 +ssh/aur.key
10 +ssh/bugabinga.net.key
11 +gh/hosts.yml
12 +pi/agent/auth.json

MusicBrainz/Picard.ini

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

NB-00718.symlinks

Modified
73 73 topgrade/win32.toml
74 74 ~/AppData/Roaming/topgrade.d/win32.toml
76 -tresor/1078030f-e587-4ed3-bce9-15f6ad113390
76 +ssh/github.key
77 77 ~/.ssh/github.key

bootstripper.java

Modified
1 1 import static java.text.MessageFormat.format;
3 +import java.io.ByteArrayOutputStream;
3 4 import java.io.IOException;
4 -import java.io.InputStreamReader;
5 +import java.net.InetAddress;
6 +import java.nio.charset.StandardCharsets;
5 7 import java.nio.file.Files;
6 8 import java.nio.file.LinkOption;
7 9 import java.nio.file.Path;
10 +import java.nio.file.attribute.PosixFilePermission;
8 11 import java.nio.file.attribute.PosixFilePermissions;
12 +import java.security.SecureRandom;
13 +import java.util.ArrayList;
14 +import java.util.Arrays;
15 +import java.util.Base64;
16 +import java.util.HashSet;
9 17 import java.util.List;
18 +import java.util.Set;
19 +import java.util.regex.Pattern;
20 +import java.util.stream.Collectors;
21 +import javax.crypto.SecretKeyFactory;
22 +import javax.crypto.spec.PBEKeySpec;
11 24 class bootstripper {
13 25 private final static String operating_system = System.getProperty("os.name");
14 26 private final static boolean win32 = operating_system.toLowerCase().contains("win");
27 + private final static String filter_name = "dotfiles-aes";
28 + private final static String key_file = ".git/dotfiles-aes.key";
29 + private final static String salt_file = ".dotfiles-aes-salt";
30 + private final static String secrets_file = ".secrets";
31 + private final static String attributes_begin = "# BEGIN bootstripper secrets";
32 + private final static String attributes_end = "# END bootstripper secrets";
33 + private final static byte[] aes_magic = new byte[] { 'D', 'F', 'A', 'E', 'S', '1' };
34 + private final static int salt_bytes = 32;
35 + private final static int derived_key_bits = 512;
36 + private final static int pbkdf2_iterations = 310_000;
16 38 public static void main(String[] arguments) throws Throwable {
39 + var command = "bootstrap";
17 40 var dorkfile_path_input = ".";
18 - var do_clean = false;
20 42 if (arguments.length == 1) {
21 - if ("clean".equals(arguments[0])) {
22 - do_clean = true;
23 - } else {
43 + if (is_command(arguments[0]))
44 + command = arguments[0];
45 + else
24 46 dorkfile_path_input = arguments[0];
25 - }
26 47 } else if (arguments.length == 2) {
27 - if ("clean".equals(arguments[0])) {
28 - do_clean = true;
29 - dorkfile_path_input = arguments[1];
30 - } else {
48 + if (!is_command(arguments[0])) {
31 49 usage();
32 50 throw fail();
52 + command = arguments[0];
53 + dorkfile_path_input = arguments[1];
34 54 } else if (arguments.length > 2) {
35 55 usage();
36 56 throw fail();
38 - var dorkfiles_root = Path.of(dorkfile_path_input).toRealPath();
39 - log("Assuming dorkfiles root repo in {0}.",
40 - emphasize_local(dorkfiles_root.toString()));
41 - var hostname = hostname();
42 - log("Hostname: {0}", emphasize_global(hostname));
43 - var symlinks_file = dorkfiles_root.resolve(hostname + ".symlinks");
44 - if (Files.exists(symlinks_file)) {
45 - if (do_clean)
46 - delete_symlinks(dorkfiles_root, symlinks_file);
47 - else
48 - create_symlinks(dorkfiles_root, symlinks_file);
49 - } else {
50 - throw fail("Expected a file containing symlinks at: {0}. Found nothing!",
51 - symlinks_file);
59 + var root = Path.of(dorkfile_path_input).toRealPath();
60 + if ("init-crypto".equals(command)) {
61 + init_crypto(root);
62 + return;
63 + }
64 + if ("check".equals(command)) {
65 + setup_crypto(root, false);
66 + check(root);
67 + return;
68 + }
70 + log("Assuming dorkfiles root repo in {0}.", emphasize_local(root.toString()));
71 + if ("clean".equals(command)) {
72 + var symlinks_file = symlinks_file(root);
73 + delete_symlinks(root, symlinks_file);
74 + return;
75 + }
77 + setup_crypto(root, true);
78 + check(root);
79 + var symlinks_file = symlinks_file(root);
80 + create_symlinks(root, symlinks_file);
81 + }
83 + static boolean is_command(String argument) {
84 + return "bootstrap".equals(argument) || "clean".equals(argument) || "check".equals(argument) || "init-crypto".equals(argument);
85 + }
87 + static void init_crypto(Path root) throws Throwable {
88 + require_git_repo(root);
89 + var salt = root.resolve(salt_file);
90 + if (Files.exists(salt)) {
91 + log("Crypto salt already exists: {0}", emphasize_local(salt_file));
92 + return;
93 + }
94 + var bytes = new byte[salt_bytes];
95 + new SecureRandom().nextBytes(bytes);
96 + Files.writeString(salt, Base64.getEncoder().encodeToString(bytes) + "\n", StandardCharsets.UTF_8);
97 + log("Created crypto salt: {0}", emphasize_local(salt_file));
98 + }
100 + static void setup_crypto(Path root, boolean restore) throws Throwable {
101 + require_git_repo(root);
102 + var secrets = read_secrets(root);
103 + if (secrets.isEmpty())
104 + return;
105 + require_normal_gitdir(root);
106 + install_filter(root);
107 + write_attributes(root, secrets);
108 + ensure_key(root);
109 + self_test_aes(root);
110 + if (restore)
111 + restore_tracked_secrets(root, secrets);
112 + apply_secret_permissions(root, secrets);
113 + install_pre_commit_hook(root);
116 + static void require_git_repo(Path root) throws Throwable {
117 + run(root, List.of("git", "rev-parse", "--is-inside-work-tree"), null, false);
120 + static void require_normal_gitdir(Path root) throws Throwable {
121 + if (!Files.isDirectory(root.resolve(".git")))
122 + throw fail("Expected normal .git directory. Linked worktrees are not supported yet.");
125 + static List<String> read_secrets(Path root) throws IOException {
126 + var path = root.resolve(secrets_file);
127 + if (!Files.exists(path))
128 + return List.of();
129 + var secrets = new ArrayList<String>();
130 + for (var raw : Files.readAllLines(path)) {
131 + var line = raw.strip();
132 + if (line.isEmpty() || line.startsWith("#"))
133 + continue;
134 + if (line.contains(" ") || line.contains("\t") || line.startsWith("/") || line.contains("\\"))
135 + throw new IllegalArgumentException("invalid secret path: " + line);
136 + secrets.add(line);
138 + return secrets;
141 + static void install_filter(Path root) throws Throwable {
142 + run(root, List.of("git", "config", "--local", "filter." + filter_name + ".clean",
143 + "java tools/aes.java encrypt --key-file " + key_file), null, false);
144 + run(root, List.of("git", "config", "--local", "filter." + filter_name + ".smudge",
145 + "java tools/aes.java decrypt --key-file " + key_file), null, false);
146 + run(root, List.of("git", "config", "--local", "filter." + filter_name + ".required", "true"), null, false);
149 + static void write_attributes(Path root, List<String> secrets) throws IOException {
150 + var attributes = root.resolve(".git/info/attributes");
151 + Files.createDirectories(attributes.getParent());
152 + var previous = Files.exists(attributes) ? Files.readString(attributes) : "";
153 + var lines = new ArrayList<String>();
154 + var in_block = false;
155 + for (var line : previous.split("\n", -1)) {
156 + if (attributes_begin.equals(line)) {
157 + in_block = true;
158 + continue;
160 + if (attributes_end.equals(line)) {
161 + in_block = false;
162 + continue;
164 + if (!in_block && !line.isEmpty())
165 + lines.add(line);
167 + lines.add(attributes_begin);
168 + for (var secret : secrets)
169 + lines.add(secret + " -text filter=" + filter_name + " -diff");
170 + lines.add(attributes_end);
171 + Files.writeString(attributes, String.join("\n", lines) + "\n", StandardCharsets.UTF_8);
174 + static void ensure_key(Path root) throws Throwable {
175 + var key = root.resolve(key_file);
176 + if (Files.exists(key))
177 + return;
178 + var salt = read_salt(root);
179 + var passphrase = passphrase();
180 + try {
181 + var factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
182 + var spec = new PBEKeySpec(passphrase, salt, pbkdf2_iterations, derived_key_bits);
183 + var encoded = factory.generateSecret(spec).getEncoded();
184 + Files.writeString(key, Base64.getEncoder().encodeToString(encoded) + "\n", StandardCharsets.UTF_8);
185 + chmod(key, "rw-------");
186 + log("Cached dotfiles AES key in {0}", emphasize_local(key_file));
187 + } finally {
188 + Arrays.fill(passphrase, '\0');
192 + static byte[] read_salt(Path root) throws IOException {
193 + var path = root.resolve(salt_file);
194 + if (!Files.exists(path))
195 + throw new IllegalStateException("Missing " + salt_file + ". Run `java bootstripper.java init-crypto` once for this repo.");
196 + return Base64.getDecoder().decode(Files.readString(path).trim());
199 + static char[] passphrase() {
200 + var from_env = System.getenv("DOTFILES_AES_PASSPHRASE");
201 + if (from_env != null && !from_env.isEmpty())
202 + return from_env.toCharArray();
203 + var console = System.console();
204 + if (console == null)
205 + throw new IllegalStateException("No console available. Set DOTFILES_AES_PASSPHRASE for non-interactive bootstrap.");
206 + var first = console.readPassword("[%s]:", emphasize_global("Dotfiles AES passphrase"));
207 + var second = console.readPassword("[%s]:", emphasize_global("Repeat passphrase"));
208 + if (!Arrays.equals(first, second))
209 + throw new IllegalStateException("Passphrases do not match.");
210 + Arrays.fill(second, '\0');
211 + return first;
214 + static void self_test_aes(Path root) throws Throwable {
215 + var plain = "bootstripper self-test".getBytes(StandardCharsets.UTF_8);
216 + var encrypted = run(root, List.of("java", "tools/aes.java", "encrypt", "--key-file", key_file), plain, false).stdout;
217 + if (!starts_with(encrypted, aes_magic))
218 + throw fail("AES self-test did not produce expected magic header.");
219 + var decrypted = run(root, List.of("java", "tools/aes.java", "decrypt", "--key-file", key_file), encrypted, false).stdout;
220 + if (!Arrays.equals(plain, decrypted))
221 + throw fail("AES self-test failed to round-trip.");
224 + static void restore_tracked_secrets(Path root, List<String> secrets) throws Throwable {
225 + var tracked = new ArrayList<String>();
226 + for (var secret : secrets) {
227 + var result = run(root, List.of("git", "ls-files", "--error-unmatch", "--", secret), null, false, false);
228 + if (result.exit == 0) {
229 + tracked.add(secret);
230 + var path = root.resolve(secret);
231 + if (Files.exists(path) && starts_with(Files.readAllBytes(path), aes_magic))
232 + Files.delete(path);
235 + if (tracked.isEmpty())
236 + return;
237 + var command = new ArrayList<String>();
238 + command.addAll(List.of("git", "restore", "--source=HEAD", "--worktree", "--"));
239 + command.addAll(tracked);
240 + run(root, command, null, false);
243 + static void apply_secret_permissions(Path root, List<String> secrets) throws IOException {
244 + for (var secret : secrets) {
245 + var path = root.resolve(secret);
246 + if (Files.exists(path) && secret.startsWith("ssh/") && secret.endsWith(".key"))
247 + chmod(path, "rw-------");
251 + static void install_pre_commit_hook(Path root) throws IOException {
252 + var hooks = root.resolve(".git/hooks");
253 + Files.createDirectories(hooks);
254 + var hook = hooks.resolve("pre-commit");
255 + Files.writeString(hook, "#!/bin/sh\ncd \"$(git rev-parse --show-toplevel)\" || exit 1\nexec java bootstripper.java check\n", StandardCharsets.UTF_8);
256 + chmod(hook, "rwxr-xr-x");
259 + static void check(Path root) throws Throwable {
260 + var secrets = read_secrets(root);
261 + if (secrets.isEmpty())
262 + return;
263 + check_filter(root);
264 + check_attributes(root, secrets);
265 + check_key_not_tracked(root);
266 + check_staged_secrets(root, secrets);
267 + check_no_tresor_refs(root);
268 + check_staged_plaintext_patterns(root);
269 + log("OK bootstripper check passed.");
272 + static void check_filter(Path root) throws Throwable {
273 + var clean = run(root, List.of("git", "config", "--local", "--get", "filter." + filter_name + ".clean"), null, false).text().strip();
274 + var smudge = run(root, List.of("git", "config", "--local", "--get", "filter." + filter_name + ".smudge"), null, false).text().strip();
275 + var required = run(root, List.of("git", "config", "--local", "--get", "filter." + filter_name + ".required"), null, false).text().strip();
276 + if (!clean.equals("java tools/aes.java encrypt --key-file " + key_file))
277 + throw fail("Unexpected clean filter: {0}", clean);
278 + if (!smudge.equals("java tools/aes.java decrypt --key-file " + key_file))
279 + throw fail("Unexpected smudge filter: {0}", smudge);
280 + if (!required.equals("true"))
281 + throw fail("Filter is not required.");
284 + static void check_attributes(Path root, List<String> secrets) throws Throwable {
285 + for (var secret : secrets) {
286 + var output = run(root, List.of("git", "check-attr", "text", "filter", "diff", "--", secret), null, false).text();
287 + if (!output.contains(secret + ": text: unset"))
288 + throw fail("Missing -text attribute for {0}: {1}", secret, output.strip());
289 + if (!output.contains(secret + ": filter: " + filter_name))
290 + throw fail("Missing filter attribute for {0}: {1}", secret, output.strip());
291 + if (!output.contains(secret + ": diff: unset"))
292 + throw fail("Missing -diff attribute for {0}: {1}", secret, output.strip());
296 + static void check_key_not_tracked(Path root) throws Throwable {
297 + var bad = run(root, List.of("git", "ls-files", "--", key_file), null, false).text().strip();
298 + if (!bad.isEmpty())
299 + throw fail("Key file is tracked: {0}", key_file);
300 + var staged = run(root, List.of("git", "diff", "--cached", "--name-only", "--", key_file), null, false).text().strip();
301 + if (!staged.isEmpty())
302 + throw fail("Key file is staged: {0}", key_file);
305 + static void check_staged_secrets(Path root, List<String> secrets) throws Throwable {
306 + for (var secret : secrets) {
307 + var status = run(root, List.of("git", "diff", "--cached", "--name-status", "--", secret), null, false).text().strip();
308 + if (status.isEmpty() || status.startsWith("D"))
309 + continue;
310 + var blob = run(root, List.of("git", "show", ":" + secret), null, false).stdout;
311 + if (!starts_with(blob, aes_magic))
312 + throw fail("Staged secret is not encrypted: {0}", secret);
313 + run(root, List.of("java", "tools/aes.java", "decrypt", "--key-file", key_file), blob, false);
317 + static void check_no_tresor_refs(Path root) throws IOException {
318 + try (var stream = Files.list(root)) {
319 + var files = stream.filter(path -> path.getFileName().toString().endsWith(".symlinks")).collect(Collectors.toList());
320 + for (var file : files) {
321 + var line_number = 0;
322 + for (var line : Files.readAllLines(file)) {
323 + line_number++;
324 + if (line.strip().startsWith("tresor/"))
325 + throw new IllegalStateException("tresor reference remains: " + file.getFileName() + ":" + line_number);
331 + static void check_staged_plaintext_patterns(Path root) throws Throwable {
332 + var diff = run(root, List.of("git", "diff", "--cached", "-U0"), null, false).text();
333 + var patterns = List.of(
334 + Pattern.compile("gh[pousr]_[A-Za-z0-9_]{20,}"),
335 + Pattern.compile("github_personal_access_token\\s*\\\":\\s*\\\"[^<G][^\\\"]+\\\""),
336 + Pattern.compile("oauth_(access|refresh)_token\\s*=\\s*\\S+"),
337 + Pattern.compile("Authorization\\s*[:=]\\s*Bearer\\s+[A-Za-z0-9._-]{20,}", Pattern.CASE_INSENSITIVE));
338 + for (var pattern : patterns) {
339 + var matcher = pattern.matcher(diff);
340 + if (matcher.find())
341 + throw fail("Potential plaintext secret in staged diff: {0}", matcher.group());
345 + static Path symlinks_file(Path root) throws Throwable {
346 + var hostname = hostname();
347 + log("Hostname: {0}", emphasize_global(hostname));
348 + var symlinks_file = root.resolve(hostname + ".symlinks");
349 + if (!Files.exists(symlinks_file))
350 + throw fail("Expected a file containing symlinks at: {0}. Found nothing!", symlinks_file);
351 + return symlinks_file;
55 354 static void create_symlinks(Path root, Path symlinks_file) throws Throwable {
56 - log("Creating symlinks as defined in {0} file.",
57 - emphasize_local(symlinks_file.getFileName().toString()));
355 + log("Creating symlinks as defined in {0} file.", emphasize_local(symlinks_file.getFileName().toString()));
58 356 var lines = Files.readAllLines(symlinks_file);
59 357 for_each_mapping(lines, (source, target) -> link(root, source, target));
62 360 static void delete_symlinks(Path root, Path symlinks_file) throws Throwable {
63 - log("Deleting symlinks as defined in {0} file.",
64 - emphasize_local(symlinks_file.getFileName().toString()));
361 + log("Deleting symlinks as defined in {0} file.", emphasize_local(symlinks_file.getFileName().toString()));
65 362 var lines = Files.readAllLines(symlinks_file);
66 363 for_each_mapping(lines, (source, target) -> delete(root, source, target));
74 371 if (Files.exists(target_path, LinkOption.NOFOLLOW_LINKS)) {
75 372 if (Files.isSymbolicLink(target_path)) {
76 - log("\nOK {0} exists and points to {1}, a symlink indeed!\nDeleting {0}.",
77 - emphasize_global(target_path.toString()),
78 - emphasize_local(source_path.toString()));
79 - // a symlink is always a file. no need to handle folders
373 + log("\nOK {0} exists and points to {1}, a symlink indeed!\nDeleting {0}.", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
80 374 Files.delete(target_path);
81 375 } else {
82 - log("\nNOPE {0} exists, but it is not a symlink! Clean manually.",
83 - target_path.toString());
376 + log("\nNOPE {0} exists, but it is not a symlink! Clean manually.", target_path.toString());
89 382 var home = System.getProperty("user.home");
90 383 var source_path = root.resolve(source).toAbsolutePath();
91 384 if (!Files.exists(source_path)) {
92 - log("\n{0} does not exist anymore in my dorkfiles. Have I yeeted it?",
93 - emphasize_global(source_path.toString()));
385 + log("\n{0} does not exist anymore in my dorkfiles. Have I yeeted it?", emphasize_global(source_path.toString()));
94 386 return;
96 388 var target_path = Path.of(target.replace("~", home)).toAbsolutePath();
97 - var is_directory = Files.isDirectory(source_path);
98 389 if (Files.exists(target_path, LinkOption.NOFOLLOW_LINKS)) {
99 390 if (Files.exists(target_path)) {
100 - log("\nOK {0} already exists!\nNot linking {1}.",
101 - emphasize_global(target_path.toString()),
102 - emphasize_local(source_path.toString()));
391 + log("\nOK {0} already exists!\nNot linking {1}.", emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
103 392 return;
104 393 } else {
105 - log("\nNOPE {0} exists, but it points into nirvana. Removing broken link!",
106 - target_path.toString());
394 + log("\nNOPE {0} exists, but it points into nirvana. Removing broken link!", target_path.toString());
107 395 Files.delete(target_path);
110 - if (source_path.getParent().endsWith("tresor")) {
111 - log("\nDetected encrypted file in tresor! {0}", source_path.getFileName());
112 - final var success = decrypt(source_path, target_path);
113 - if (success)
114 - log("\nDECRYPT {0} to {1}!", source_path, target_path);
115 - else
116 - log("\nFAIL DECRYPT {0} to {1}!", source_path, target_path);
117 - return;
118 - }
119 - log("\nLINK {0} TO {1}.", emphasize_local(source_path.toString()),
120 - emphasize_local(target_path.toString()));
398 + log("\nLINK {0} TO {1}.", emphasize_local(source_path.toString()), emphasize_local(target_path.toString()));
121 399 Files.createDirectories(target_path.getParent());
122 - try {
123 - Files.createSymbolicLink(target_path, source_path);
124 - } catch (Exception __) {
125 - /*
126 - * Creating symbolic links on Windows only recently became possible
127 - * without admin rights. And even that, is only available in Developer
128 - * Mode. However, most tools (including JDK) have not yet adapted to this
129 - * change and still require admin rights. Until that is fixed, we escape
130 - * to a system tool that is known to behave correctly in this regard.
131 - */
132 - if (win32) {
133 - var process = new ProcessBuilder();
134 - var command = process.command();
135 - command.add("cmd.exe");
136 - command.add("/c");
137 - command.add("mklink");
138 - if (is_directory) {
139 - command.add("/d");
140 - }
141 - command.add(target_path.toString());
142 - command.add(source_path.toString());
143 - log(command.toString());
144 - process.inheritIO().start().onExit().join();
145 - } else {
146 - __.printStackTrace();
147 - throw fail("Could not create symbolic link!");
148 - }
149 - }
400 + if (target_path.getParent().endsWith(".ssh"))
401 + chmod(target_path.getParent(), "rwx------");
402 + Files.createSymbolicLink(target_path, source_path);
152 405 static String hostname() throws Exception {
153 - var process_builder = new ProcessBuilder().command("hostname");
154 - Process process;
406 + var computername = System.getenv("COMPUTERNAME");
407 + if (computername != null && !computername.isBlank())
408 + return computername;
409 + var hostname = System.getenv("HOSTNAME");
410 + if (hostname != null && !hostname.isBlank() && !"localhost".equals(hostname))
411 + return hostname;
412 + var detected = InetAddress.getLocalHost().getHostName();
413 + if ("localhost".equals(detected) && System.getenv("PREFIX") != null)
414 + return "termux";
415 + return detected;
418 + static void chmod(Path path, String permissions) throws IOException {
419 + if (win32)
420 + return;
156 - process = process_builder.start().onExit().join();
157 - } catch (IOException __) {
158 - process = new ProcessBuilder()
159 - .command("hostnamectl", "hostname")
160 - .start()
161 - .onExit()
162 - .join();
163 - }
164 - try (var reader = new InputStreamReader(process.getInputStream())) {
165 - int character = -1;
166 - var output = new StringBuilder();
167 - while ((character = reader.read()) != -1) {
168 - if (character == '\n' || character == '\r')
169 - continue;
170 - output.append((char) character);
171 - }
172 - var name = output.toString();
173 - if ("localhost".equals(name)) {
174 - // we are inside termux
175 - assert System.getenv("PREFIX") != null;
176 - return "termux";
177 - }
178 - return name;
422 + Files.setPosixFilePermissions(path, PosixFilePermissions.fromString(permissions));
423 + } catch (UnsupportedOperationException ignored) {
182 - static boolean decrypt(Path source_path, Path target_path) throws IOException {
183 - final var command = new String[] {
184 - "java",
185 - "./tools/aes.java",
186 - "decrypt",
187 - source_path.toString(),
188 - target_path.toString(),
189 - };
190 - final var success = new ProcessBuilder(command)
191 - .inheritIO()
192 - .start()
193 - .onExit()
194 - .thenApply(p -> p.exitValue() == 0)
195 - .join();
196 - if (success && !win32) {
197 - final var user_read_only = PosixFilePermissions.fromString("r--------");
198 - Files.setPosixFilePermissions(target_path, user_read_only);
427 + static boolean starts_with(byte[] bytes, byte[] prefix) {
428 + if (bytes.length < prefix.length)
429 + return false;
430 + for (var index = 0; index < prefix.length; index++)
431 + if (bytes[index] != prefix[index])
432 + return false;
433 + return true;
436 + static Result run(Path directory, List<String> command, byte[] input, boolean inherit_io) throws Throwable {
437 + return run(directory, command, input, inherit_io, true);
440 + static Result run(Path directory, List<String> command, byte[] input, boolean inherit_io, boolean fail) throws Throwable {
441 + var process_builder = new ProcessBuilder(command).directory(directory.toFile());
442 + if (inherit_io)
443 + process_builder.inheritIO();
444 + var process = process_builder.start();
445 + if (input != null) {
446 + try (var stdin = process.getOutputStream()) {
447 + stdin.write(input);
449 + } else {
450 + process.getOutputStream().close();
200 - return success;
452 + var stdout = inherit_io ? new byte[0] : process.getInputStream().readAllBytes();
453 + var stderr = inherit_io ? new byte[0] : process.getErrorStream().readAllBytes();
454 + var exit = process.waitFor();
455 + var result = new Result(exit, stdout, stderr);
456 + if (fail && exit != 0)
457 + throw fail("Command failed ({0}): {1}\n{2}", exit, String.join(" ", command), result.error().strip());
458 + return result;
203 461 static void usage() {
204 462 log("Bootstraps bugabingas {0}.", emphasize_local("dorkfiles"));
205 - log("{0}: java bootstripper.java [clean] [dotfiles root path]",
206 - emphasize_global("Usage"));
463 + log("{0}: java bootstripper.java [init-crypto|check|clean] [dotfiles root path]", emphasize_global("Usage"));
209 466 static String emphasize_global(String message) {
241 498 void apply(A a, B b) throws Throwable;
244 - static void for_each_mapping(List<String> lines, ThrowUp<String, String> block)
245 - throws Throwable {
501 + static void for_each_mapping(List<String> lines, ThrowUp<String, String> block) throws Throwable {
246 502 String source = null;
247 503 String target = null;
248 504 for (String line : lines) {
521 + static class Result {
522 + final int exit;
523 + final byte[] stdout;
524 + final byte[] stderr;
526 + Result(int exit, byte[] stdout, byte[] stderr) {
527 + this.exit = exit;
528 + this.stdout = stdout;
529 + this.stderr = stderr;
532 + String text() {
533 + return new String(stdout, StandardCharsets.UTF_8);
536 + String error() {
537 + return new String(stderr, StandardCharsets.UTF_8);

desktop.symlinks

Modified
94 94 ghostty
95 95 ~/.config/ghostty
97 -ssh/config
98 -~/.ssh/config
97 +ssh
98 +~/.ssh
100 100 neovim
101 101 ~/.config/nvim
130 130 psd/psd.conf
131 131 ~/.config/psd/psd.conf
133 -tresor/1078030f-e587-4ed3-bce9-15f6ad113390
134 -~/.ssh/github.key
136 -tresor/1be0bc56-591a-4630-8ba4-0007506841cf
137 -~/.ssh/box.bugabinga.net.key
139 -tresor/f3c469df-6b5a-4755-897c-9597ca10b0af
140 -~/.ssh/klops.key
142 -tresor/f8f81035-cb10-4639-965f-2a1c33a7ce9e
143 -~/.ssh/tini.key

fedora.symlinks

Modified
127 127 psd/psd.conf
128 128 ~/.config/psd/psd.conf
130 -tresor/1078030f-e587-4ed3-bce9-15f6ad113390
130 +ssh/github.key
131 131 ~/.ssh/github.key
133 -tresor/1be0bc56-591a-4630-8ba4-0007506841cf
133 +ssh/box.bugabinga.net.key
134 134 ~/.ssh/box.bugabinga.net.key
136 -tresor/f3c469df-6b5a-4755-897c-9597ca10b0af
136 +ssh/klops.key
137 137 ~/.ssh/klops.key
139 -tresor/f8f81035-cb10-4639-965f-2a1c33a7ce9e
139 +ssh/tini.key
140 140 ~/.ssh/tini.key

pi/.gitignore

Modified
1 -# Local secrets; never commit
2 -agent/auth.json
4 1 # Local env files
5 2 .env
6 3 .env.*

pi/agent/auth.json

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/aur.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/aur.key.pub

Added
new file mode 100644
1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBXVyQ6hNUhHmAbFAO77XwkS6IJk4x039OHNM2n0HAiA aur

ssh/box.bugabinga.net.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/box.bugabinga.net.key.pub

Added
new file mode 100644
1 +ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHa1A6wxXpUuy6rwgnj+RXf3MdeZ3nbvV+UwrDtW33s9g6oJAI2NiuHwscMBUu8gIPDrmeMYCBsL5PEahQCtSHY= oli@fedora

ssh/bugabinga.net.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/bugabinga.net.key.pub

Added
new file mode 100644
1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEsx7YD4yTLs2h6mdTYYyrzReqMXWZ0WmblYZ8C8d1Yj oliver@bugabinga.net

ssh/config

Modified
1 1 # SSH client configuration
2 2 # defines bookmarks/templates for hosts and options to quickly connect to known hosts
4 -Host box
4 +Host box box.bugabinga.net
5 5 HostName 46.101.206.216
6 + User root
6 7 IdentityFile ~/.ssh/box.bugabinga.net.key
8 9 Host github.com
21 22 User oli
22 23 IdentityFile ~/.ssh/klops.key
24 -Host fedora
25 - Hostname fedora
26 - User oli
28 -Host kea
29 - HostName kea
30 - User admlnx
32 25 Host alpha
33 26 HostName alpha.bugabinga.net
34 27 Port 49200

ssh/github.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/github.key.pub

Added
new file mode 100644
1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICyZgTxIo9LIsvZLl/iKxlh6vf2WSiz6tyHEQI9lYnC6 oli@velma

ssh/hetzner.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/hetzner.key.pub

Added
new file mode 100644
1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAEgwviWn4mm3T0hAWk3NaZHqed+Xn98czNmpaxB9CMY oliver@bugabinga.net

ssh/klops.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

ssh/klops.key.pub

Added
new file mode 100644
1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICYH4HzF6Zgd2LW+a+WD2F+LobCLaVKorPVo6OyLFQ04 oli@x230

ssh/tini.key

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.

termux.symlinks

Modified
67 67 termux-shortcuts
68 68 ~/.shortcuts
70 -tresor/1078030f-e587-4ed3-bce9-15f6ad113390
70 +ssh/github.key
71 71 ~/.ssh/github.key
73 -tresor/1be0bc56-591a-4630-8ba4-0007506841cf
73 +ssh/box.bugabinga.net.key
74 74 ~/.ssh/box.bugabinga.net.key
76 -tresor/f3c469df-6b5a-4755-897c-9597ca10b0af
76 +ssh/klops.key
77 77 ~/.ssh/klops.key
79 -tresor/f8f81035-cb10-4639-965f-2a1c33a7ce9e
79 +ssh/tini.key
80 80 ~/.ssh/tini.key

tools/aes.java

Modified
1 -import static java.lang.System.out;
2 -import static java.nio.file.StandardOpenOption.CREATE_NEW;
3 -import static java.nio.file.StandardOpenOption.READ;
4 -import static java.nio.file.StandardOpenOption.WRITE;
6 -import java.nio.file.*;
7 -import java.nio.charset.*;
8 -import java.nio.*;
9 -import java.io.*;
11 -import java.security.*;
13 -import javax.crypto.*;
14 -import javax.crypto.spec.*;
16 -class aes {
17 - enum Command {
18 - ENCRYPT, DECRYPT
19 - }
21 - static Cipher AES_GCM_PKCS5;
22 - static byte[] SALT = new byte[] { 116, 104, 101, 32, 109, 111, 111, 110, 32, 105, 115, 32, 104, 105, 100, 100, 101,
23 - 110, 32, 105, 110, 32, 112, 108, 97, 105, 110, 32, 118, 105, 101, 119 };
24 - static SecureRandom RANDOM = new SecureRandom();
25 - /*
26 - * 12 ist NIST recommendation. supposedly fast and secure enough...
27 - */
28 - static int GCM_IV_SIZE = 12;
29 - /*
30 - * AES encrypts 128-blocks internally, so this should be reasonable memory bufer
31 - * size.
32 - */
33 - static int READ_BUFFER_SIZE = 128;
34 - /*
35 - * Supported sizes for GCM authentication tags seem to be {128, 120, 112, 104,
36 - * 96}.
37 - * But we do not really care, since we do not use them here.
38 - */
39 - static int GCM_AUTH_TAG_SIZE = 96;
41 - public static void main(String[] arguments) throws Throwable {
42 - if (arguments.length == 0) {
43 - usage();
44 - throw fail();
45 - }
47 - var input_command = arguments[0];
48 - Command command;
49 - if ("encrypt".startsWith(input_command)) {
50 - command = Command.ENCRYPT;
51 - } else if ("decrypt".startsWith(input_command)) {
52 - command = Command.DECRYPT;
53 - } else {
54 - throw fail("unknown command %s given%n", emphasize_global(input_command));
55 - }
57 - AES_GCM_PKCS5 = Cipher.getInstance("AES/GCM/NoPadding");
59 - var console = System.console();
60 - /*
61 - * If there is no console, this program is most likely part of a pipe.
62 - * In such cases a `--password-file` flag is mandatory, because we cannot
63 - * interactively ask for the password.
64 - */
65 - if (console == null) {
66 - if (arguments.length != 3 || !"--password-file".equals(arguments[1])) {
67 - usage();
68 - throw fail(
69 - "When running %s non-interactively, the %s flag is required.%nOtherwise there is no way to securely obtain the password.%n",
70 - emphasize_local("aes"), emphasize_global("--password-file"));
71 - }
72 - var password_file = Path.of(arguments[2]);
73 - if (!Files.exists(password_file)) {
74 - throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString()));
75 - }
76 - var password = toChars(Files.readAllBytes(password_file));
77 - switch (command) {
78 - case ENCRYPT:
79 - encrypt(password, System.in, System.out);
80 - break;
81 - case DECRYPT:
82 - decrypt(password, System.in, System.out);
83 - break;
84 - }
85 - } else {
86 - if (arguments.length <= 1) {
87 - usage();
88 - throw fail("not enough arguments given%n");
89 - }
90 - char[] password;
91 - String input;
92 - String output;
93 - if ("--password-file".equals(arguments[1])) {
94 - if (arguments.length != 5) {
95 - usage();
96 - throw fail("the flag %s requires a path%n", emphasize_local("--password-file"));
97 - }
98 - var password_file = Path.of(arguments[2]);
99 - if (!Files.exists(password_file)) {
100 - throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString()));
101 - }
102 - password = toChars(Files.readAllBytes(password_file));
103 - input = arguments[3];
104 - output = arguments[4];
105 - } else {
106 - if (arguments.length != 3) {
107 - usage();
108 - throw fail("when encrypting/decrypting a file, an output path is required%n");
109 - }
110 - password = console.readPassword("[%s]:", emphasize_global("Password"));
111 - input = arguments[1];
112 - output = arguments[2];
113 - }
115 - var input_path = Path.of(input);
116 - if (!Files.exists(input_path)) {
117 - throw fail("the given input path %s does not exist%n", emphasize_global(input_path.toString()));
118 - }
119 - var output_path = Path.of(output);
120 - if (Files.exists(output_path)) {
121 - throw fail("the output path %s already exists%n", emphasize_global(output_path.toString()));
122 - }
124 - try (var input_stream = Files.newInputStream(input_path, READ);
125 - var output_stream = Files.newOutputStream(output_path, CREATE_NEW, WRITE);) {
126 - switch (command) {
127 - case ENCRYPT:
128 - encrypt(password, input_stream, output_stream);
129 - break;
130 - case DECRYPT:
131 - decrypt(password, input_stream, output_stream);
132 - break;
133 - }
134 - }
135 - }
136 - throw exit();
137 - }
139 - static void encrypt(char[] password, InputStream input, OutputStream output) throws Exception {
140 - // FIXME: generate random salt and append it here just like IV
141 - // in GCM the IV should be unique per encrypted thingy
142 - var initialization_vector = new byte[GCM_IV_SIZE];
143 - RANDOM.nextBytes(initialization_vector);
144 - // save the IV for the decryption step later. secure? nope. but how else are we
145 - // to share IVs between encryption/decryption?
146 - output.write(initialization_vector);
147 - var secret = toSecretKey(password);
148 - var parameter_spec = new GCMParameterSpec(GCM_AUTH_TAG_SIZE, initialization_vector);
150 - AES_GCM_PKCS5.init(Cipher.ENCRYPT_MODE, secret, parameter_spec);
151 - var read_buffer = new byte[READ_BUFFER_SIZE];
152 - var aes_buffer = new byte[READ_BUFFER_SIZE];
153 - int read_bytes_count = 0;
154 - while ((read_bytes_count = input.read(read_buffer)) != -1) {
155 - var aes_bytes_count = AES_GCM_PKCS5.update(read_buffer, 0, read_bytes_count, aes_buffer);
156 - output.write(aes_buffer, 0, aes_bytes_count);
157 - }
158 - output.write(AES_GCM_PKCS5.doFinal());
159 - }
161 - static void decrypt(char[] password, InputStream input, OutputStream output) throws Exception {
162 - // the IV get prepended to the data during encryption
163 - var initialization_vector = new byte[GCM_IV_SIZE];
164 - input.read(initialization_vector);
165 - var parameter_spec = new GCMParameterSpec(GCM_AUTH_TAG_SIZE, initialization_vector);
166 - var secret = toSecretKey(password);
168 - AES_GCM_PKCS5.init(Cipher.DECRYPT_MODE, secret, parameter_spec);
169 - var read_buffer = new byte[READ_BUFFER_SIZE];
170 - var aes_buffer = new byte[READ_BUFFER_SIZE];
171 - int read_bytes_count = 0;
172 - while ((read_bytes_count = input.read(read_buffer)) != -1) {
173 - var aes_bytes_count = AES_GCM_PKCS5.update(read_buffer, 0, read_bytes_count, aes_buffer);
174 - output.write(aes_buffer, 0, aes_bytes_count);
175 - }
176 - // the java impl of GCM seems to buffer the whole data in memory and only
177 - // releasing it on doFinal. yuck!
178 - // there is not much i can do about this other than to wait for JDK patches.
179 - // TODO: in the case of AES GCM the final byte block is the authentication tag.
180 - // as such it should porbably NOT be written to the output file.
181 - // or is this assumption wrong?
182 - output.write(AES_GCM_PKCS5.doFinal());
183 - // FIXME: when given a wrong password we get a nonsensical error. make this
184 - // nicer for human
185 - }
187 - static SecretKey toSecretKey(char[] password) throws Exception {
188 - var factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
189 - var spec = new PBEKeySpec(password, SALT, 65536, 256);
190 - return new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
191 - }
193 - static char[] toChars(byte[] bytes) {
194 - var byte_buffer = ByteBuffer.wrap(bytes);
195 - var char_buffer = StandardCharsets.UTF_8.decode(byte_buffer);
196 - return char_buffer.array();
197 - }
199 - static void usage() {
200 - out.printf("%s encrypts/decrypts data.%n", emphasize_local("Symmetrically "));
201 - out.printf("%s: java aes.java <e(ncrypt)|d(ecrypt)> [--password-file <path>] <input path> <output path>%n",
202 - emphasize_global("Usage for files"));
203 - out.printf("%s: java aes.java <e(ncrypt)|d(ecrypt)> --password-file <path>%n",
204 - emphasize_global("Usage for stdin/stdout"));
205 - }
207 - static Throwable exit() {
208 - System.exit(0);
209 - // abuse control flow to make compiler realize `exit` will never return
210 - return new Throwable();
211 - }
213 - static String emphasize_global(String message) {
214 - return "\033[4m" + message + "\033[0m";
215 - }
217 - static String emphasize_local(String message) {
218 - return "\033[3m" + message + "\033[0m";
219 - }
221 - static Throwable fail(String message, Object... arguments) {
222 - out.printf(message, arguments);
223 - System.exit(-1);
224 - // abuse control flow to make compiler realize `fail` will never return
225 - return new Throwable();
226 - }
228 - static Throwable fail() {
229 - System.exit(-1);
230 - // abuse control flow to make compiler realize `fail` will never return
231 - return new Throwable();
232 - }
1 +import static java.lang.System.err;
2 +import static java.lang.System.out;
4 +import java.io.ByteArrayOutputStream;
5 +import java.nio.file.Files;
6 +import java.nio.file.Path;
7 +import java.util.Arrays;
8 +import java.util.Base64;
9 +import javax.crypto.Cipher;
10 +import javax.crypto.Mac;
11 +import javax.crypto.spec.GCMParameterSpec;
12 +import javax.crypto.spec.SecretKeySpec;
14 +class aes {
15 + private static final byte[] MAGIC = new byte[] { 'D', 'F', 'A', 'E', 'S', '1' };
16 + private static final int KEY_BYTES = 64;
17 + private static final int AES_KEY_BYTES = 32;
18 + private static final int IV_BYTES = 12;
19 + private static final int GCM_TAG_BITS = 128;
20 + private static final int HEADER_BYTES = MAGIC.length + IV_BYTES;
22 + enum Command {
23 + ENCRYPT, DECRYPT
24 + }
26 + public static void main(String[] arguments) throws Exception {
27 + try {
28 + run(arguments);
29 + } catch (IllegalArgumentException problem) {
30 + err.println(problem.getMessage());
31 + System.exit(2);
32 + } catch (Exception problem) {
33 + err.println(problem.getMessage());
34 + System.exit(1);
35 + }
36 + }
38 + private static void run(String[] arguments) throws Exception {
39 + if (arguments.length != 3 && arguments.length != 5) {
40 + usage();
41 + throw new IllegalArgumentException("wrong argument count");
42 + }
44 + var command = parseCommand(arguments[0]);
45 + if (!"--key-file".equals(arguments[1])) {
46 + usage();
47 + throw new IllegalArgumentException("expected --key-file");
48 + }
50 + var key = readKey(Path.of(arguments[2]));
51 + byte[] input;
52 + if (arguments.length == 3) {
53 + input = System.in.readAllBytes();
54 + } else {
55 + input = Files.readAllBytes(Path.of(arguments[3]));
56 + }
58 + byte[] output;
59 + switch (command) {
60 + case ENCRYPT:
61 + output = encrypt(key, input);
62 + break;
63 + case DECRYPT:
64 + output = decrypt(key, input);
65 + break;
66 + default:
67 + throw new IllegalStateException("unhandled command: " + command);
68 + }
70 + if (arguments.length == 3) {
71 + System.out.write(output);
72 + } else {
73 + var outputPath = Path.of(arguments[4]);
74 + if (Files.exists(outputPath)) {
75 + throw new IllegalArgumentException("output path already exists: " + outputPath);
76 + }
77 + try (var stream = Files.newOutputStream(outputPath)) {
78 + stream.write(output);
79 + }
80 + }
81 + }
83 + static byte[] encrypt(byte[] key, byte[] plaintext) throws Exception {
84 + if (startsWith(plaintext, MAGIC)) {
85 + return plaintext;
86 + }
88 + var split = splitKey(key);
89 + var iv = deterministicIv(split.macKey(), plaintext);
90 + var header = header(iv);
91 + var cipher = Cipher.getInstance("AES/GCM/NoPadding");
92 + cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(split.encryptionKey(), "AES"), new GCMParameterSpec(GCM_TAG_BITS, iv));
93 + cipher.updateAAD(header);
94 + var ciphertext = cipher.doFinal(plaintext);
96 + var output = new ByteArrayOutputStream(header.length + ciphertext.length);
97 + output.write(header);
98 + output.write(ciphertext);
99 + return output.toByteArray();
102 + static byte[] decrypt(byte[] key, byte[] encrypted) throws Exception {
103 + if (!startsWith(encrypted, MAGIC)) {
104 + throw new IllegalArgumentException("input is not a dotfiles AES blob");
106 + if (encrypted.length < HEADER_BYTES + 1) {
107 + throw new IllegalArgumentException("encrypted blob is truncated");
110 + var iv = Arrays.copyOfRange(encrypted, MAGIC.length, HEADER_BYTES);
111 + var header = Arrays.copyOfRange(encrypted, 0, HEADER_BYTES);
112 + var ciphertext = Arrays.copyOfRange(encrypted, HEADER_BYTES, encrypted.length);
113 + var split = splitKey(key);
114 + var cipher = Cipher.getInstance("AES/GCM/NoPadding");
115 + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(split.encryptionKey(), "AES"), new GCMParameterSpec(GCM_TAG_BITS, iv));
116 + cipher.updateAAD(header);
117 + return cipher.doFinal(ciphertext);
120 + static boolean startsWith(byte[] bytes, byte[] prefix) {
121 + if (bytes.length < prefix.length) {
122 + return false;
124 + for (var index = 0; index < prefix.length; index++) {
125 + if (bytes[index] != prefix[index]) {
126 + return false;
129 + return true;
132 + private static Command parseCommand(String input) {
133 + if ("encrypt".startsWith(input)) {
134 + return Command.ENCRYPT;
136 + if ("decrypt".startsWith(input)) {
137 + return Command.DECRYPT;
139 + throw new IllegalArgumentException("unknown command: " + input);
142 + private static byte[] readKey(Path path) throws Exception {
143 + if (!Files.exists(path)) {
144 + throw new IllegalArgumentException("key file does not exist: " + path);
146 + var text = Files.readString(path).trim();
147 + var key = Base64.getDecoder().decode(text);
148 + if (key.length != KEY_BYTES) {
149 + throw new IllegalArgumentException("key file must contain " + KEY_BYTES + " base64-encoded bytes");
151 + return key;
154 + private static SplitKey splitKey(byte[] key) {
155 + return new SplitKey(
156 + Arrays.copyOfRange(key, 0, AES_KEY_BYTES),
157 + Arrays.copyOfRange(key, AES_KEY_BYTES, KEY_BYTES));
160 + private static byte[] deterministicIv(byte[] macKey, byte[] plaintext) throws Exception {
161 + var mac = Mac.getInstance("HmacSHA256");
162 + mac.init(new SecretKeySpec(macKey, "HmacSHA256"));
163 + return Arrays.copyOf(mac.doFinal(plaintext), IV_BYTES);
166 + private static byte[] header(byte[] iv) throws Exception {
167 + var output = new ByteArrayOutputStream(HEADER_BYTES);
168 + output.write(MAGIC);
169 + output.write(iv);
170 + return output.toByteArray();
173 + private static void usage() {
174 + out.println("Symmetrically encrypts/decrypts dotfiles data.");
175 + out.println("Usage for streams: java tools/aes.java <encrypt|decrypt> --key-file <path>");
176 + out.println("Usage for files: java tools/aes.java <encrypt|decrypt> --key-file <path> <input> <output>");
179 + static class SplitKey {
180 + private final byte[] encryptionKey;
181 + private final byte[] macKey;
183 + SplitKey(byte[] encryptionKey, byte[] macKey) {
184 + this.encryptionKey = encryptionKey;
185 + this.macKey = macKey;
188 + byte[] encryptionKey() {
189 + return encryptionKey;
192 + byte[] macKey() {
193 + return macKey;

x230.symlinks

Modified
94 94 psd/psd.conf
95 95 ~/.config/psd/psd.conf
97 -tresor/1078030f-e587-4ed3-bce9-15f6ad113390
97 +ssh/github.key
98 98 ~/.ssh/github.key
100 -tresor/1be0bc56-591a-4630-8ba4-0007506841cf
100 +ssh/box.bugabinga.net.key
101 101 ~/.ssh/box.bugabinga.net.key
103 -tresor/f3c469df-6b5a-4755-897c-9597ca10b0af
103 +ssh/klops.key
104 104 ~/.ssh/klops.key
106 -tresor/f8f81035-cb10-4639-965f-2a1c33a7ce9e
106 +ssh/tini.key
107 107 ~/.ssh/tini.key

zed/settings.json

Added
new file mode 100644

Current version contains binary or non-UTF-8 data.