aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2022-11-09 16:50:01 +0000
committerMichael Brown <mcb30@ipxe.org>2022-11-10 09:58:44 +0000
commitf5c829b6f8397c4083bb19b00aa147bd7a628e5e (patch)
tree264cc13f0eacca1e0948979e8a74406a8859b53a /src
parent4acded7e574fb18dd653a18f48a7b6066c543712 (diff)
downloadipxe-f5c829b6f8397c4083bb19b00aa147bd7a628e5e.zip
ipxe-f5c829b6f8397c4083bb19b00aa147bd7a628e5e.tar.gz
ipxe-f5c829b6f8397c4083bb19b00aa147bd7a628e5e.tar.bz2
[tests] Verify ability to perform in-place encryption and decryption
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>
Diffstat (limited to 'src')
-rw-r--r--src/tests/cipher_test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tests/cipher_test.c b/src/tests/cipher_test.c
index 0d0eac1..b7a9827 100644
--- a/src/tests/cipher_test.c
+++ b/src/tests/cipher_test.c
@@ -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 );