github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/gp/crypto.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package gp
     4  
     5  import "../protocol"
     6  
     7  // Encrypt use in encrypted connection from Apps to Apps!
     8  func Encrypt(frames []byte, cipher protocol.Cipher) (payload []byte, err protocol.Error) {
     9  	err = cipher.Encrypt(frames)
    10  	return
    11  }
    12  
    13  // Decrypt use in encrypted connection from Apps to Apps!
    14  func Decrypt(payload []byte, cipher protocol.Cipher) (frames []byte, err protocol.Error) {
    15  	// Decrypt packet by encryptionKey & Checksum data in this protocol :
    16  	// We check packet errors with encryption proccess together
    17  	// and needed checksum data will be add to encrypted data. 32 bit checksum in end of Packet
    18  	err = cipher.Decrypt(payload)
    19  	return
    20  }
    21  
    22  // EncryptRouting usually use in encrypted connection from OS to GP Router!
    23  func EncryptRouting(packet []byte, cipher protocol.Cipher) (err protocol.Error) {
    24  	err = cipher.Encrypt(packet[:32])
    25  	return
    26  }
    27  
    28  // DecryptRouting usually use in encrypted connection from OS to GP Router!
    29  func DecryptRouting(packet []byte, cipher protocol.Cipher) (err protocol.Error) {
    30  	err = cipher.Decrypt(packet[:32])
    31  	return
    32  }
    33  
    34  func checkSignature() {}