Documentation ¶
Overview ¶
Package des-avx implements the Data Encryption Standard (DES) as described in chapter 7.4 of Handbook of Applied Cryptography, 1997. DES proceeds in 16 rounds, processing 64-bit plaintext blocks into 64-bit ciphertext blocks using a 56-bit key. This implementation utilises x86 AVX extensions to work on multiple blocks of plaintext simultaneously.
Example ¶
// The length of plaintext must be a multiple of 8 plaintext := []byte("exampleplaintext") ciphertext := make([]byte, len(plaintext)) // DES keys must be 8 bytes key, _ := hex.DecodeString("deadbeefdeadc0de") des.NewDESECBEncrypter(key).CryptBlocks(ciphertext, plaintext) // Encrypt des.NewDESECBDecrypter(key).CryptBlocks(ciphertext, ciphertext) // Decrypt // DES3 keys must be 24 bytes key, _ = hex.DecodeString("deadbeefdeadc0defeedbabef00dbabebaadf00dbaaaaaad") des.NewDES3ECBEncrypter(key).CryptBlocks(ciphertext, ciphertext) // Encrypt des.NewDES3ECBDecrypter(key).CryptBlocks(ciphertext, ciphertext) // Decrypt fmt.Println(string(ciphertext))
Output: exampleplaintext
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewDES3ECBDecrypter ¶
NewDES3ECBDecrypter returns a cipher.BlockMode which decrypts messages using DES3 in electronic coodebook mode. The key should be 24 bytes long, its its effective size however, is only 168 bits as the least significant bit from each byte is ignored.
func NewDES3ECBEncrypter ¶
NewDES3ECBEncrypter returns a cipher.BlockMode which encrypts messages using DES3 in electronic coodebook mode. The key should be 24 bytes long, its effective size however, is only 168 bits as the least significant bit from each byte is ignored.
func NewDESECBDecrypter ¶
NewDESECBDecrypter returns a cipher.BlockMode which decrypts messages using DES in electronic coodebook mode. The key should be 8 bytes long, however, its effective size is only 56 bits as the least significant bit from each byte is ignored.
func NewDESECBEncrypter ¶
NewDESECBEncrypter returns a cipher.BlockMode which encrypts messages using DES in electronic coodebook mode. The key should be 8 bytes long, its effective size however, is only 56 bits as the least significant bit from each byte is ignored.
Types ¶
This section is empty.