package xtea
import "golang.org/x/crypto/xtea"
Package xtea implements XTEA encryption, as defined in Needham and Wheeler's 1997 technical report, "Tea extensions."
XTEA is a legacy cipher and its short block size makes it vulnerable to birthday bound attacks (see https://sweet32.info). It should only be used where compatibility with legacy systems, not security, is the goal.
Deprecated: any new system should use AES (from crypto/aes, if necessary in an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from golang.org/x/crypto/chacha20poly1305).
Index ¶
- Constants
- type Cipher
- func NewCipher(key []byte) (*Cipher, error)
- func (c *Cipher) BlockSize() int
- func (c *Cipher) Decrypt(dst, src []byte)
- func (c *Cipher) Encrypt(dst, src []byte)
- type KeySizeError
Constants ¶
const BlockSize = 8
The XTEA block size in bytes.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
A Cipher is an instance of an XTEA cipher using a particular key.
func NewCipher ¶
NewCipher creates and returns a new Cipher. The key argument should be the XTEA key. XTEA only supports 128 bit (16 byte) keys.
func (*Cipher) BlockSize ¶
BlockSize returns the XTEA block size, 8 bytes. It is necessary to satisfy the Block interface in the package "crypto/cipher".
func (*Cipher) Decrypt ¶
Decrypt decrypts the 8 byte buffer src using the key and stores the result in dst.
func (*Cipher) Encrypt ¶
Encrypt encrypts the 8 byte buffer src using the key and stores the result in dst. Note that for amounts of data larger than a block, it is not safe to just call Encrypt on successive blocks; instead, use an encryption mode like CBC (see crypto/cipher/cbc.go).
type KeySizeError ¶
type KeySizeError int
func (KeySizeError) Error ¶
func (k KeySizeError) Error() string
Source Files ¶
block.go cipher.go
- Version
- v0.34.0 (latest)
- Published
- Feb 22, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 9 hours ago –
Tools for package owners.