• Herbert Xu's avatar
    crypto: skcipher - Add internal state support · 0ae4dcc1
    Herbert Xu authored
    Unlike chaining modes such as CBC, stream ciphers other than CTR
    usually hold an internal state that must be preserved if the
    operation is to be done piecemeal.  This has not been represented
    in the API, resulting in the inability to split up stream cipher
    operations.
    
    This patch adds the basic representation of an internal state to
    skcipher and lskcipher.  In the interest of backwards compatibility,
    the default has been set such that existing users are assumed to
    be operating in one go as opposed to piecemeal.
    
    With the new API, each lskcipher/skcipher algorithm has a new
    attribute called statesize.  For skcipher, this is the size of
    the buffer that can be exported or imported similar to ahash.
    For lskcipher, instead of providing a buffer of ivsize, the user
    now has to provide a buffer of ivsize + statesize.
    
    Each skcipher operation is assumed to be final as they are now,
    but this may be overridden with a request flag.  When the override
    occurs, the user may then export the partial state and reimport
    it later.
    
    For lskcipher operations this is reversed.  All operations are
    not final and the state will be exported unless the FINAL bit is
    set.  However, the CONT bit still has to be set for the state
    to be used.
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    0ae4dcc1
lskcipher.c 16.9 KB