Documentation
¶
Overview ¶
Package cbc implements AES-CBC for disk encryption, with an arm64 kernel that decrypts 8 blocks at a time.
CBC decryption is parallel: plaintext block i is D(C[i]) ^ C[i-1], and every C is known before the first block is decrypted. crypto/cipher's CBC decrypter on arm64 decrypts one block at a time through the cipher.Block interface, which leaves the AES units mostly idle; this package runs the AESD rounds of 8 blocks interleaved, with the round keys held in registers, and produces byte-identical output.
Disk formats give every sector its own IV, derived by encrypting the sector's position: BitLocker's eboiv is AES_K(byte offset), LUKS's essiv is AES_{SHA-256(K)}(sector number). DecryptSectors takes one IV per sector, and EncryptECB computes a batch of such IVs 8 blocks at a time.
Encryption is serial by nature (each block needs the previous ciphertext) and goes through crypto/cipher. Architectures other than arm64 use crypto/cipher throughout; the output is the same everywhere.
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 AES key. It is safe for concurrent use.
func (*Cipher) Decrypt ¶
Decrypt decrypts src into dst in CBC mode with iv, as cipher.NewCBCDecrypter(block, iv).CryptBlocks(dst, src) does. dst and src must overlap entirely or not at all; len(src) must be a multiple of 16 and len(iv) 16.
func (*Cipher) DecryptSectors ¶
DecryptSectors decrypts consecutive sectors of sectorSize bytes, sector i with the IV ivs[16*i:16*i+16]: each sector is its own CBC chain, as disk encryption lays them out. sectorSize must be a positive multiple of 16, len(src) a multiple of sectorSize and len(ivs) 16 per sector.
func (*Cipher) Encrypt ¶
Encrypt encrypts src into dst in CBC mode with iv, through crypto/cipher: each block needs the previous ciphertext, so one chain cannot be parallelised.
func (*Cipher) EncryptECB ¶
EncryptECB encrypts each 16-byte block of src into dst independently: the building block of per-sector IVs (eboiv, essiv), 8 blocks at a time on arm64.