[Ffmpeg-devel] [PATCH] cbc decoding for aes

Michael Niedermayer michaelni
Sun Jan 14 23:58:31 CET 2007


Hi

On Sun, Jan 14, 2007 at 10:27:37PM +0100, Reimar D?ffinger wrote:
> Hello,
> added this to test. Speed for my sample movie file is about the same as
> with libgcrypt.
> Should I apply or do you have some better/other implementation in mind
> already?

i was thinking about the public API ... but didnt really come up with
anyting nice ...


[...]
>  
> +static inline void copyblock(uint64_t dst[2], const uint64_t src[2]){
> +    dst[0] = src[0];
> +    dst[1] = src[1];
> +}

whats the problem with memcpy() ? gcc does replace constant memcpy() with
not that bad code IIRC


> +
>  #define SUBSHIFT0(s, box)         s[0]=box[s[ 0]]; s[ 4]=box[s[ 4]];          s[ 8]=box[s[ 8]]; s[12]=box[s[12]];
>  #define SUBSHIFT1(s, box) t=s[0]; s[0]=box[s[ 4]]; s[ 4]=box[s[ 8]];          s[ 8]=box[s[12]]; s[12]=box[t];
>  #define SUBSHIFT2(s, box) t=s[0]; s[0]=box[s[ 8]]; s[ 8]=box[    t]; t=s[ 4]; s[ 4]=box[s[12]]; s[12]=box[t];
> @@ -95,6 +100,17 @@
>      crypt(a, 0, inv_sbox, dec_multbl);
>  }
>  
> +void av_aes_cbc_decrypt(AVAES *a, uint8_t *mem, int blockcnt, uint8_t *iv) {

why not have a src and dst?
is it slower?


> +    while (blockcnt-- > 0) {
> +        copyblock(a->state, mem);
> +        crypt(a, 0, inv_sbox, dec_multbl);

is it slower with av_aes_decrypt()?


> +        addkey(a->state, iv);
> +        copyblock(iv, mem);
> +        copyblock(mem, a->state);

i hate all these copies but i have no suggestions on how to avoid them, all
my tries made the code slower ... i hate gcc


> +        mem += 16;
> +    }
> +}

isnt a for(;mem < end; mem+=16) faster?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No evil is honorable: but death is honorable; therefore death is not evil.
-- Citium Zeno
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070114/649257ac/attachment.pgp>



More information about the ffmpeg-devel mailing list