remove unused EncryptUtil methods, rename
This commit is contained in:
parent
8d4b4b3619
commit
5b2a51a8b5
2 changed files with 4 additions and 30 deletions
|
@ -364,8 +364,8 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startEncryption(SecretKey key) {
|
public void startEncryption(SecretKey key) {
|
||||||
this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptionDecoder(EncryptUtil.createNetCipherInstance(Cipher.DECRYPT_MODE, key)));
|
this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptionDecoder(EncryptUtil.createCipher(Cipher.DECRYPT_MODE, key)));
|
||||||
this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptionEncoder(EncryptUtil.createNetCipherInstance(Cipher.ENCRYPT_MODE, key)));
|
this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptionEncoder(EncryptUtil.createCipher(Cipher.ENCRYPT_MODE, key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class InboundHandlerTuplePacketListener
|
static class InboundHandlerTuplePacketListener
|
||||||
|
|
|
@ -50,32 +50,6 @@ public class EncryptUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getServerIdHash(String id, PublicKey pubkey, SecretKey secret) {
|
|
||||||
try {
|
|
||||||
return digestOperation("SHA-1", new byte[][] {id.getBytes("ISO_8859_1"), secret.getEncoded(), pubkey.getEncoded()});
|
|
||||||
}
|
|
||||||
catch(UnsupportedEncodingException e) {
|
|
||||||
Log.SYSTEM.error(e, "Konnte Server-Prüfwert nicht berechnen");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] digestOperation(String algorithm, byte[]... data) {
|
|
||||||
try {
|
|
||||||
MessageDigest digest = MessageDigest.getInstance(algorithm);
|
|
||||||
|
|
||||||
for(byte[] abyte : data) {
|
|
||||||
digest.update(abyte);
|
|
||||||
}
|
|
||||||
|
|
||||||
return digest.digest();
|
|
||||||
}
|
|
||||||
catch(NoSuchAlgorithmException e) {
|
|
||||||
Log.SYSTEM.error(e, "Konnte Prüfwert nicht berechnen");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PublicKey decodePublicKey(byte[] encoded) {
|
public static PublicKey decodePublicKey(byte[] encoded) {
|
||||||
try {
|
try {
|
||||||
EncodedKeySpec spec = new X509EncodedKeySpec(encoded);
|
EncodedKeySpec spec = new X509EncodedKeySpec(encoded);
|
||||||
|
@ -122,7 +96,7 @@ public class EncryptUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cipher createNetCipherInstance(int mode, Key key) {
|
public static Cipher createCipher(int mode, Key key) {
|
||||||
try {
|
try {
|
||||||
Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding");
|
Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding");
|
||||||
cipher.init(mode, (Key)key, (AlgorithmParameterSpec)(new IvParameterSpec(key.getEncoded())));
|
cipher.init(mode, (Key)key, (AlgorithmParameterSpec)(new IvParameterSpec(key.getEncoded())));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue