fix exceptions from net handlers, raise rsa key size to 4096

This commit is contained in:
Sen 2025-05-30 19:39:54 +02:00
parent d1a0847303
commit 1b61f085e3
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
4 changed files with 12 additions and 12 deletions

View file

@ -44,7 +44,7 @@ public class EncryptUtil {
public static KeyPair createKeypair() {
try {
KeyPairGenerator pairgen = KeyPairGenerator.getInstance("RSA");
pairgen.initialize(2048);
pairgen.initialize(4096);
return pairgen.generateKeyPair();
}
catch(NoSuchAlgorithmException e) {
@ -142,7 +142,7 @@ public class EncryptUtil {
}
public static String getArmoredPubkey(PublicKey pubkey, String cn) {
StringBuilder sb = new StringBuilder("tcr-rsa-2048 ");
StringBuilder sb = new StringBuilder("tcr-rsa-4096 ");
sb.append(Base64.getEncoder().encodeToString(pubkey.getEncoded()));
sb.append(' ').append(Base64.getEncoder().encodeToString(crc24(pubkey.getEncoded())));
return cn == null || cn.isEmpty() ? sb.toString() : sb.append(' ').append(Util.sanitizeCommonName(cn)).toString();
@ -152,8 +152,8 @@ public class EncryptUtil {
String[] tok = armor.trim().split(" ");
if(tok.length != 3 && tok.length != 4)
throw new IllegalArgumentException("Key muss aus 3 oder 4 Segmenten bestehen");
if(!tok[0].equals("tcr-rsa-2048"))
throw new IllegalArgumentException("Algorithmus '" + tok[0] + "' ist nicht unterstützt, es wird derzeit nur tcr-rsa-2048 verwendet");
if(!tok[0].equals("tcr-rsa-4096"))
throw new IllegalArgumentException("Algorithmus '" + tok[0] + "' ist nicht unterstützt, es wird derzeit nur tcr-rsa-4096 verwendet");
byte[] key;
try {
key = Base64.getDecoder().decode(tok[1]);

View file

@ -490,6 +490,6 @@ int utf_len(const char *str) {
}
public static void throwUnchecked(Throwable t) {
throw (RuntimeException)t;
throw t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(t);
}
}