[FFmpeg-devel] [PATCH] DES en-/decryption

Reimar Döffinger Reimar.Doeffinger
Mon Oct 15 09:53:26 CEST 2007


Hello,
On Sun, Oct 14, 2007 at 11:40:43PM +0200, Michael Niedermayer wrote:
[...]
> > +static uint64_t shuffle_inv(uint64_t in, const uint8_t *shuffle, int shuffle_len) {
> > +    int i;
> > +    uint64_t res = 0;
> > +    shuffle += shuffle_len - 1;
> > +    for (i = 0; i < shuffle_len; i++) {
> > +        res |= (in & 1) << *shuffle--;
> > +        in >>= 1;
> > +    }
> > +    return res;
> > +}
> 
> is this function bigger than the 64 byte needed for the inverse IP table?

It is 51 bytes without the alignment, and since it with my compiler
always gets inlined it is about 50 bytes.

> maybe
> out |= P_shuffle2[ S_boxes2[i][tmp] ];
> 
> would be worth a try?
> it would cut the needed table size down by 2 at the expense of one more
> table lookup
> (yes S_boxes2 would contain i so that P_shuffle2 could correctly reshuffle
> it)

Well, I find it somewhat doubtful that adding a second table lookup to
save 2kB (IIRC) makes sense without CONFIG_SMALL.

> [...]
> 
> > +    uint64_t CDn = shuffle(key, PC1_shuffle, sizeof(PC1_shuffle));
> > +    // generate round keys
> > +    for (i = 0; i < 16; i++) {
> > +        CDn = key_shift_left(CDn);
> > +        if (i > 1 && i != 8 && i != 15)
> 
> if((i&7) && i != 15)

This misses the i == 1 case, doesn't it?
Not sure if (i != 1 && (i & 7) && i != 15) is any better than the
current code.

[...]
and now I have to go.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list