• Eric Biggers's avatar
    crypto: testmgr - test the !may_use_simd() fallback code · 6570737c
    Eric Biggers authored
    All crypto API algorithms are supposed to support the case where they
    are called in a context where SIMD instructions are unusable, e.g. IRQ
    context on some architectures.  However, this isn't tested for by the
    self-tests, causing bugs to go undetected.
    
    Now that all algorithms have been converted to use crypto_simd_usable(),
    update the self-tests to test the no-SIMD case.  First, a bool
    testvec_config::nosimd is added.  When set, the crypto operation is
    executed with preemption disabled and with crypto_simd_usable() mocked
    out to return false on the current CPU.
    
    A bool test_sg_division::nosimd is also added.  For hash algorithms it's
    honored by the corresponding ->update().  By setting just a subset of
    these bools, the case where some ->update()s are done in SIMD context
    and some are done in no-SIMD context is also tested.
    
    These bools are then randomly set by generate_random_testvec_config().
    
    For now, all no-SIMD testing is limited to the extra crypto self-tests,
    because it might be a bit too invasive for the regular self-tests.
    But this could be changed later.
    
    This has already found bugs in the arm64 AES-GCM and ChaCha algorithms.
    This would have found some past bugs as well.
    Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
    Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    6570737c
testmgr.c 101 KB