• Pascal van Leeuwen's avatar
    crypto: inside-secure - fix incorrect skcipher output IV · 5bdb6e6a
    Pascal van Leeuwen authored
    This patch fixes corruption issues with the skcipher output IV
    witnessed on x86+EIP197-FPGA (devboard). The original fix, commit
    57660b11 ("crypto: inside-secure - implement IV retrieval"),
    attempted to write out the result IV through the context record.
    However, this is not a reliable mechanism as there is no way of
    knowing the hardware context update actually arrived in memory, so
    it is possible to read the old contents instead of the updated IV.
    (and indeed, this failed for the x86/FPGA case)
    
    The alternative approach used here recognises the fact that the
    result IV for CBC is actually the last cipher block, which is the last
    input block in case of decryption and the last output block in case
    of encryption. So the result IV is taken from the input data buffer
    respectively the output data buffer instead, which *is* reliable.
    Signed-off-by: default avatarPascal van Leeuwen <pvanleeuwen@verimatrix.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    5bdb6e6a
safexcel_cipher.c 37.9 KB