if the decryption fails
Test encrypting and decrypting a short value.
auto key = generateKey(); auto crypt = new typeof(this)(key); auto original = generateMessage(); mstring buf; buf ~= original; // Encrypt buf in place crypt.encrypt(buf); test!("!=")(buf, original); // Decrypt buf in place crypt.decrypt(buf); test!("==")(buf, original);
Test that encrypting a value after setting an IV gives the same result as not setting an IV. For these algorithms, the IV should not be used.
auto key = generateKey(); auto crypt = new typeof(this)(key); auto original = generateMessage(); mstring buf; buf ~= original; // Encrypt buf in place crypt.encrypt(buf); // Generate and set an IV auto iv = generateMessage(); gcry_cipher_setiv(crypt.handle, iv.ptr, iv.length); // Encrypt another buf in place and test that is the same as before mstring buf2; buf2 ~= original; crypt.encrypt(buf2); test!("==")(buf, buf2);
Decrypt the content of buffer in place.