package dhellman import ( "crypto/aes" "crypto/cipher" "git.ali33.ru/fcg-xvii/curve/v2/tools" ) func aesEncode(data []byte, p *tools.Point) ([]byte, error) { rData := make([]byte, len(data)) copy(rData, data) block, err := aes.NewCipher(tools.Bytes32(p.X())) if err != nil { return nil, err } iv := tools.Bytes32(p.Y())[:aes.BlockSize] stream := cipher.NewCFBEncrypter(block, iv) stream.XORKeyStream(rData, rData) return rData, nil } func aesDecode(encrypted []byte, p *tools.Point) ([]byte, error) { rData := make([]byte, len(encrypted)) copy(rData, encrypted) block, err := aes.NewCipher(tools.Bytes32(p.X())) if err != nil { return nil, err } iv := tools.Bytes32(p.Y())[:aes.BlockSize] stream := cipher.NewCFBDecrypter(block, iv) stream.XORKeyStream(rData, rData) return rData, nil }