[FFmpeg-devel] [RFC] Public API for RC4 and DES

Måns Rullgård mans
Mon Feb 2 14:38:43 CET 2009


Reimar D?ffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> writes:

> On Mon, Feb 02, 2009 at 12:53:55PM +0100, Michael Niedermayer wrote:
>> On Mon, Feb 02, 2009 at 11:15:28AM +0000, M?ns Rullg?rd wrote:
>> > Michael Niedermayer <michaelni at gmx.at> writes:
>> > 
>> > > On Mon, Feb 02, 2009 at 10:22:50AM +0000, M?ns Rullg?rd wrote:
>> > >> Reimar D?ffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> writes:
>> > >> 
>> > >> > On Mon, Feb 02, 2009 at 10:59:16AM +0100, Marc Mason wrote:
>> > >> >> Then, why not just declare rc4 on the stack, and pass its address?
>> > >> >> 
>> > >> >> struct AVRC4 rc4;
>> > >> >> [...]
>> > >> >> /* rc4 = av_malloc(av_rc4_size); UNNECESSARY */
>> > >> >> /* pass &rc4 around */
>> > >> >> [...]
>> > >> >> /* av_free(rc4); UNNECESSARY */
>> > >> >> 
>> > >> >> I must be missing something?
>> > >> >
>> > >> > You miss that the size of struct AVRC4 is not known to the compiler.
>> > >> 
>> > >> Why is the interface done in such a twisted way?
>> > >
>> > > so the struct can be changed without breaking ABI
>> > 
>> > How likely is the struct to change?
>> 
>> i dont know, maybe reimar can guess ...
>
> When someone wants to optimize e.g. DES.
> So probably never ;-).
> It was just done in the same way as AES, and it is not a big issue if
> you already have a context.
> It wouldn't be such a big deal to change asfcrypt.c and its usages to
> work better with this API.
> Probably making the struct public isn't such an issue either, except
> that the current way also makes it very clear that users are not
> supposed to touch it.

Users seem able to stay away from the internals of the FILE type from
stdio.h and other standard library structs that are visible but
undocumented.

Either way, the size alone is not sufficient information.  The user
must know the required alignment as well.

> I would prefer if these (AES, DES, RC4) would share the same API if we
> make it public...

Using the same API for all the encryption types makes sense.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list