Originally committed as revision 17875 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -284,14 +284,6 @@ static uint64_t des_encdec(uint64_t in, uint64_t K[16], int decrypt) { · 283 unmodified lines | |||
| 284 | return in; | 284 | return in; |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | #if LIBAVUTIL_VERSION_MAJOR < 50 | ||
| 288 | uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt) { | ||
| 289 | uint64_t K[16]; | ||
| 290 | gen_roundkeys(K, key); | ||
| 291 | return des_encdec(in, K, decrypt); | ||
| 292 | } | ||
| 293 | #endif | ||
| 294 | |||
| 295 | int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { | 287 | int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { |
| 296 | if (key_bits != 64 && key_bits != 192) | 288 | if (key_bits != 64 && key_bits != 192) |
| 297 | return -1; | 289 | return -1; |
| @@ -390,16 +382,16 @@ int main(void) { · 92 unmodified lines | |||
| 390 | uint64_t key[3]; | 382 | uint64_t key[3]; |
| 391 | uint64_t data; | 383 | uint64_t data; |
| 392 | uint64_t ct; | 384 | uint64_t ct; |
| 385 | uint64_t roundkeys[16]; | ||
| 393 | gettimeofday(&tv, NULL); | 386 | gettimeofday(&tv, NULL); |
| 394 | srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec); | 387 | srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec); |
| 395 | #if LIBAVUTIL_VERSION_MAJOR < 50 | ||
| 396 | key[0] = AV_RB64(test_key); | 388 | key[0] = AV_RB64(test_key); |
| 397 | data = AV_RB64(plain); | 389 | data = AV_RB64(plain); |
| 398 | if (ff_des_encdec(data, key[0], 0) != AV_RB64(crypt)) { | 390 | gen_roundkeys(roundkeys, key[0]); |
| 391 | if (des_encdec(data, roundkeys, 0) != AV_RB64(crypt)) { | ||
| 399 | printf("Test 1 failed\n"); | 392 | printf("Test 1 failed\n"); |
| 400 | return 1; | 393 | return 1; |
| 401 | } | 394 | } |
| 402 | #endif | ||
| 403 | av_des_init(&d, test_key, 64, 0); | 395 | av_des_init(&d, test_key, 64, 0); |
| 404 | av_des_crypt(&d, tmp, plain, 1, NULL, 0); | 396 | av_des_crypt(&d, tmp, plain, 1, NULL, 0); |
| 405 | if (memcmp(tmp, crypt, sizeof(crypt))) { | 397 | if (memcmp(tmp, crypt, sizeof(crypt))) { |