[Ffmpeg-devel] [PATCH] cbc decoding for aes
Michael Niedermayer
michaelni
Mon Jan 15 11:20:19 CET 2007
Hi
On Mon, Jan 15, 2007 at 10:02:47AM +0100, Reimar Doeffinger wrote:
[...]
> > > +
> > > #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?
>
> Well, at least in my use case I would have to allocate another buffer
> for that.
you could always pass dst=src or dst=src-2 to the decrypt function ...
> It actually might be faster (the decryption itself, together
> with cache effects it could easily be slower overall though) since we would
> have to copy iv only once per function call. Though about speed I have
> been wondering if we really have to use that state var in the context,
> it means an additional copy in and copy out if we provide a function
ive tried to remove the state thing yesterday but no matter what i did the
code ended up significantly slower, if you can figure out how to get rid of
it without causing gcc to create bullshit-code id be happy ...
[...]
> > > + while (blockcnt-- > 0) {
> > > + copyblock(a->state, mem);
> > > + crypt(a, 0, inv_sbox, dec_multbl);
> >
> > is it slower with av_aes_decrypt()?
>
> Probably not, but to be honest I find av_aes_decrypt pretty useless
> as exported function at least since I can hardly imagine a use case
> where the application would want to decrypt only 16 bytes...
i too find it useless, thats why its not in aes.h ... as i said iam not
sure about the public API
i wanted to do something like, getting rid of state and then doing
src -cpy-> dst
decrypt(dst)
if(cbc)
src-1 -xor-> dst
---
src -cpy-> dst
if(cbc)
dst-1 -xor-> dst
encrypt(dst)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20070115/685c5d72/attachment.pgp>
More information about the ffmpeg-devel
mailing list