diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-05-11 19:10:10 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-05-11 19:13:03 +0100 |
commit | 96d616052b3d39678e477fa10610ca688f46fff9 (patch) | |
tree | 8bd31d06318bc786ea8f1d84f92090c9c860bc11 /libavutil/twofish.c | |
parent | 27506aceda8115f82f89691a4441d62a8cf24a6e (diff) | |
parent | d12b5b2f135aade4099f4b26b0fe678656158c13 (diff) | |
download | ffmpeg-96d616052b3d39678e477fa10610ca688f46fff9.tar.gz |
Merge commit 'd12b5b2f135aade4099f4b26b0fe678656158c13'
* commit 'd12b5b2f135aade4099f4b26b0fe678656158c13':
build: Split test programs off into separate files
Some conversions done by: James Almer <jamrial@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavutil/twofish.c')
-rw-r--r-- | libavutil/twofish.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/libavutil/twofish.c b/libavutil/twofish.c index 162069be5c..d84fa4f363 100644 --- a/libavutil/twofish.c +++ b/libavutil/twofish.c @@ -329,77 +329,3 @@ void av_twofish_crypt(AVTWOFISH *cs, uint8_t *dst, const uint8_t *src, int count dst = dst + 16; } } - -#ifdef TEST -#include<stdio.h> -#include<stdlib.h> -#include"log.h" - -int main(int argc, char *argv[]) -{ - uint8_t Key[32] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff - }; - const uint8_t rct[6][16] = { - {0x9f, 0x58, 0x9f, 0x5c, 0xf6, 0x12, 0x2c, 0x32, 0xb6, 0xbf, 0xec, 0x2f, 0x2a, 0xe8, 0xc3, 0x5a}, - {0xcf, 0xd1, 0xd2, 0xe5, 0xa9, 0xbe, 0x9c, 0xdf, 0x50, 0x1f, 0x13, 0xb8, 0x92, 0xbd, 0x22, 0x48}, - {0x37, 0x52, 0x7b, 0xe0, 0x05, 0x23, 0x34, 0xb8, 0x9f, 0x0c, 0xfc, 0xca, 0xe8, 0x7c, 0xfa, 0x20}, - {0x5d, 0x9d, 0x4e, 0xef, 0xfa, 0x91, 0x51, 0x57, 0x55, 0x24, 0xf1, 0x15, 0x81, 0x5a, 0x12, 0xe0}, - {0xe7, 0x54, 0x49, 0x21, 0x2b, 0xee, 0xf9, 0xf4, 0xa3, 0x90, 0xbd, 0x86, 0x0a, 0x64, 0x09, 0x41}, - {0x37, 0xfe, 0x26, 0xff, 0x1c, 0xf6, 0x61, 0x75, 0xf5, 0xdd, 0xf4, 0xc3, 0x3b, 0x97, 0xa2, 0x05} - }; - uint8_t temp[32], iv[16], rpt[32] = {0}; - const int kbits[3] = {128, 192, 256}; - int i, j, err = 0; - AVTWOFISH *cs; - cs = av_twofish_alloc(); - if (!cs) - return 1; - for (j = 1; j < 3; j++) { - av_twofish_init(cs, Key, kbits[j]); - av_twofish_crypt(cs, temp, rpt, 1, NULL, 0); - for (i = 0; i < 16; i++) { - if (rct[j][i] != temp[i]) { - av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[j][i], temp[i]); - err = 1; - } - } - av_twofish_crypt(cs, temp, rct[j], 1, NULL, 1); - for (i = 0; i < 16; i++) { - if (rpt[i] != temp[i]) { - av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]); - err = 1; - } - } - } - for (j = 0; j < 3; j++) { - memset(Key, 0, sizeof(Key)); - memset(rpt, 0, sizeof(rpt)); - for (i = 1; i < 50; i++) { - av_twofish_init(cs, Key, kbits[j]); - av_twofish_crypt(cs, temp, rpt, 1, NULL, 0); - memcpy(Key+16,Key,(kbits[j]-128) >> 3); - memcpy(Key,rpt,16); - memcpy(rpt,temp,16); - } - for (i = 0; i < 16; i++) { - if (rct[3 + j][i] != temp[i]) { - av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rct[3 + j][i], temp[i]); - err = 1; - } - } - } - memset(rpt, 0, sizeof(rpt)); - memcpy(iv, "HALLO123HALLO123", 16); - av_twofish_crypt(cs, temp, rpt, 2, iv, 0); - memcpy(iv, "HALLO123HALLO123", 16); - av_twofish_crypt(cs, temp, temp, 2, iv, 1); - for (i = 0; i < 32; i++) { - if (rpt[i] != temp[i]) { - av_log(NULL, AV_LOG_ERROR, "%d %02x %02x\n", i, rpt[i], temp[i]); - err = 1; - } - } - av_free(cs); - return err; -} -#endif |