Documentation
¶
Overview ¶
Package xts implements the XTS-AES tweakable block-cipher mode (IEEE P1619/D16, NIST SP 800-38E) used for full-disk encryption.
It is a drop-in replacement for golang.org/x/crypto/xts: the Cipher type exposes the same NewCipher / Encrypt / Decrypt API and produces byte-identical ciphertext. The difference is performance. x/crypto/xts drives the underlying block cipher one 16-byte block at a time through the cipher.Block interface and advances the XTS tweak with a scalar GF(2^128) multiply per block; on a CPU with hardware AES this collapses a ~10 GB/s AES engine to ~600 MB/s because the per-block interface dispatch defeats the pipelined multi-block AES path.
This package instead ships a fused AES-XTS kernel that pipelines four AES blocks at a time and folds the tweak XOR into the round pipeline. On arm64 (ARMv8 AES + NEON) and amd64 (AES-NI) the kernel runs the AESE/AESMC (resp. AESENC) pipeline directly, reaching multi-GB/s per core. On the remaining architectures (riscv64, loong64, ppc64le, s390x) it transparently falls back to the same per-block algorithm as x/crypto/xts, so behaviour is identical everywhere; only the speed differs.
XTS provides confidentiality but no authentication, and does not implement ciphertext stealing, so each sector must be a multiple of 16 bytes. It is intended for disk-sector encryption only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
Cipher is an expanded XTS key. It is safe for concurrent use.
func NewCipher ¶
NewCipher creates a Cipher from a function that builds the underlying block cipher (which must have a 16-byte block size) and a key that is twice the underlying cipher's key length. For AES this is a 32-byte key (AES-128-XTS) or a 64-byte key (AES-256-XTS).
func (*Cipher) Decrypt ¶
Decrypt decrypts a sector of ciphertext into plaintext using the given sector number as the XTS tweak. The same overlap and length rules as Encrypt apply.
