27 Dec, 2019

1 commit

  • This patch introduces the skcipher_ialg_simple helper which fetches
    the crypto_alg structure from a simple skcipher instance's spawn.

    This allows us to remove the third argument from the function
    skcipher_alloc_instance_simple.

    In doing so the reference count to the algorithm is now maintained
    by the Crypto API and the caller no longer needs to drop the alg
    refcount.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

18 Apr, 2019

1 commit

  • Use subsys_initcall for registration of all templates and generic
    algorithm implementations, rather than module_init. Then change
    cryptomgr to use arch_initcall, to place it before the subsys_initcalls.

    This is needed so that when both a generic and optimized implementation
    of an algorithm are built into the kernel (not loadable modules), the
    generic implementation is registered before the optimized one.
    Otherwise, the self-tests for the optimized implementation are unable to
    allocate the generic implementation for the new comparison fuzz tests.

    Note that on arm, a side effect of this change is that self-tests for
    generic implementations may run before the unaligned access handler has
    been installed. So, unaligned accesses will crash the kernel. This is
    arguably a good thing as it makes it easier to detect that type of bug.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

11 Jan, 2019

1 commit

  • Convert the keywrap template from the deprecated "blkcipher" API to the
    "skcipher" API, taking advantage of skcipher_alloc_instance_simple() to
    simplify it considerably.

    Cc: Stephan Mueller
    Signed-off-by: Eric Biggers
    Reviewed-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Eric Biggers
     

29 Nov, 2017

1 commit

  • On 32-bit (e.g. with m68k-linux-gnu-gcc-4.1):

    crypto/keywrap.c: In function ‘crypto_kw_decrypt’:
    crypto/keywrap.c:191: warning: integer constant is too large for ‘long’ type
    crypto/keywrap.c: In function ‘crypto_kw_encrypt’:
    crypto/keywrap.c:224: warning: integer constant is too large for ‘long’ type

    Fixes: 9e49451d7a15365d ("crypto: keywrap - simplify code")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Geert Uytterhoeven
     

12 Oct, 2017

1 commit

  • The code is simplified by using two __be64 values for the operation
    instead of using two arrays of u8. This allows to get rid of the memory
    alignment code. In addition, the crypto_xor can be replaced with a
    native XOR operation. Finally, the definition of the variables is
    re-arranged such that the data structures come before simple variables
    to potentially reduce memory space.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

01 Feb, 2016

1 commit

  • We're clearing the wrong memory. The memory corruption is likely
    harmless because we weren't going to use that stack memory again but not
    zeroing is a potential information leak.

    Fixes: e28facde3c39 ('crypto: keywrap - add key wrapping block chaining mode')
    Signed-off-by: Dan Carpenter
    Acked-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Dan Carpenter
     

15 Oct, 2015

1 commit

  • This patch implements the AES key wrapping as specified in
    NIST SP800-38F and RFC3394.

    The implementation covers key wrapping without padding.

    IV handling: The caller does not provide an IV for encryption,
    but must obtain the IV after encryption which would serve as the first
    semblock in the ciphertext structure defined by SP800-38F. Conversely,
    for decryption, the caller must provide the first semiblock of the data
    as the IV and the following blocks as ciphertext.

    The key wrapping is an authenticated decryption operation. The caller
    will receive EBADMSG during decryption if the authentication failed.

    Albeit the standards define the key wrapping for AES only, the template
    can be used with any other block cipher that has a block size of 16
    bytes. During initialization of the template, that condition is checked.
    Any cipher not having a block size of 16 bytes will cause the
    initialization to fail.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller