[FFmpeg-cvslog] tools/crypto_bench: add support for des

James Almer git at videolan.org
Fri Aug 26 21:47:30 EEST 2016


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Aug 26 15:43:44 2016 -0300| [cf16d620765ad8af6f59b612bf38faf352c77b93] | committer: James Almer

tools/crypto_bench: add support for des

Reviewed-by: Nicolas George <george at nsup.org>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf16d620765ad8af6f59b612bf38faf352c77b93
---

 tools/crypto_bench.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tools/crypto_bench.c b/tools/crypto_bench.c
index a3ec41a..203bffe 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")



More information about the ffmpeg-cvslog mailing list