]> git.ipfire.org Git - thirdparty/openssl.git/commit
Avoid fragile aliasing of SHA224/384 update/final
authorViktor Dukhovni <openssl-users@dukhovni.org>
Wed, 14 Feb 2018 03:43:15 +0000 (22:43 -0500)
committerViktor Dukhovni <openssl-users@dukhovni.org>
Wed, 14 Feb 2018 04:29:07 +0000 (23:29 -0500)
commit144724c75584054329a9d6bb7711cec527fbf523
treef82c97a040020761a2c66d4f4e995978f47d3def
parentb91891043df21928b72d8093a22a396eca58aa5b
Avoid fragile aliasing of SHA224/384 update/final

This is purported to save a few cycles, but makes the code less
obvious and more brittle, and in fact breaks on platforms where for
ABI continuity reasons there is a SHA2 implementation in libc, and
so EVP needs to call those to avoid conflicts.

A sufficiently good optimizer could simply generate the same entry
points for:

        foo(...) { ... }
    and
        bar(...) { return foo(...); }

but, even without that, the different is negligible, with the
"winner" varying from run to run (openssl speed -evp sha384):

    Old:
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes 16384 bytes
    sha384           28864.28k   117362.62k   266469.21k   483258.03k   635144.87k 649123.16k

    New:
    type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes 16384 bytes
    sha384           30055.18k   120725.98k   272057.26k   482847.40k   634585.09k 650308.27k

Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/evp/m_sha1.c