mirror of https://git.ffmpeg.org/ffmpeg.git
tools/crypto_bench: add CAST5 support
Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
c5ffd7aee5
commit
e397edbfba
|
@ -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 <openssl/sha.h>
|
||||
#include <openssl/ripemd.h>
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/cast.h>
|
||||
|
||||
#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)
|
||||
|
|
Loading…
Reference in New Issue