Documentation ¶
Overview ¶
EME (ECB-Mix-ECB or, clearer, Encrypt-Mix-Encrypt) is a wide-block encryption mode developed by Halevi and Rogaway.
It was presented in the 2003 paper "A Parallelizable Enciphering Mode" by Halevi and Rogaway.
EME uses multiple invocations of a block cipher to construct a new cipher of bigger block size (in multiples of 16 bytes, up to 2048 bytes).
Index ¶
Constants ¶
const ( // Encrypt "inputData" DirectionEncrypt = directionConst(true) // Decrypt "inputData" DirectionDecrypt = directionConst(false) )
Variables ¶
This section is empty.
Functions ¶
func Transform ¶
Transform - EME-encrypt or EME-decrypt, according to "direction" (defined in the constants DirectionEncrypt and DirectionDecrypt). The data in "inputData" is en- or decrypted with the block ciper "bc" under "tweak" (also known as IV).
The tweak is used to randomize the encryption in the same way as an IV. A use of this encryption mode envisioned by the authors of the algorithm was to encrypt each sector of a disk, with the tweak being the sector number. If you encipher the same data with the same tweak you will get the same ciphertext.
The result is returned in a freshly allocated slice of the same size as inputData.
Limitations: * The block cipher must have block size 16 (usually AES). * The size of "tweak" must be 16 * "inputData" must be a multiple of 16 bytes long If any of these pre-conditions are not met, the function will panic.
Note that you probably don't want to call this function directly and instead use eme.New(), which provides conventient wrappers.
Types ¶
type EMECipher ¶
type EMECipher struct {
// contains filtered or unexported fields
}
EMECipher provides EME-Encryption and -Decryption functions that are more convenient than calling Transform directly.
func New ¶
New returns a new EMECipher object. "bc" must have a block size of 16, or subsequent calls to Encrypt and Decrypt will panic.