Class WorldPacketCrypt
java.lang.Object
br.net.dd.netherwingcore.common.cryptography.authentication.WorldPacketCrypt
The
WorldPacketCrypt class is responsible for encrypting and decrypting
network packets with an implementation based on AES encryption. This class manages
both packet decryption for incoming data and encryption for outgoing data.
It also handles initialization vectors (IVs) and counters for the encryption
and decryption processes to ensure data integrity and security.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents a cryptographic key used for initialization of the encryption and decryption algorithms.static classRepresents the Initialization Vector (IV) used in encryption and decryption processes. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newWorldPacketCryptinstance with default AES configurations. -
Method Summary
Modifier and TypeMethodDescriptionbooleandecryptRecv(byte[] data, int length, AES.Tag tag) Decrypts the received data using the current client counter and verification tag.booleanencryptSend(byte[] data, int length, AES.Tag tag) Encrypts the given data using the current server counter and verification tag.voidinit(WorldPacketCrypt.Key key) Initializes the cryptographic system with the given cryptographic key.booleanChecks whether the cryptographic system has been initialized.booleanpeekDecryptRecv(byte[] data, int length) Performs a non-destructive decryption on the given data to verify its integrity, without modifying the input data's integrity.
-
Constructor Details
-
WorldPacketCrypt
-
-
Method Details
-
init
Initializes the cryptographic system with the given cryptographic key.- Parameters:
key- The cryptographic key used for both encryption and decryption.
-
peekDecryptRecv
public boolean peekDecryptRecv(byte[] data, int length) Performs a non-destructive decryption on the given data to verify its integrity, without modifying the input data's integrity.- Parameters:
data- The data to be decrypted.length- The length of the data to be decrypted.- Returns:
trueif the data can be successfully decrypted;falseotherwise.
-
decryptRecv
Decrypts the received data using the current client counter and verification tag.- Parameters:
data- The data to be decrypted.length- The length of the data to be decrypted.tag- The cryptographic tag used for integrity verification.- Returns:
trueif decryption is successful;falseotherwise.
-
encryptSend
Encrypts the given data using the current server counter and verification tag.- Parameters:
data- The data to be encrypted.length- The length of the data to be encrypted.tag- The cryptographic tag used for integrity verification.- Returns:
trueif encryption is successful;falseotherwise.
-
isInitialized
public boolean isInitialized()Checks whether the cryptographic system has been initialized.- Returns:
trueif the cryptographic system is initialized;falseotherwise.
-