09 Jan, 2020

1 commit

  • The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to
    make the ->setkey() functions provide more information about errors.

    However, no one actually checks for this flag, which makes it pointless.

    Also, many algorithms fail to set this flag when given a bad length key.
    Reviewing just the generic implementations, this is the case for
    aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309,
    rfc7539, rfc7539esp, salsa20, seqiv, and xcbc. But there are probably
    many more in arch/*/crypto/ and drivers/crypto/.

    Some algorithms can even set this flag when the key is the correct
    length. For example, authenc and authencesn set it when the key payload
    is malformed in any way (not just a bad length), the atmel-sha and ccree
    drivers can set it if a memory allocation fails, and the chelsio driver
    sets it for bad auth tag lengths, not just bad key lengths.

    So even if someone actually wanted to start checking this flag (which
    seems unlikely, since it's been unused for a long time), there would be
    a lot of work needed to get it working correctly. But it would probably
    be much better to go back to the drawing board and just define different
    return values, like -EINVAL if the key is invalid for the algorithm vs.
    -EKEYREJECTED if the key was rejected by a policy like "no weak keys".
    That would be much simpler, less error-prone, and easier to test.

    So just remove this flag.

    Signed-off-by: Eric Biggers
    Reviewed-by: Horia Geantă
    Signed-off-by: Herbert Xu

    Eric Biggers
     

21 May, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not see http www gnu org licenses

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details [based]
    [from] [clk] [highbank] [c] you should have received a copy of the
    gnu general public license along with this program if not see http
    www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 355 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

29 Nov, 2017

1 commit


09 Nov, 2011

1 commit

  • Patch adds LRW support for twofish-x86_64-3way by using lrw_crypt(). Patch has
    been tested with tcrypt and automated filesystem tests.

    Tcrypt benchmarks results (twofish-3way/twofish-asm speed ratios):

    Intel Celeron T1600 (fam:6, model:15, step:13):

    size lrw-enc lrw-dec
    16B 0.99x 1.00x
    64B 1.17x 1.17x
    256B 1.26x 1.27x
    1024B 1.30x 1.31x
    8192B 1.31x 1.32x

    AMD Phenom II 1055T (fam:16, model:10):

    size lrw-enc lrw-dec
    16B 1.06x 1.01x
    64B 1.08x 1.14x
    256B 1.19x 1.20x
    1024B 1.21x 1.22x
    8192B 1.23x 1.24x

    Signed-off-by: Jussi Kivilinna
    Signed-off-by: Herbert Xu

    Jussi Kivilinna
     

11 Jan, 2008

1 commit

  • Currently twofish cipher key setup code
    has unrolled loops - approximately 70-100
    instructions are repeated 40 times.

    As a result, twofish module is the biggest module
    in crypto/*.

    Unrolling produces x2.5 more code (+18k on i386), and speeds up key
    setup by 7%:

    unrolled: twofish_setkey/sec: 41128
    loop: twofish_setkey/sec: 38148
    CALC_K256: ~100 insns each
    CALC_K192: ~90 insns
    CALC_K: ~70 insns

    Attached patch removes this unrolling.

    $ size */twofish_common.o
    text data bss dec hex filename
    37920 0 0 37920 9420 crypto.org/twofish_common.o
    13209 0 0 13209 3399 crypto/twofish_common.o

    Run tested (modprobe tcrypt reports ok). Please apply.

    Signed-off-by: Denys Vlasenko
    Signed-off-by: Herbert Xu

    Denys Vlasenko
     

21 Sep, 2006

2 commits

  • Now that the tfm is passed directly to setkey instead of the ctx, we no
    longer need to pass the &tfm->crt_flags pointer.

    This patch also gets rid of a few unnecessary checks on the key length
    for ciphers as the cipher layer guarantees that the key length is within
    the bounds specified by the algorithm.

    Rather than testing dia_setkey every time, this patch does it only once
    during crypto_alloc_tfm. The redundant check from crypto_digest_setkey
    is also removed.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch splits up the twofish crypto routine into a common part ( key
    setup ) which will be uses by all twofish crypto modules ( generic-c , i586
    assembler and x86_64 assembler ) and generic-c part. It also creates a new
    header file which will be used by all 3 modules.

    This eliminates all code duplication.

    Correctness was verified with the tcrypt module and automated test scripts.

    Signed-off-by: Joachim Fritschi
    Signed-off-by: Herbert Xu

    Joachim Fritschi