[flac-dev] [PATCH] Optionally, allow distros to use openssl for MD5 verification
Cristian Rodríguez
crrodriguez at opensuse.org
Sat May 5 19:37:16 PDT 2012
El 05/05/12 21:04, Eric Wong escribió:
> Cristian Rodríguez<crrodriguez at opensuse.org> wrote:
>> +#if defined(HAVE_OPENSSL)
>> + /* decoder->private_->computed_md5sum is NULL when decoder->private_->do_md5_checking == false
>> + * that causes assertion failure crash in openSSL.
>> + */
>> + if(decoder->private_->do_md5_checking) {
>> + md5_failed = (EVP_DigestFinal_ex(&decoder->private_->md5context, decoder->private_->computed_md5sum, NULL) == 0);
>> + }
>> +#else
>> FLAC__MD5Final(decoder->private_->computed_md5sum,&decoder->private_->md5context);
>> -
>> +#endif
>
> Can you do this without sprinkling #ifdefs all over the place?
>
> Mixing #ifdefs and normal C control structures make code hard to
> read/maintain. This is *especially* true for folks who aren't regular
> contributors to flac, myself included.
>
> I would define workalike macros/no-op functions instead and hide
> OpenSSL-related functionality behind them.
Well, there are reasons why I did it this way.. Initially I though about
your suggested approach...
With this new code
- The format can be easily extended to support other digests algorithms,
(i.e shaXXX that nowdays is implemented with hardware support) openssl
is everywhere including windows.
- The original code follows the traditional old-style convention of
init() update() final() for every operation, this new version init()
cleanup() only *once* per encoder/decoder "instance" reducing the number
of function calls and openssl reuses the allocated resources...
More information about the flac-dev
mailing list