[FFmpeg-cvslog] tools: added twofish support
Supraja Meedinti
git at videolan.org
Sat Feb 21 15:12:22 CET 2015
ffmpeg | branch: master | Supraja Meedinti <supraja0493 at gmail.com> | Sat Feb 21 19:23:39 2015 +0530| [daebe6319ed759980daf062f97ce983361a16292] | committer: Michael Niedermayer
tools: added twofish support
Signed-off-by: Supraja Meedinti <supraja0493 at gmail.com>
Reviewed-by: Nicolas George <george at nsup.org>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=daebe6319ed759980daf062f97ce983361a16292
---
tools/crypto_bench.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/crypto_bench.c b/tools/crypto_bench.c
index 5e56d12..79629bc 100644
--- a/tools/crypto_bench.c
+++ b/tools/crypto_bench.c
@@ -77,6 +77,7 @@ struct hash_impl {
#include "libavutil/aes.h"
#include "libavutil/camellia.h"
#include "libavutil/cast5.h"
+#include "libavutil/twofish.h"
#define IMPL_USE_lavu IMPL_USE
@@ -133,6 +134,15 @@ static void run_lavu_cast128(uint8_t *output,
av_cast5_crypt(cast, output, input, size >> 3, 0);
}
+static void run_lavu_twofish(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ static struct AVTWOFISH *twofish;
+ if (!twofish && !(twofish = av_twofish_alloc()))
+ fatal_error("out of memory");
+ av_twofish_init(twofish, hardcoded_key, 128);
+ av_twofish_crypt(twofish, output, input, size >> 4, NULL, 0);
+}
/***************************************************************************
* crypto: OpenSSL's libcrypto
***************************************************************************/
@@ -250,6 +260,16 @@ static void run_gcrypt_cast128(uint8_t *output,
gcry_cipher_encrypt(cast, output, size, input, size);
}
+static void run_gcrypt_twofish(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ static gcry_cipher_hd_t twofish;
+ if (!twofish)
+ gcry_cipher_open(&twofish, GCRY_CIPHER_TWOFISH128, GCRY_CIPHER_MODE_ECB, 0);
+ gcry_cipher_setkey(twofish, hardcoded_key, 16);
+ gcry_cipher_encrypt(twofish, output, size, input, size);
+}
+
#define IMPL_USE_gcrypt(...) IMPL_USE(__VA_ARGS__)
#else
#define IMPL_USE_gcrypt(...) /* ignore */
@@ -314,6 +334,19 @@ static void run_tomcrypt_cast128(uint8_t *output,
cast5_ecb_encrypt(input + i, output + i, &cast);
}
+static void run_tomcrypt_twofish(uint8_t *output,
+ const uint8_t *input, unsigned size)
+{
+ symmetric_key twofish;
+ unsigned i;
+
+ twofish_setup(hardcoded_key, 16, 0, &twofish);
+ size -= 15;
+ for (i = 0; i < size; i += 16)
+ twofish_ecb_encrypt(input + i, output + i, &twofish);
+}
+
+
#define IMPL_USE_tomcrypt(...) IMPL_USE(__VA_ARGS__)
#else
#define IMPL_USE_tomcrypt(...) /* ignore */
@@ -398,6 +431,9 @@ struct hash_impl implementations[] = {
IMPL_ALL("AES-128", aes128, "crc:ff6bc888")
IMPL_ALL("CAMELLIA", camellia, "crc:7abb59a7")
IMPL_ALL("CAST-128", cast128, "crc:456aa584")
+ IMPL(lavu, "TWOFISH", twofish, "crc:9edbd5c1")
+ IMPL(gcrypt, "TWOFISH", twofish, "crc:9edbd5c1")
+ IMPL(tomcrypt, "TWOFISH", twofish, "crc:9edbd5c1")
};
int main(int argc, char **argv)
More information about the ffmpeg-cvslog
mailing list