mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Add in-place encryption test
This commit is contained in:
@@ -181,6 +181,22 @@ main(void)
|
||||
}
|
||||
printf("OK: Deterministic encryption verified\n");
|
||||
|
||||
printf("\nTest 7: In-place encryption and decryption\n");
|
||||
|
||||
crypto_ipcrypt_encrypt(output, input, key);
|
||||
memcpy(decrypted, input, sizeof input);
|
||||
crypto_ipcrypt_encrypt(decrypted, decrypted, key);
|
||||
if (memcmp(output, decrypted, sizeof output) != 0) {
|
||||
printf("FAILED: In-place encryption differs from out-of-place\n");
|
||||
return 1;
|
||||
}
|
||||
crypto_ipcrypt_decrypt(decrypted, decrypted, key);
|
||||
if (memcmp(input, decrypted, sizeof input) != 0) {
|
||||
printf("FAILED: In-place decryption does not match original\n");
|
||||
return 1;
|
||||
}
|
||||
printf("OK: In-place round-trip successful\n");
|
||||
|
||||
printf("\nAll tests passed!\n");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -46,4 +46,7 @@ Input[3]: 00000000000000000000ffff00000003
|
||||
Test 6: Verify deterministic encryption
|
||||
OK: Deterministic encryption verified
|
||||
|
||||
Test 7: In-place encryption and decryption
|
||||
OK: In-place round-trip successful
|
||||
|
||||
All tests passed!
|
||||
|
||||
Reference in New Issue
Block a user