123456789101112131415161718192021222324252627282930 |
- package dhellman
- import (
- "crypto/aes"
- "crypto/cipher"
- "git.ali33.ru/fcg-xvii/curve/v2/tools"
- )
- func aesEncode(data []byte, p *tools.Point) ([]byte, error) {
- 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(data, data)
- return data, nil
- }
- func aesDecode(encrypted []byte, p *tools.Point) ([]byte, error) {
- 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(encrypted, encrypted)
- return encrypted, nil
- }
|