summaryrefslogtreecommitdiff
path: root/tools/crypto_bench.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-08-26 15:43:44 -0300
committerJames Almer <jamrial@gmail.com>2016-08-26 15:46:32 -0300
commitcf16d620765ad8af6f59b612bf38faf352c77b93 (patch)
tree9bff8e55e05a7b0df3ccbf091efc187beb5b9221 /tools/crypto_bench.c
parentba3f32d07134a68eb8f15e41dcc8564f065dec7a (diff)
downloadffmpeg-cf16d620765ad8af6f59b612bf38faf352c77b93.tar.gz
tools/crypto_bench: add support for des
Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'tools/crypto_bench.c')
-rw-r--r--tools/crypto_bench.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/crypto_bench.c b/tools/crypto_bench.c
index a3ec41ac4b..203bffe198 100644
--- a/tools/crypto_bench.c
+++ b/tools/crypto_bench.c
@@ -78,6 +78,7 @@ struct hash_impl {
#include "libavutil/blowfish.h"
#include "libavutil/camellia.h"
#include "libavutil/cast5.h"
+#include "libavutil/des.h"
#include "libavutil/twofish.h"
#include "libavutil/rc4.h"
#include "libavutil/xtea.h"
@@ -148,6 +149,16 @@ static void run_lavu_cast128(uint8_t *output,
av_cast5_crypt(cast, output, input, size >> 3, 0);
}
+static void run_lavu_des(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ static struct AVDES *des;
+ if (!des && !(des = av_des_alloc()))
+ fatal_error("out of memory");
+ av_des_init(des, hardcoded_key, 64, 0);
+ av_des_crypt(des, output, input, size >> 3, NULL, 0);
+}
+
static void run_lavu_twofish(uint8_t *output,
const uint8_t *input, unsigned size)
{
@@ -184,6 +195,7 @@ static void run_lavu_xtea(uint8_t *output,
#if (USE_EXT_LIBS) & USE_crypto
+#define OPENSSL_DISABLE_OLD_DES_SUPPORT
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
@@ -191,6 +203,7 @@ static void run_lavu_xtea(uint8_t *output,
#include <openssl/blowfish.h>
#include <openssl/camellia.h>
#include <openssl/cast.h>
+#include <openssl/des.h>
#include <openssl/rc4.h>
#define DEFINE_CRYPTO_WRAPPER(suffix, function) \
@@ -252,6 +265,17 @@ static void run_crypto_cast128(uint8_t *output,
CAST_ecb_encrypt(input + i, output + i, &cast, 1);
}
+static void run_crypto_des(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ DES_key_schedule des;
+ unsigned i;
+
+ DES_set_key(hardcoded_key, &des);
+ for (i = 0; i < size; i += 8)
+ DES_ecb_encrypt(input + i, output + i, &des, 1);
+}
+
static void run_crypto_rc4(uint8_t *output,
const uint8_t *input, unsigned size)
{
@@ -302,6 +326,7 @@ DEFINE_GCRYPT_CYPHER_WRAPPER(aes128, AES128, 16)
DEFINE_GCRYPT_CYPHER_WRAPPER(blowfish, BLOWFISH, 16)
DEFINE_GCRYPT_CYPHER_WRAPPER(camellia, CAMELLIA128, 16)
DEFINE_GCRYPT_CYPHER_WRAPPER(cast128, CAST5, 16)
+DEFINE_GCRYPT_CYPHER_WRAPPER(des, DES, 8)
DEFINE_GCRYPT_CYPHER_WRAPPER(twofish, TWOFISH128, 16)
#define IMPL_USE_gcrypt(...) IMPL_USE(__VA_ARGS__)
@@ -380,6 +405,17 @@ static void run_tomcrypt_cast128(uint8_t *output,
cast5_ecb_encrypt(input + i, output + i, &cast);
}
+static void run_tomcrypt_des(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ symmetric_key des;
+ unsigned i;
+
+ des_setup(hardcoded_key, 8, 0, &des);
+ for (i = 0; i < size; i += 8)
+ des_ecb_encrypt(input + i, output + i, &des);
+}
+
static void run_tomcrypt_twofish(uint8_t *output,
const uint8_t *input, unsigned size)
{
@@ -491,6 +527,7 @@ struct hash_impl implementations[] = {
IMPL_ALL("CAMELLIA", camellia, "crc:7abb59a7")
IMPL_ALL("CAST-128", cast128, "crc:456aa584")
IMPL_ALL("BLOWFISH", blowfish, "crc:33e8aa74")
+ IMPL_ALL("DES", des, "crc:31291e0b")
IMPL(lavu, "TWOFISH", twofish, "crc:9edbd5c1")
IMPL(gcrypt, "TWOFISH", twofish, "crc:9edbd5c1")
IMPL(tomcrypt, "TWOFISH", twofish, "crc:9edbd5c1")