server: implement REP_LOGIN key exchange

This commit is contained in:
2023-03-07 01:20:36 -06:00
parent 57e681742e
commit 8f3f31d354
4 changed files with 78 additions and 31 deletions

View File

@@ -1,8 +1,12 @@
package protocol
import (
"encoding/binary"
)
const (
E_KEY = "m@rQn~W#"
KEY_LENGTH = 8
DEFAULT_KEY = "m@rQn~W#"
KEY_LENGTH = 8
)
func encrypt_byte_change_A(ERSize int, data []byte) int {
@@ -43,3 +47,14 @@ func DecryptData(buff, key []byte) {
size := encrypt_byte_change_A(ERSize, buff)
xorData(buff, key, size)
}
func CreateNewKey(uTime uint64, iv1, iv2 uint64) []byte {
num := iv1 + 1
num2 := iv2 + 1
dEKey := uint64(binary.LittleEndian.Uint64([]byte(DEFAULT_KEY)))
key := dEKey * (uTime * num * num2)
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, uint64(key))
return buf
}