Documentation ¶
Overview ¶
=====This is a GO API file for parse server-client transport pkg in SGame Framework===== * more info:https://github.com/nmsoccer/sgame ======================================================================================= NET-PKG Tag + Len + Value (1B) (1|2|4B) (...) |<- head ->| |<- data ->|
*Tag: 1Byte **Tag: 0 0 0 0 0 | 0 0 0 high-5bits:option , low-3bits: Bytes of len
*Len: 1 or 2 or 4Byte **len [1,0xFF] :1Byte **len (0xFF , 0xFFFF] :2Byte **len (0xFFFF , 0xFFFFFFFF]: 4Byte
Index ¶
- Constants
- func AesDecrypt(block cipher.Block, cryted []byte, key []byte) ([]byte, error)
- func AesEncrypt(block cipher.Block, orig []byte, key []byte) ([]byte, error)
- func DesDecrypt(block cipher.Block, src []byte, key []byte) ([]byte, error)
- func DesEncrypt(block cipher.Block, src []byte, key []byte) ([]byte, error)
- func GetPkgLen(data_len int) int
- func PackPkg(pkg_buff []byte, pkg_data []byte, pkg_option uint8) int
- func Pkcs5Padding(ciphertext []byte, blockSize int) []byte
- func Pkcs5UnPadding(origData []byte) []byte
- func PkgOption(tag uint8) uint8
- func RsaDecrypt(ciphertext []byte, privateKey []byte) ([]byte, error)
- func RsaDecrypt8(ciphertext []byte, privateKey []byte) ([]byte, error)
- func RsaEncrypt(origData []byte, publicKey []byte) ([]byte, error)
- func UnPackPkg(raw []byte) (uint8, []byte, int)
Constants ¶
const ( ENCRY_DES_KEY_LEN = 8 ENCRY_AES_KEY_LEN = 16 NET_ENCRYPT_NONE int8 = 0 NET_ENCRYPT_DES_ECB int8 = 1 //desc-ecb NET_ENCRYPT_AES_CBC_128 int8 = 2 //aes-cbc-128 NET_ENCRYPT_RSA int8 = 3 //rsa + des or aes )
const ( TAG_LEN = 1 INT_MAX = 0x7FFFFFF0 //pkg option PKG_OP_NORMAL = 0 //normal pkg PKG_OP_ECHO = 1 //echo client <-> tcp-serv PKG_OP_VALID = 2 //valid connection client-->server[validate] server-->client[enc_key if enc enable] PKG_OP_RSA_NEGO = 3 //encrypt by rsa_pub_key to negotiate des key client-->server[encrypted key] server-->client[result] PKG_OP_MAX = 32 //max option value //VALID_KEY CONN_VALID_KEY = "c#s..x*.39&suomeI./().32&show+me_tHe_m0ney$" )
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
AES-CBC key must 16bits if @block != nil use it , or new block
func AesEncrypt ¶
******************AES********************** AES-CBC key must 16bits if @block != nil use it , or new block
func DesDecrypt ¶
if @block != nil use it , or new block
func DesEncrypt ¶
******************DES********************** DES-ECB key must 8bits if @block != nil use it , or new block
func PackPkg ¶
Pack pkg_data to pkg. @pkg_option: ==0 normal pkg. > 0 PKG_OP_XX means special pkg to server @return: -1:failed -2:buff_len not enough >0:success(pkg_len)
func Pkcs5UnPadding ¶
func RsaDecrypt8 ¶
解密 PKCS8(java may use it)
func RsaEncrypt ¶
******************RSA********************** 公钥加密
Types ¶
This section is empty.