]> git.sesse.net Git - ffmpeg/blobdiff - tools/crypto_bench.c
avformat: Remove FFserver leftovers
[ffmpeg] / tools / crypto_bench.c
index ecbe45f36a4cc4b0c9f4def244768e7cadf31f51..0aff4ea784c29a93e070a09436c732f04b3473fc 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /* Optional external libraries; can be enabled using:
- * make VERSUS=crypto+gcrypt+tomcrypt tools/crypto_bench */
+ * make VERSUS=crypto+gcrypt+tomcrypt+mbedcrypto tools/crypto_bench */
 #define USE_crypto           0x01    /* OpenSSL's libcrypto */
 #define USE_gcrypt           0x02    /* GnuTLS's libgcrypt */
 #define USE_tomcrypt         0x04    /* LibTomCrypt */
@@ -528,6 +528,16 @@ static void run_tomcrypt_des(uint8_t *output,
         des_ecb_encrypt(input + i, output + i, &des);
 }
 
+static void run_tomcrypt_rc4(uint8_t *output,
+                             const uint8_t *input, unsigned size)
+{
+    rc4_state rc4;
+
+    rc4_stream_setup(&rc4, hardcoded_key, 16);
+    rc4_stream_crypt(&rc4, input, size, output);
+    rc4_stream_done(&rc4);
+}
+
 static void run_tomcrypt_twofish(uint8_t *output,
                                 const uint8_t *input, unsigned size)
 {
@@ -647,10 +657,7 @@ struct hash_impl implementations[] = {
     IMPL(lavu,     "TWOFISH", twofish, "crc:9edbd5c1")
     IMPL(gcrypt,   "TWOFISH", twofish, "crc:9edbd5c1")
     IMPL(tomcrypt, "TWOFISH", twofish, "crc:9edbd5c1")
-    IMPL(lavu,     "RC4",     rc4,     "crc:538d37b2")
-    IMPL(crypto,   "RC4",     rc4,     "crc:538d37b2")
-    IMPL(gcrypt,   "RC4",     rc4,     "crc:538d37b2")
-    IMPL(mbedcrypto, "RC4",   rc4,     "crc:538d37b2")
+    IMPL_ALL("RC4",           rc4,     "crc:538d37b2")
     IMPL(lavu,     "XTEA",    xtea,    "crc:931fc270")
     IMPL(mbedcrypto, "XTEA",  xtea,    "crc:931fc270")
     IMPL(tomcrypt, "XTEA",    xtea,    "crc:931fc270")
@@ -658,8 +665,8 @@ struct hash_impl implementations[] = {
 
 int main(int argc, char **argv)
 {
-    uint8_t *input = av_malloc(MAX_INPUT_SIZE * 2);
-    uint8_t *output = input + MAX_INPUT_SIZE;
+    uint8_t *input;
+    uint8_t *output;
     unsigned i, impl, size;
     int opt;
 
@@ -695,12 +702,14 @@ int main(int argc, char **argv)
             exit(opt != 'h');
         }
     }
-
+    input = av_malloc(MAX_INPUT_SIZE * 2);
     if (!input)
         fatal_error("out of memory");
     for (i = 0; i < MAX_INPUT_SIZE; i += 4)
         AV_WB32(input + i, i);
 
+    output = input + MAX_INPUT_SIZE;
+
     size = MAX_INPUT_SIZE;
     for (impl = 0; impl < FF_ARRAY_ELEMS(implementations); impl++)
         run_implementation(input, output, &implementations[impl], size);