Hello, I have made the changes as suggested by Giorgio. Please let me know if any further changes required.
Thanks, Supraja On Wed, Feb 18, 2015 at 10:52 PM, Giorgio Vazzana <mywin...@gmail.com> wrote: > Hi, > > 2015-02-14 11:12 GMT+01:00 Giorgio Vazzana <mywin...@gmail.com>: > > Hi, > > > > 2015-02-14 9:33 GMT+01:00 supraja reddy <supraja0...@gmail.com>: > >> Hello, > >> > >> I have added the necessary functions for twofish in crypto_bench. > >> A note, there is no twofish implementation in openssl library but since > the > >> code demands that all the libraries have the impl, i have introduced a > >> dummy function. > > > > I know this was initially my suggestion, but looking now at the code I > > see that maybe we could use the IMPL() macro instead of the IMPL_ALL() > > macro in order to exclude 'crypto'. This should simplify the patch. > > > > I'll give it a look tomorrow hopefully, but of course let's see if > > others have comments. > > what about something like the following code? You won't need to add a > dummy function or insert a check inside run_implementation(): > > @@ -398,6 +398,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") > }; > > Giorgio Vazzana > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
From 8a1f5216baa1a2ce741359ed4e83871b2ab790d8 Mon Sep 17 00:00:00 2001 From: Supraja Meedinti <supraja0...@gmail.com> Date: Sat, 21 Feb 2015 19:05:39 +0530 Subject: [PATCH] tools: added twofish support Signed-off-by: Supraja Meedinti <supraja0...@gmail.com> --- 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) -- 1.8.3.2
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel