Skip to content
  • Joy Latten's avatar
    [CRYPTO] ctr: Add countersize · 41fdab3d
    Joy Latten authored
    
    
    This patch adds countersize to CTR mode.
    The template is now ctr(algo,noncesize,ivsize,countersize).
    
    For example, ctr(aes,4,8,4) indicates the counterblock
    will be composed of a salt/nonce that is 4 bytes, an iv
    that is 8 bytes and the counter is 4 bytes.
    
    When noncesize + ivsize < blocksize, CTR initializes the
    last block - ivsize - noncesize portion of the block to
    zero.  Otherwise the counter block is composed of the IV
    (and nonce if necessary).
    
    If noncesize + ivsize == blocksize, then this indicates that
    user is passing in entire counterblock. Thus countersize
    indicates the amount of bytes in counterblock to use as
    the counter for incrementing. CTR will increment counter
    portion by 1, and begin encryption with that value.
    
    Note that CTR assumes the counter portion of the block that
    will be incremented is stored in big endian.
    
    Signed-off-by: default avatarJoy Latten <latten@austin.ibm.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    41fdab3d