You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
xtea: Test inplace decryption
Based on test code by: Giorgio Vazzana <mywing81@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
committed by
Martin Storsjö
parent
b434500431
commit
f0fce9f33e
@@ -160,14 +160,28 @@ static void test_xtea(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
AVXTEA ctx;
|
AVXTEA ctx;
|
||||||
uint8_t buf[8];
|
uint8_t buf[8], iv[8];
|
||||||
int i;
|
int i;
|
||||||
|
const uint8_t src[32] = "HelloWorldHelloWorldHelloWorld";
|
||||||
|
uint8_t ct[32];
|
||||||
|
uint8_t pl[32];
|
||||||
|
|
||||||
for (i = 0; i < XTEA_NUM_TESTS; i++) {
|
for (i = 0; i < XTEA_NUM_TESTS; i++) {
|
||||||
av_xtea_init(&ctx, xtea_test_key[i]);
|
av_xtea_init(&ctx, xtea_test_key[i]);
|
||||||
|
|
||||||
test_xtea(&ctx, buf, xtea_test_pt[i], xtea_test_ct[i], 1, NULL, 0, "encryption");
|
test_xtea(&ctx, buf, xtea_test_pt[i], xtea_test_ct[i], 1, NULL, 0, "encryption");
|
||||||
test_xtea(&ctx, buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "decryption");
|
test_xtea(&ctx, buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "decryption");
|
||||||
|
|
||||||
|
/* encrypt */
|
||||||
|
memcpy(iv, "HALLO123", 8);
|
||||||
|
av_xtea_crypt(&ctx, ct, src, 4, iv, 0);
|
||||||
|
|
||||||
|
/* decrypt into pl */
|
||||||
|
memcpy(iv, "HALLO123", 8);
|
||||||
|
test_xtea(&ctx, pl, ct, src, 4, iv, 1, "CBC decryption");
|
||||||
|
|
||||||
|
memcpy(iv, "HALLO123", 8);
|
||||||
|
test_xtea(&ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption");
|
||||||
}
|
}
|
||||||
printf("Test encryption/decryption success.\n");
|
printf("Test encryption/decryption success.\n");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user