Skip to content
Snippets Groups Projects
  1. Nov 09, 2021
  2. Oct 29, 2021
  3. Oct 25, 2021
  4. Oct 22, 2021
  5. Oct 08, 2021
  6. Oct 01, 2021
  7. Sep 24, 2021
    • Herbert Xu's avatar
      crypto: api - Fix built-in testing dependency failures · adad556e
      Herbert Xu authored
      
      When complex algorithms that depend on other algorithms are built
      into the kernel, the order of registration must be done such that
      the underlying algorithms are ready before the ones on top are
      registered.  As otherwise they would fail during the self-test
      which is required during registration.
      
      In the past we have used subsystem initialisation ordering to
      guarantee this.  The number of such precedence levels are limited
      and they may cause ripple effects in other subsystems.
      
      This patch solves this problem by delaying all self-tests during
      boot-up for built-in algorithms.  They will be tested either when
      something else in the kernel requests for them, or when we have
      finished registering all built-in algorithms, whichever comes
      earlier.
      
      Reported-by: default avatarVladis Dronov <vdronov@redhat.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      adad556e
  8. Sep 22, 2021
    • Alexey Dobriyan's avatar
      isystem: delete global -isystem compile option · 04e85bbf
      Alexey Dobriyan authored
      
      Further isolate kernel from userspace, prevent accidental inclusion of
      undesireable headers, mainly float.h and stdatomic.h.
      
      nds32 keeps -isystem globally due to intrinsics used in entrenched header.
      
      -isystem is selectively reenabled for some files, again, for intrinsics.
      
      Compile tested on:
      
      hexagon-defconfig hexagon-allmodconfig
      alpha-allmodconfig alpha-allnoconfig alpha-defconfig arm64-allmodconfig
      arm64-allnoconfig arm64-defconfig arm-am200epdkit arm-aspeed_g4
      arm-aspeed_g5 arm-assabet arm-at91_dt arm-axm55xx arm-badge4 arm-bcm2835
      arm-cerfcube arm-clps711x arm-cm_x300 arm-cns3420vb arm-colibri_pxa270
      arm-colibri_pxa300 arm-collie arm-corgi arm-davinci_all arm-dove
      arm-ep93xx arm-eseries_pxa arm-exynos arm-ezx arm-footbridge arm-gemini
      arm-h3600 arm-h5000 arm-hackkit arm-hisi arm-imote2 arm-imx_v4_v5
      arm-imx_v6_v7 arm-integrator arm-iop32x arm-ixp4xx arm-jornada720
      arm-keystone arm-lart arm-lpc18xx arm-lpc32xx arm-lpd270 arm-lubbock
      arm-magician arm-mainstone arm-milbeaut_m10v arm-mini2440 arm-mmp2
      arm-moxart arm-mps2 arm-multi_v4t arm-multi_v5 arm-multi_v7 arm-mv78xx0
      arm-mvebu_v5 arm-mvebu_v7 arm-mxs arm-neponset arm-netwinder arm-nhk8815
      arm-omap1 arm-omap2plus arm-orion5x arm-oxnas_v6 arm-palmz72 arm-pcm027
      arm-pleb arm-pxa arm-pxa168 arm-pxa255-idp arm-pxa3xx arm-pxa910
      arm-qcom arm-realview arm-rpc arm-s3c2410 arm-s3c6400 arm-s5pv210
      arm-sama5 arm-shannon arm-shmobile arm-simpad arm-socfpga arm-spear13xx
      arm-spear3xx arm-spear6xx arm-spitz arm-stm32 arm-sunxi arm-tct_hammer
      arm-tegra arm-trizeps4 arm-u8500 arm-versatile arm-vexpress arm-vf610m4
      arm-viper arm-vt8500_v6_v7 arm-xcep arm-zeus csky-allmodconfig
      csky-allnoconfig csky-defconfig h8300-edosk2674 h8300-h8300h-sim
      h8300-h8s-sim i386-allmodconfig i386-allnoconfig i386-defconfig
      ia64-allmodconfig ia64-allnoconfig ia64-bigsur ia64-generic ia64-gensparse
      ia64-tiger ia64-zx1 m68k-amcore m68k-amiga m68k-apollo m68k-atari
      m68k-bvme6000 m68k-hp300 m68k-m5208evb m68k-m5249evb m68k-m5272c3
      m68k-m5275evb m68k-m5307c3 m68k-m5407c3 m68k-m5475evb m68k-mac
      m68k-multi m68k-mvme147 m68k-mvme16x m68k-q40 m68k-stmark2 m68k-sun3
      m68k-sun3x microblaze-allmodconfig microblaze-allnoconfig microblaze-mmu
      mips-ar7 mips-ath25 mips-ath79 mips-bcm47xx mips-bcm63xx mips-bigsur
      mips-bmips_be mips-bmips_stb mips-capcella mips-cavium_octeon mips-ci20
      mips-cobalt mips-cu1000-neo mips-cu1830-neo mips-db1xxx mips-decstation
      mips-decstation_64 mips-decstation_r4k mips-e55 mips-fuloong2e
      mips-gcw0 mips-generic mips-gpr mips-ip22 mips-ip27 mips-ip28 mips-ip32
      mips-jazz mips-jmr3927 mips-lemote2f mips-loongson1b mips-loongson1c
      mips-loongson2k mips-loongson3 mips-malta mips-maltaaprp mips-malta_kvm
      mips-malta_qemu_32r6 mips-maltasmvp mips-maltasmvp_eva mips-maltaup
      mips-maltaup_xpa mips-mpc30x mips-mtx1 mips-nlm_xlp mips-nlm_xlr
      mips-omega2p mips-pic32mzda mips-pistachio mips-qi_lb60 mips-rb532
      mips-rbtx49xx mips-rm200 mips-rs90 mips-rt305x mips-sb1250_swarm
      mips-tb0219 mips-tb0226 mips-tb0287 mips-vocore2 mips-workpad mips-xway
      nds32-allmodconfig nds32-allnoconfig nds32-defconfig nios2-10m50
      nios2-3c120 nios2-allmodconfig nios2-allnoconfig openrisc-allmodconfig
      openrisc-allnoconfig openrisc-or1klitex openrisc-or1ksim
      openrisc-simple_smp parisc-allnoconfig parisc-generic-32bit
      parisc-generic-64bit powerpc-acadia powerpc-adder875 powerpc-akebono
      powerpc-amigaone powerpc-arches powerpc-asp8347 powerpc-bamboo
      powerpc-bluestone powerpc-canyonlands powerpc-cell powerpc-chrp32
      powerpc-cm5200 powerpc-currituck powerpc-ebony powerpc-eiger
      powerpc-ep8248e powerpc-ep88xc powerpc-fsp2 powerpc-g5 powerpc-gamecube
      powerpc-ge_imp3a powerpc-holly powerpc-icon powerpc-iss476-smp
      powerpc-katmai powerpc-kilauea powerpc-klondike powerpc-kmeter1
      powerpc-ksi8560 powerpc-linkstation powerpc-lite5200b powerpc-makalu
      powerpc-maple powerpc-mgcoge powerpc-microwatt powerpc-motionpro
      powerpc-mpc512x powerpc-mpc5200 powerpc-mpc7448_hpc2 powerpc-mpc8272_ads
      powerpc-mpc8313_rdb powerpc-mpc8315_rdb powerpc-mpc832x_mds
      powerpc-mpc832x_rdb powerpc-mpc834x_itx powerpc-mpc834x_itxgp
      powerpc-mpc834x_mds powerpc-mpc836x_mds powerpc-mpc836x_rdk
      powerpc-mpc837x_mds powerpc-mpc837x_rdb powerpc-mpc83xx
      powerpc-mpc8540_ads powerpc-mpc8560_ads powerpc-mpc85xx_cds
      powerpc-mpc866_ads powerpc-mpc885_ads powerpc-mvme5100 powerpc-obs600
      powerpc-pasemi powerpc-pcm030 powerpc-pmac32 powerpc-powernv
      powerpc-ppa8548 powerpc-ppc40x powerpc-ppc44x powerpc-ppc64
      powerpc-ppc64e powerpc-ppc6xx powerpc-pq2fads powerpc-ps3
      powerpc-pseries powerpc-rainier powerpc-redwood powerpc-sam440ep
      powerpc-sbc8548 powerpc-sequoia powerpc-skiroot powerpc-socrates
      powerpc-storcenter powerpc-stx_gp3 powerpc-taishan powerpc-tqm5200
      powerpc-tqm8540 powerpc-tqm8541 powerpc-tqm8548 powerpc-tqm8555
      powerpc-tqm8560 powerpc-tqm8xx powerpc-walnut powerpc-warp powerpc-wii
      powerpc-xes_mpc85xx riscv-allmodconfig riscv-allnoconfig riscv-nommu_k210
      riscv-nommu_k210_sdcard riscv-nommu_virt riscv-rv32 s390-allmodconfig
      s390-allnoconfig s390-debug s390-zfcpdump sh-ap325rxa sh-apsh4a3a
      sh-apsh4ad0a sh-dreamcast sh-ecovec24 sh-ecovec24-romimage sh-edosk7705
      sh-edosk7760 sh-espt sh-hp6xx sh-j2 sh-kfr2r09 sh-kfr2r09-romimage
      sh-landisk sh-lboxre2 sh-magicpanelr2 sh-microdev sh-migor sh-polaris
      sh-r7780mp sh-r7785rp sh-rsk7201 sh-rsk7203 sh-rsk7264 sh-rsk7269
      sh-rts7751r2d1 sh-rts7751r2dplus sh-sdk7780 sh-sdk7786 sh-se7206 sh-se7343
      sh-se7619 sh-se7705 sh-se7712 sh-se7721 sh-se7722 sh-se7724 sh-se7750
      sh-se7751 sh-se7780 sh-secureedge5410 sh-sh03 sh-sh2007 sh-sh7710voipgw
      sh-sh7724_generic sh-sh7757lcr sh-sh7763rdp sh-sh7770_generic sh-sh7785lcr
      sh-sh7785lcr_32bit sh-shmin sh-shx3 sh-titan sh-ul2 sh-urquell
      sparc-allmodconfig sparc-allnoconfig sparc-sparc32 sparc-sparc64
      um-i386-allmodconfig um-i386-allnoconfig um-i386-defconfig
      um-x86_64-allmodconfig um-x86_64-allnoconfig x86_64-allmodconfig
      x86_64-allnoconfig x86_64-defconfig xtensa-allmodconfig xtensa-allnoconfig
      xtensa-audio_kc705 xtensa-cadence_csp xtensa-common xtensa-generic_kc705
      xtensa-iss xtensa-nommu_kc705 xtensa-smp_lx200 xtensa-virt
      xtensa-xip_kc705
      
      Tested-by: Nathan Chancellor <nathan@kernel.org> # build (hexagon)
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      04e85bbf
  9. Sep 17, 2021
  10. Aug 27, 2021
    • Lukas Bulwahn's avatar
      crypto: sha512 - remove imaginary and mystifying clearing of variables · 6ae51ffe
      Lukas Bulwahn authored
      
      The function sha512_transform() assigns all local variables to 0 before
      returning to its caller with the intent to erase sensitive data.
      
      However, make clang-analyzer warns that all these assignments are dead
      stores, and as commit 7a4295f6 ("crypto: lib/sha256 - Don't clear
      temporary variables") already points out for sha256_transform():
      
        The assignments to clear a through h and t1/t2 are optimized out by the
        compiler because they are unused after the assignments.
      
        Clearing individual scalar variables is unlikely to be useful, as they
        may have been assigned to registers, and even if stack spilling was
        required, there may be compiler-generated temporaries that are
        impossible to clear in any case.
      
      This applies here again as well. Drop meaningless clearing of local
      variables and avoid this way that the code suggests that data is erased,
      which simply does not happen.
      
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      6ae51ffe
    • Tianjia Zhang's avatar
      crypto: x86/sm4 - add AES-NI/AVX2/x86_64 implementation · 5b2efa2b
      Tianjia Zhang authored
      Like the implementation of AESNI/AVX, this patch adds an accelerated
      implementation of AESNI/AVX2. In terms of code implementation, by
      reusing AESNI/AVX mode-related codes, the amount of code is greatly
      reduced. From the benchmark data, it can be seen that when the block
      size is 1024, compared to AVX acceleration, the performance achieved
      by AVX2 has increased by about 70%, it is also 7.7 times of the pure
      software implementation of sm4-generic.
      
      The main algorithm implementation comes from SM4 AES-NI work by
      libgcrypt and Markku-Juhani O. Saarinen at:
      https://github.com/mjosaarinen/sm4ni
      
      
      
      This optimization supports the four modes of SM4, ECB, CBC, CFB,
      and CTR. Since CBC and CFB do not support multiple block parallel
      encryption, the optimization effect is not obvious.
      
      Benchmark on Intel i5-6200U 2.30GHz, performance data of three
      implementation methods, pure software sm4-generic, aesni/avx
      acceleration, and aesni/avx2 acceleration, the data comes from
      the 218 mode and 518 mode of tcrypt. The abscissas are blocks of
      different lengths. The data is tabulated and the unit is Mb/s:
      
      block-size  |    16      64     128     256    1024    1420    4096
      sm4-generic
          ECB enc | 60.94   70.41   72.27   73.02   73.87   73.58   73.59
          ECB dec | 61.87   70.53   72.15   73.09   73.89   73.92   73.86
          CBC enc | 56.71   66.31   68.05   69.84   70.02   70.12   70.24
          CBC dec | 54.54   65.91   68.22   69.51   70.63   70.79   70.82
          CFB enc | 57.21   67.24   69.10   70.25   70.73   70.52   71.42
          CFB dec | 57.22   64.74   66.31   67.24   67.40   67.64   67.58
          CTR enc | 59.47   68.64   69.91   71.02   71.86   71.61   71.95
          CTR dec | 59.94   68.77   69.95   71.00   71.84   71.55   71.95
      sm4-aesni-avx
          ECB enc | 44.95  177.35  292.06  316.98  339.48  322.27  330.59
          ECB dec | 45.28  178.66  292.31  317.52  339.59  322.52  331.16
          CBC enc | 57.75   67.68   69.72   70.60   71.48   71.63   71.74
          CBC dec | 44.32  176.83  284.32  307.24  328.61  312.61  325.82
          CFB enc | 57.81   67.64   69.63   70.55   71.40   71.35   71.70
          CFB dec | 43.14  167.78  282.03  307.20  328.35  318.24  325.95
          CTR enc | 42.35  163.32  279.11  302.93  320.86  310.56  317.93
          CTR dec | 42.39  162.81  278.49  302.37  321.11  310.33  318.37
      sm4-aesni-avx2
          ECB enc | 45.19  177.41  292.42  316.12  339.90  322.53  330.54
          ECB dec | 44.83  178.90  291.45  317.31  339.85  322.55  331.07
          CBC enc | 57.66   67.62   69.73   70.55   71.58   71.66   71.77
          CBC dec | 44.34  176.86  286.10  501.68  559.58  483.87  527.46
          CFB enc | 57.43   67.60   69.61   70.52   71.43   71.28   71.65
          CFB dec | 43.12  167.75  268.09  499.33  558.35  490.36  524.73
          CTR enc | 42.42  163.39  256.17  493.95  552.45  481.58  517.19
          CTR dec | 42.49  163.11  256.36  493.34  552.62  481.49  516.83
      
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      5b2efa2b
    • Lukas Bulwahn's avatar
      crypto: rmd320 - remove rmd320 in Makefile · ff1469a2
      Lukas Bulwahn authored
      
      Commit 93f64202 ("crypto: rmd320 - remove RIPE-MD 320 hash algorithm")
      removes the Kconfig and code, but misses to adjust the Makefile.
      
      Hence, ./scripts/checkkconfigsymbols.py warns:
      
      CRYPTO_RMD320
      Referencing files: crypto/Makefile
      
      Remove the missing piece of this code removal.
      
      Fixes: 93f64202 ("crypto: rmd320 - remove RIPE-MD 320 hash algorithm")
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      ff1469a2
  11. Aug 23, 2021
  12. Aug 21, 2021
  13. Aug 12, 2021
  14. Jul 30, 2021
    • Mian Yousaf Kaukab's avatar
      crypto: ecc - handle unaligned input buffer in ecc_swap_digits · 0469dede
      Mian Yousaf Kaukab authored
      
      ecdsa_set_pub_key() makes an u64 pointer at 1 byte offset of the key.
      This results in an unaligned u64 pointer. This pointer is passed to
      ecc_swap_digits() which assumes natural alignment.
      
      This causes a kernel crash on an armv7 platform:
      [    0.409022] Unhandled fault: alignment exception (0x001) at 0xc2a0a6a9
      ...
      [    0.416982] PC is at ecdsa_set_pub_key+0xdc/0x120
      ...
      [    0.491492] Backtrace:
      [    0.492059] [<c07c266c>] (ecdsa_set_pub_key) from [<c07c75d4>] (test_akcipher_one+0xf4/0x6c0)
      
      Handle unaligned input buffer in ecc_swap_digits() by replacing
      be64_to_cpu() to get_unaligned_be64(). Change type of in pointer to
      void to reflect it doesn’t necessarily need to be aligned.
      
      Fixes: 4e660291 ("crypto: ecdsa - Add support for ECDSA signature verification")
      Reported-by: default avatarGuillaume Gardet <guillaume.gardet@arm.com>
      Suggested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarMian Yousaf Kaukab <ykaukab@suse.de>
      Tested-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      0469dede
    • Tianjia Zhang's avatar
      crypto: tcrypt - add the asynchronous speed test for SM4 · a7fc80bb
      Tianjia Zhang authored
      
      tcrypt supports testing of SM4 cipher algorithms that use avx
      instruction set acceleration. The implementation of sm4 instruction
      set acceleration supports up to 8 blocks in parallel encryption and
      decryption, which is 128 bytes. Therefore, the 128-byte block size
      is also added to block_sizes.
      
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      a7fc80bb
    • Tianjia Zhang's avatar
      crypto: x86/sm4 - add AES-NI/AVX/x86_64 implementation · a7ee22ee
      Tianjia Zhang authored
      This patch adds AES-NI/AVX/x86_64 assembler implementation of SM4
      block cipher. Through two affine transforms, we can use the AES S-Box
      to simulate the SM4 S-Box to achieve the effect of instruction
      acceleration.
      
      The main algorithm implementation comes from SM4 AES-NI work by
      libgcrypt and Markku-Juhani O. Saarinen at:
      https://github.com/mjosaarinen/sm4ni
      
      
      
      This optimization supports the four modes of SM4, ECB, CBC, CFB, and
      CTR. Since CBC and CFB do not support multiple block parallel
      encryption, the optimization effect is not obvious.
      
      Benchmark on Intel Xeon Cascadelake, the data comes from the 218 mode
      and 518 mode of tcrypt. The abscissas are blocks of different lengths.
      The data is tabulated and the unit is Mb/s:
      
      sm4-generic   |    16      64     128     256    1024    1420    4096
            ECB enc | 40.99   46.50   48.05   48.41   49.20   49.25   49.28
            ECB dec | 41.07   46.99   48.15   48.67   49.20   49.25   49.29
            CBC enc | 37.71   45.28   46.77   47.60   48.32   48.37   48.40
            CBC dec | 36.48   44.82   46.43   47.45   48.23   48.30   48.36
            CFB enc | 37.94   44.84   46.12   46.94   47.57   47.46   47.68
            CFB dec | 37.50   42.84   43.74   44.37   44.85   44.80   44.96
            CTR enc | 39.20   45.63   46.75   47.49   48.09   47.85   48.08
            CTR dec | 39.64   45.70   46.72   47.47   47.98   47.88   48.06
      sm4-aesni-avx
            ECB enc | 33.75  134.47  221.64  243.43  264.05  251.58  258.13
            ECB dec | 34.02  134.92  223.11  245.14  264.12  251.04  258.33
            CBC enc | 38.85   46.18   47.67   48.34   49.00   48.96   49.14
            CBC dec | 33.54  131.29  223.88  245.27  265.50  252.41  263.78
            CFB enc | 38.70   46.10   47.58   48.29   49.01   48.94   49.19
            CFB dec | 32.79  128.40  223.23  244.87  265.77  253.31  262.79
            CTR enc | 32.58  122.23  220.29  241.16  259.57  248.32  256.69
            CTR dec | 32.81  122.47  218.99  241.54  258.42  248.58  256.61
      
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      a7ee22ee
    • Tianjia Zhang's avatar
      crypto: arm64/sm4-ce - Make dependent on sm4 library instead of sm4-generic · c59de48e
      Tianjia Zhang authored
      
      SM4 library is abstracted from sm4-generic algorithm, sm4-ce can depend on
      the SM4 library instead of sm4-generic, and some functions in sm4-generic
      do not need to be exported.
      
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c59de48e
    • Tianjia Zhang's avatar
      crypto: sm4 - create SM4 library based on sm4 generic code · 2b31277a
      Tianjia Zhang authored
      
      Take the existing small footprint and mostly time invariant C code
      and turn it into a SM4 library that can be used for non-performance
      critical, casual use of SM4, and as a fallback for, e.g., SIMD code
      that needs a secondary path that can be taken in contexts where the
      SIMD unit is off limits.
      
      Secondly, some codes have been optimized, such as unrolling small
      times loop, removing unnecessary memory shifts, exporting sbox, fk,
      ck arrays, and basic encryption and decryption functions.
      
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      2b31277a
  15. Jul 16, 2021
  16. Jun 28, 2021
  17. Jun 24, 2021
  18. Jun 17, 2021
  19. Jun 11, 2021
  20. Jun 03, 2021
  21. May 28, 2021
Loading