repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

new workstation

2ded34fa6bdfd6d020ed11f324d3fffe5a79cf30

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

Changed files (7)

PC-00625.symlinks

Added
new file mode 100644
1 +git/gitconfig
2 +~/.gitconfig
4 +git/gitconfig.PC-00625
5 +~/.gitconfig.include
7 +topgrade/topgrade.windows.toml
8 +~/AppData/Roaming/topgrade.toml
10 +nushell
11 +~/AppData/Roaming/nushell
13 +bottom
14 +~/AppData/Roaming/bottom
16 +stackoverflow/so
17 +~/AppData/Roaming/Sam Tay/so
19 +subversion/config
20 +~/AppData/Roaming/Subversion/config
22 +cargo/config.toml
23 +~/scoop/persist/rustup/.cargo/config.toml
25 +indexa/config.windows.toml
26 +~/AppData/Roaming/indexa/config.toml
28 +wezterm
29 +~/.config/wezterm
31 +helix/config.toml
32 +~/AppData/Roaming/helix/config.toml
34 +helix/themes
35 +~/AppData/Roaming/helix/themes

TODO.md

Modified
7 7 - [ ] write svn completions for nushell
8 8 - [ ] interactive zoxide jump function with skim
9 9 - [x] port nushell config to new config script
10 +- [ ] remove win32 from target platforms of bootstripper

bootstripper.java

Modified
89 89 command.add(target_path.toString());
90 90 command.add(source_path.toString());
91 + log(command.toString());
91 92 process.inheritIO()
92 93 .start()
93 94 .onExit()

git/gitconfig

Modified
59 59 # On each host a different file might be symlinked into '.gitconfig.include'.
60 60 [include]
61 61 path = .gitconfig.include
62 63 [credential "helperselector"]
63 64 selected = manager-core

git/gitconfig.PC-00625

Added
new file mode 100644
1 +[user]
2 + name = Oliver Krylow
3 + email = o.krylow@isp-insoft.de
5 +[credential]
6 + helper = manager-core

tools/aes.java

Modified
1 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;
3 6 import java.nio.file.*;
4 7 import java.nio.charset.*;
5 8 import java.nio.*;
6 9 import java.io.*;
7 -import java.util.*;
9 11 import java.security.*;
10 -import java.security.spec.*;
12 13 import javax.crypto.*;
13 14 import javax.crypto.spec.*;
15 16 class aes {
16 - enum Command { ENCRYPT, DECRYPT };
17 + enum Command {
18 + ENCRYPT, DECRYPT
19 + }
17 21 static Cipher AES_GCM_PKCS5;
18 - static byte[] SALT = new byte[] { 116, 104, 101, 32, 109, 111, 111, 110, 32, 105, 115, 32, 104, 105, 100, 100, 101, 110, 32, 105, 110, 32, 112, 108, 97, 105, 110, 32, 118, 105, 101, 119 };
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 };
19 24 static SecureRandom RANDOM = new SecureRandom();
21 26 * 12 ist NIST recommendation. supposedly fast and secure enough...
23 28 static int GCM_IV_SIZE = 12;
25 - * AES encrypts 128-blocks internally, so this should be reasonable memory bufer size.
30 + * AES encrypts 128-blocks internally, so this should be reasonable memory bufer
31 + * size.
27 33 static int READ_BUFFER_SIZE = 128;
29 - * Supported sizes for GCM authentication tags seem to be {128, 120, 112, 104, 96}.
30 - * But we do not really care, since we do not use them here.
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.
32 39 static int GCM_AUTH_TAG_SIZE = 96;
34 41 public static void main(String[] arguments) throws Throwable {
35 - if(arguments.length == 0){
42 + if (arguments.length == 0) {
36 43 usage();
37 44 throw fail();
40 47 var input_command = arguments[0];
41 48 Command command;
42 - if ("encrypt".startsWith(input_command)) { command = Command.ENCRYPT; }
43 - else if ("decrypt".startsWith(input_command)) { command = Command.DECRYPT; }
44 - else { throw fail("unknown command %s given%n", emphasize_global(input_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 + }
46 57 AES_GCM_PKCS5 = Cipher.getInstance("AES/GCM/NoPadding");
48 59 var console = System.console();
50 61 * If there is no console, this program is most likely part of a pipe.
51 - * In such cases a `--password-file` flag is mandatory, because we cannot interactively ask for the password.
62 + * In such cases a `--password-file` flag is mandatory, because we cannot
63 + * interactively ask for the password.
53 - if(console == null){
54 - if(arguments.length != 3 || !"--password-file".equals(arguments[1])) {
65 + if (console == null) {
66 + if (arguments.length != 3 || !"--password-file".equals(arguments[1])) {
55 67 usage();
56 - throw fail("When running %s non-interactively, the %s flag is required.%nOtherwise there is no way to securely obtain the password.%n",emphasize_local("aes"), emphasize_global("--password-file"));
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"));
58 72 var password_file = Path.of(arguments[2]);
59 - if(!Files.exists(password_file)) { throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString())); }
73 + if (!Files.exists(password_file)) {
74 + throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString()));
75 + }
60 76 var password = toChars(Files.readAllBytes(password_file));
61 77 switch (command) {
62 78 case ENCRYPT:
63 79 encrypt(password, System.in, System.out);
64 - break;
80 + break;
65 81 case DECRYPT:
66 82 decrypt(password, System.in, System.out);
67 - break;
83 + break;
69 - }
70 - else {
71 - if(arguments.length <= 1) {
85 + } else {
86 + if (arguments.length <= 1) {
72 87 usage();
73 88 throw fail("not enough arguments given%n");
75 90 char[] password;
76 91 String input;
77 92 String output;
78 - if("--password-file".equals(arguments[1])) {
79 - if(arguments.length != 5) {
93 + if ("--password-file".equals(arguments[1])) {
94 + if (arguments.length != 5) {
80 95 usage();
81 96 throw fail("the flag %s requires a path%n", emphasize_local("--password-file"));
83 98 var password_file = Path.of(arguments[2]);
84 - if(!Files.exists(password_file)) { throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString())); }
99 + if (!Files.exists(password_file)) {
100 + throw fail("the given password file %s does not exist%n", emphasize_local(password_file.toString()));
85 102 password = toChars(Files.readAllBytes(password_file));
86 103 input = arguments[3];
87 104 output = arguments[4];
88 - }
89 - else {
90 - if(arguments.length != 3) {
105 + } else {
106 + if (arguments.length != 3) {
91 107 usage();
92 108 throw fail("when encrypting/decrypting a file, an output path is required%n");
94 - password = console.readPassword("[%s]:",emphasize_global("Password"));
110 + password = console.readPassword("[%s]:", emphasize_global("Password"));
95 111 input = arguments[1];
96 112 output = arguments[2];
99 115 var input_path = Path.of(input);
100 - if(!Files.exists(input_path)) { throw fail("the given input path %s does not exist%n", emphasize_global(input_path.toString())); }
116 + if (!Files.exists(input_path)) {
117 + throw fail("the given input path %s does not exist%n", emphasize_global(input_path.toString()));
101 119 var output_path = Path.of(output);
102 - if(Files.exists(output_path)) { throw fail("the output path %s already exists%n", emphasize_global(output_path.toString())); }
120 + if (Files.exists(output_path)) {
121 + throw fail("the output path %s already exists%n", emphasize_global(output_path.toString()));
104 - var input_stream = Files.newInputStream(input_path, StandardOpenOption.READ);
105 - var output_stream = Files.newOutputStream(output_path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
107 - switch (command) {
108 - case ENCRYPT:
109 - encrypt(password, input_stream, output_stream);
110 - break;
111 - case DECRYPT:
112 - decrypt(password, input_stream, output_stream);
113 - break;
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;
116 136 throw exit();
121 141 // in GCM the IV should be unique per encrypted thingy
122 142 var initialization_vector = new byte[GCM_IV_SIZE];
123 143 RANDOM.nextBytes(initialization_vector);
124 - //save the IV for the decryption step later. secure? nope. but how else are we to share IVs between encryption/decryption?
144 + // save the IV for the decryption step later. secure? nope. but how else are we
145 + // to share IVs between encryption/decryption?
125 146 output.write(initialization_vector);
126 147 var secret = toSecretKey(password);
127 148 var parameter_spec = new GCMParameterSpec(GCM_AUTH_TAG_SIZE, initialization_vector);
130 151 var read_buffer = new byte[READ_BUFFER_SIZE];
131 152 var aes_buffer = new byte[READ_BUFFER_SIZE];
132 153 int read_bytes_count = 0;
133 - while((read_bytes_count = input.read(read_buffer)) != -1){
134 - var aes_bytes_count = AES_GCM_PKCS5.update(read_buffer, 0, read_bytes_count, aes_buffer);
135 - output.write(aes_buffer, 0, aes_bytes_count);
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);
137 158 output.write(AES_GCM_PKCS5.doFinal());
140 161 static void decrypt(char[] password, InputStream input, OutputStream output) throws Exception {
141 - //the IV get prepended to the data during encryption
162 + // the IV get prepended to the data during encryption
142 163 var initialization_vector = new byte[GCM_IV_SIZE];
143 164 input.read(initialization_vector);
144 165 var parameter_spec = new GCMParameterSpec(GCM_AUTH_TAG_SIZE, initialization_vector);
148 169 var read_buffer = new byte[READ_BUFFER_SIZE];
149 170 var aes_buffer = new byte[READ_BUFFER_SIZE];
150 171 int read_bytes_count = 0;
151 - while((read_bytes_count = input.read(read_buffer)) != -1){
152 - var aes_bytes_count = AES_GCM_PKCS5.update(read_buffer, 0, read_bytes_count, aes_buffer);
153 - output.write(aes_buffer, 0, aes_bytes_count);
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);
155 - // the java impl of GCM seems to buffer the whole data in memory and only releasing it on doFinal. yuck!
176 + // the java impl of GCM seems to buffer the whole data in memory and only
177 + // releasing it on doFinal. yuck!
156 178 // there is not much i can do about this other than to wait for JDK patches.
157 - //TODO: in the case of AES GCM the final byte block is the authentication tag.
158 - //as such it should porbably NOT be written to the output file.
159 - //or is this assumption wrong?
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?
160 182 output.write(AES_GCM_PKCS5.doFinal());
161 - //FIXME: when given a wrong password we get a nonsensical error. make this nicer for human
183 + // FIXME: when given a wrong password we get a nonsensical error. make this
184 + // nicer for human
164 187 static SecretKey toSecretKey(char[] password) throws Exception {
165 188 var factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
166 189 var spec = new PBEKeySpec(password, SALT, 65536, 256);
167 - return new SecretKeySpec(factory.generateSecret(spec).getEncoded() , "AES");
190 + return new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
170 193 static char[] toChars(byte[] bytes) {
176 199 static void usage() {
177 200 out.printf("%s encrypts/decrypts data.%n", emphasize_local("Symmetrically "));
178 - out.printf("%s: java aes.java <e(ncrypt)|d(ecrypt)> [--password-file <path>] <input path> <output path>%n", emphasize_global("Usage for files"));
179 - out.printf("%s: java aes.java <e(ncrypt)|d(ecrypt)> --password-file <path>%n", emphasize_global("Usage for stdin/stdout"));
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"));
182 207 static Throwable exit() {
183 208 out.printf("%s!%n", emphasize_local("Done"));
184 209 System.exit(0);
185 - //abuse control flow to make compiler realize `exit` will never return
186 - return new Throwable();
210 + // abuse control flow to make compiler realize `exit` will never return
211 + return new Throwable();
189 214 static String emphasize_global(String message) {
197 222 static Throwable fail(String message, Object... arguments) {
198 223 out.printf(message, arguments);
199 224 System.exit(-1);
200 - //abuse control flow to make compiler realize `exit` will never return
201 - return new Throwable();
225 + // abuse control flow to make compiler realize `fail` will never return
226 + return new Throwable();
204 229 static Throwable fail() {
205 230 System.exit(-1);
206 - //abuse control flow to make compiler realize `exit` will never return
207 - return new Throwable();
231 + // abuse control flow to make compiler realize `fail` will never return
232 + return new Throwable();

topgrade/topgrade.windows.toml

Modified
26 26 # Arguments to pass Git when pulling Repositories
27 27 arguments = "--ff --rebase --autostash"
29 +[windows]
30 +enable_winget = true
29 32 # Commands to run before anything
30 33 #[pre_commands]
31 34 #"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
33 36 # Custom commands
34 37 [commands]
35 -"Refresh dotfiles" = "java W:/misc/dotfiles/bootstripper.java W:/misc/dotfiles"
38 +"Refresh dotfiles" = "java W:/dotfiles/bootstripper.java W:/dotfiles"
37 40 # Leider scheint der eingebaute "tldr" step von topgrade nicht für meine Version von TLDR funktionieren
38 41 "TLDR" = "tldr --update"
40 43 # Diese Skripte beziehen APM und MeMate aus dem Transfer.
41 -"Advantage-PM Client" = ". D:/Tools/update_apm_client.ps1"
42 -"MeMate" = ". D:/Tools/update_memate.ps1"
44 +"Advantage-PM Client" = ". C:/Users/okr/Tools/update_apm_client.ps1"
45 +"MeMate" = ". C:/USers/okr/Tools/update_memate.ps1"
44 47 # Dateisystem-Indexer ix erfrischen
45 48 "Indexa Update" = "ix --update"