• Ard Biesheuvel's avatar
    crypto: ecdh - avoid unaligned accesses in ecdh_set_secret() · 17858b14
    Ard Biesheuvel authored
    ecdh_set_secret() casts a void* pointer to a const u64* in order to
    feed it into ecc_is_key_valid(). This is not generally permitted by
    the C standard, and leads to actual misalignment faults on ARMv6
    cores. In some cases, these are fixed up in software, but this still
    leads to performance hits that are entirely avoidable.
    
    So let's copy the key into the ctx buffer first, which we will do
    anyway in the common case, and which guarantees correct alignment.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    17858b14
ecdh.c 3.97 KB