mirror of
https://github.com/ipxe/ipxe
synced 2025-12-16 01:21:10 +03:00
[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>
This commit is contained in:
@@ -91,8 +91,9 @@ void cipher_encrypt_okx ( struct cipher_test *test, const char *file,
|
|||||||
test->additional_len );
|
test->additional_len );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform encryption */
|
/* Perform in-place encryption */
|
||||||
cipher_encrypt ( cipher, ctx, test->plaintext, ciphertext, len );
|
memcpy ( ciphertext, test->plaintext, len );
|
||||||
|
cipher_encrypt ( cipher, ctx, ciphertext, ciphertext, len );
|
||||||
|
|
||||||
/* Compare against expected ciphertext */
|
/* Compare against expected ciphertext */
|
||||||
okx ( memcmp ( ciphertext, test->ciphertext, len ) == 0, file, line );
|
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 );
|
test->additional_len );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform decryption */
|
/* Perform in-place decryption */
|
||||||
cipher_decrypt ( cipher, ctx, test->ciphertext, plaintext, len );
|
memcpy ( plaintext, test->ciphertext, len );
|
||||||
|
cipher_decrypt ( cipher, ctx, plaintext, plaintext, len );
|
||||||
|
|
||||||
/* Compare against expected plaintext */
|
/* Compare against expected plaintext */
|
||||||
okx ( memcmp ( plaintext, test->plaintext, len ) == 0, file, line );
|
okx ( memcmp ( plaintext, test->plaintext, len ) == 0, file, line );
|
||||||
|
|||||||
Reference in New Issue
Block a user