X-Git-Url: https://git.piment-noir.org/?p=deb_ffmpeg.git;a=blobdiff_plain;f=ffmpeg%2Ftools%2Fcrypto_bench.c;fp=ffmpeg%2Ftools%2Fcrypto_bench.c;h=6037ead1e7c43a898f9c92dd77541ffc7ac8784d;hp=0f6206890590e7520bbfd3a109251a4ad0179b5d;hb=f6fa7814ccfe3e76514b36cf04f5cd3cb657c8cf;hpb=2ba45a602cbfa7b771effba9b11bb4245c21bc00 diff --git a/ffmpeg/tools/crypto_bench.c b/ffmpeg/tools/crypto_bench.c index 0f62068..6037ead 100644 --- a/ffmpeg/tools/crypto_bench.c +++ b/ffmpeg/tools/crypto_bench.c @@ -75,6 +75,7 @@ struct hash_impl { #include "libavutil/sha512.h" #include "libavutil/ripemd.h" #include "libavutil/aes.h" +#include "libavutil/cast5.h" #define IMPL_USE_lavu IMPL_USE @@ -111,6 +112,16 @@ static void run_lavu_aes128(uint8_t *output, av_aes_crypt(aes, output, input, size >> 4, NULL, 0); } +static void run_lavu_cast128(uint8_t *output, + const uint8_t *input, unsigned size) +{ + static struct AVCAST5 *cast; + if (!cast && !(cast = av_cast5_alloc())) + fatal_error("out of memory"); + av_cast5_init(cast, hardcoded_key, 128); + av_cast5_crypt(cast, output, input, size >> 3, 0); +} + /*************************************************************************** * crypto: OpenSSL's libcrypto ***************************************************************************/ @@ -121,6 +132,7 @@ static void run_lavu_aes128(uint8_t *output, #include #include #include +#include #define DEFINE_CRYPTO_WRAPPER(suffix, function) \ static void run_crypto_ ## suffix(uint8_t *output, \ @@ -147,6 +159,17 @@ static void run_crypto_aes128(uint8_t *output, AES_encrypt(input + i, output + i, &aes); } +static void run_crypto_cast128(uint8_t *output, + const uint8_t *input, unsigned size) +{ + CAST_KEY cast; + unsigned i; + + CAST_set_key(&cast, 16, hardcoded_key); + for (i = 0; i < size; i += 8) + CAST_ecb_encrypt(input + i, output + i, &cast, 1); +} + #define IMPL_USE_crypto(...) IMPL_USE(__VA_ARGS__) #else #define IMPL_USE_crypto(...) /* ignore */ @@ -183,6 +206,16 @@ static void run_gcrypt_aes128(uint8_t *output, gcry_cipher_encrypt(aes, output, size, input, size); } +static void run_gcrypt_cast128(uint8_t *output, + const uint8_t *input, unsigned size) +{ + static gcry_cipher_hd_t cast; + if (!cast) + gcry_cipher_open(&cast, GCRY_CIPHER_CAST5, GCRY_CIPHER_MODE_ECB, 0); + gcry_cipher_setkey(cast, hardcoded_key, 16); + gcry_cipher_encrypt(cast, output, size, input, size); +} + #define IMPL_USE_gcrypt(...) IMPL_USE(__VA_ARGS__) #else #define IMPL_USE_gcrypt(...) /* ignore */ @@ -224,6 +257,17 @@ static void run_tomcrypt_aes128(uint8_t *output, aes_ecb_encrypt(input + i, output + i, &aes); } +static void run_tomcrypt_cast128(uint8_t *output, + const uint8_t *input, unsigned size) +{ + symmetric_key cast; + unsigned i; + + cast5_setup(hardcoded_key, 16, 0, &cast); + for (i = 0; i < size; i += 8) + cast5_ecb_encrypt(input + i, output + i, &cast); +} + #define IMPL_USE_tomcrypt(...) IMPL_USE(__VA_ARGS__) #else #define IMPL_USE_tomcrypt(...) /* ignore */ @@ -306,6 +350,7 @@ struct hash_impl implementations[] = { "7c25b9e118c200a189fcd5a01ef106a4e200061f3e97dbf50ba065745fd46bef") IMPL_ALL("RIPEMD-160", ripemd160, "62a5321e4fc8784903bb43ab7752c75f8b25af00") IMPL_ALL("AES-128", aes128, "crc:ff6bc888") + IMPL_ALL("CAST-128", cast128, "crc:456aa584") }; int main(int argc, char **argv)