• Devulapally Shiva Krishna's avatar
    Crypto/chcr: fix ctr, cbc, xts and rfc3686-ctr failed tests · 6b363a28
    Devulapally Shiva Krishna authored
    This solves the following issues observed during self test when
    CONFIG_CRYPTO_MANAGER_EXTRA_TESTS is enabled.
    
    1. Added fallback for cbc, ctr and rfc3686 if req->nbytes is zero
    and for xts added a fallback case if req->nbytes is not multiple of 16.
    
    2. In case of cbc-aes, solved wrong iv update. When
    chcr_cipher_fallback() is called, used req->info pointer instead of
    reqctx->iv.
    
    3. In cbc-aes decryption there was a wrong result. This occurs when
    chcr_cipher_fallback() is called from chcr_handle_cipher_resp().
    In the fallback function iv(req->info) used is wrongly updated.
    So use the initial iv for this case.
    
    4)In case of ctr-aes encryption observed wrong result. In adjust_ctr_overflow()
    there is condition which checks if ((bytes / AES_BLOCK_SIZE) > c),
    where c is the number of blocks which can be processed without iv overflow,
    but for the above bytes (req->nbytes < 32 , not a multiple of 16) this
    condition fails and the 2nd block is corrupted as it requires the rollover iv.
    So added a '=' condition in this to take care of this.
    
    5)In rfc3686-ctr there was wrong result observed. This occurs when
    chcr_cipher_fallback() is called from chcr_handle_cipher_resp().
    Here also copying initial_iv in init_iv pointer for handling the fallback
    case correctly.
    Signed-off-by: default avatarAyush Sawal <ayush.sawal@chelsio.com>
    Signed-off-by: default avatarDevulapally Shiva Krishna <shiva@chelsio.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    6b363a28
chcr_algo.c 125 KB