summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/tests/basic.c b/tests/basic.c
index 869b3818..6ebc0568 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -2781,7 +2781,7 @@ check_ccm_cipher (void)
static void
-check_ocb_cipher (void)
+do_check_ocb_cipher (int inplace)
{
/* Note that we use hex strings and not binary strings in TV. That
makes it easier to maintain the test vectors. */
@@ -3028,7 +3028,18 @@ check_ocb_cipher (void)
err = gcry_cipher_final (hde);
if (!err)
- err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN, plain, plainlen);
+ {
+ if (inplace)
+ {
+ memcpy(out, plain, plainlen);
+ err = gcry_cipher_encrypt (hde, out, plainlen, NULL, 0);
+ }
+ else
+ {
+ err = gcry_cipher_encrypt (hde, out, MAX_DATA_LEN,
+ plain, plainlen);
+ }
+ }
if (err)
{
fail ("cipher-ocb, gcry_cipher_encrypt failed (tv %d): %s\n",
@@ -3075,7 +3086,19 @@ check_ocb_cipher (void)
/* Now for the decryption. */
err = gcry_cipher_final (hdd);
if (!err)
- err = gcry_cipher_decrypt (hdd, out, plainlen, NULL, 0);
+ {
+ if (inplace)
+ {
+ err = gcry_cipher_decrypt (hdd, out, plainlen, NULL, 0);
+ }
+ else
+ {
+ unsigned char tmp[MAX_DATA_LEN];
+
+ memcpy(tmp, out, plainlen);
+ err = gcry_cipher_decrypt (hdd, out, plainlen, tmp, plainlen);
+ }
+ }
if (err)
{
fail ("cipher-ocb, gcry_cipher_decrypt (tv %d) failed: %s\n",
@@ -3130,6 +3153,18 @@ check_ocb_cipher (void)
static void
+check_ocb_cipher (void)
+{
+ /* Check OCB cipher with separate destination and source buffers for
+ * encryption/decryption. */
+ do_check_ocb_cipher(0);
+
+ /* Check OCB cipher with inplace encrypt/decrypt. */
+ do_check_ocb_cipher(1);
+}
+
+
+static void
check_stream_cipher (void)
{
static const struct tv