]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tests] Verify ability to perform in-place encryption and decryption
authorMichael Brown <mcb30@ipxe.org>
Wed, 9 Nov 2022 16:50:01 +0000 (16:50 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 10 Nov 2022 09:58:44 +0000 (09:58 +0000)
TLS relies upon the ability of ciphers to perform in-place decryption,
in order to avoid allocating additional I/O buffers for received data.

Add verification of in-place encryption and decryption to the cipher
self-tests.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/tests/cipher_test.c

index 0d0eac1d81d2c0f3650af935d4640af5011483db..b7a98275205f3a51f339581258919f82914dd1d1 100644 (file)
@@ -91,8 +91,9 @@ void cipher_encrypt_okx ( struct cipher_test *test, const char *file,
                                 test->additional_len );
        }
 
-       /* Perform encryption */
-       cipher_encrypt ( cipher, ctx, test->plaintext, ciphertext, len );
+       /* Perform in-place encryption */
+       memcpy ( ciphertext, test->plaintext, len );
+       cipher_encrypt ( cipher, ctx, ciphertext, ciphertext, len );
 
        /* Compare against expected ciphertext */
        okx ( memcmp ( ciphertext, test->ciphertext, len ) == 0, file, line );
@@ -149,8 +150,9 @@ void cipher_decrypt_okx ( struct cipher_test *test, const char *file,
                                 test->additional_len );
        }
 
-       /* Perform decryption */
-       cipher_decrypt ( cipher, ctx, test->ciphertext, plaintext, len );
+       /* Perform in-place decryption */
+       memcpy ( plaintext, test->ciphertext, len );
+       cipher_decrypt ( cipher, ctx, plaintext, plaintext, len );
 
        /* Compare against expected plaintext */
        okx ( memcmp ( plaintext, test->plaintext, len ) == 0, file, line );