1. 02 6月, 2009 15 次提交
  2. 31 5月, 2009 1 次提交
  3. 21 4月, 2009 1 次提交
  4. 15 4月, 2009 1 次提交
  5. 31 3月, 2009 1 次提交
  6. 27 3月, 2009 1 次提交
  7. 26 3月, 2009 2 次提交
  8. 04 3月, 2009 5 次提交
  9. 26 2月, 2009 1 次提交
    • H
      crypto: api - Fix module load deadlock with fallback algorithms · a760a665
      Herbert Xu 提交于
      With the mandatory algorithm testing at registration, we have
      now created a deadlock with algorithms requiring fallbacks.
      This can happen if the module containing the algorithm requiring
      fallback is loaded first, without the fallback module being loaded
      first.  The system will then try to test the new algorithm, find
      that it needs to load a fallback, and then try to load that.
      
      As both algorithms share the same module alias, it can attempt
      to load the original algorithm again and block indefinitely.
      
      As algorithms requiring fallbacks are a special case, we can fix
      this by giving them a different module alias than the rest.  Then
      it's just a matter of using the right aliases according to what
      algorithms we're trying to find.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      a760a665
  10. 19 2月, 2009 4 次提交
    • L
      crypto: ahash - Fix digest size in /proc/crypto · bb402f16
      Lee Nipper 提交于
      crypto_ahash_show changed to use cra_ahash for digestsize reference.
      Signed-off-by: NLee Nipper <lee.nipper@freescale.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      bb402f16
    • H
      crypto: chainiv - Use kcrypto_wq instead of keventd_wq · 0a2e821d
      Huang Ying 提交于
      keventd_wq has potential starvation problem, so use dedicated
      kcrypto_wq instead.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      0a2e821d
    • H
      crypto: cryptd - Per-CPU thread implementation based on kcrypto_wq · 254eff77
      Huang Ying 提交于
      Original cryptd thread implementation has scalability issue, this
      patch solve the issue with a per-CPU thread implementation.
      
      struct cryptd_queue is defined to be a per-CPU queue, which holds one
      struct cryptd_cpu_queue for each CPU. In struct cryptd_cpu_queue, a
      struct crypto_queue holds all requests for the CPU, a struct
      work_struct is used to run all requests for the CPU.
      
      Testing based on dm-crypt on an Intel Core 2 E6400 (two cores) machine
      shows 19.2% performance gain. The testing script is as follow:
      
      -------------------- script begin ---------------------------
      #!/bin/sh
      
      dmc_create()
      {
              # Create a crypt device using dmsetup
              dmsetup create $2 --table "0 `blockdev --getsize $1` crypt cbc(aes-asm)?cryptd?plain:plain babebabebabebabebabebabebabebabe 0 $1 0"
      }
      
      dmsetup remove crypt0
      dmsetup remove crypt1
      
      dd if=/dev/zero of=/dev/ram0 bs=1M count=4 >& /dev/null
      dd if=/dev/zero of=/dev/ram1 bs=1M count=4 >& /dev/null
      
      dmc_create /dev/ram0 crypt0
      dmc_create /dev/ram1 crypt1
      
      cat >tr.sh <<EOF
      #!/bin/sh
      
      for n in \$(seq 10); do
              dd if=/dev/dm-0 of=/dev/null >& /dev/null &
              dd if=/dev/dm-1 of=/dev/null >& /dev/null &
      done
      wait
      EOF
      
      for n in $(seq 10); do
              /usr/bin/time sh tr.sh
      done
      rm tr.sh
      -------------------- script end   ---------------------------
      
      The separator of dm-crypt parameter is changed from "-" to "?", because
      "-" is used in some cipher driver name too, and cryptds need to specify
      cipher driver name instead of cipher name.
      
      The test result on an Intel Core2 E6400 (two cores) is as follow:
      
      without patch:
      -----------------wo begin --------------------------
      0.04user 0.38system 0:00.39elapsed 107%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6566minor)pagefaults 0swaps
      0.07user 0.35system 0:00.35elapsed 121%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6567minor)pagefaults 0swaps
      0.06user 0.34system 0:00.30elapsed 135%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6562minor)pagefaults 0swaps
      0.05user 0.37system 0:00.36elapsed 119%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6607minor)pagefaults 0swaps
      0.06user 0.36system 0:00.35elapsed 120%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6562minor)pagefaults 0swaps
      0.05user 0.37system 0:00.31elapsed 136%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6594minor)pagefaults 0swaps
      0.04user 0.34system 0:00.30elapsed 126%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6597minor)pagefaults 0swaps
      0.06user 0.32system 0:00.31elapsed 125%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6571minor)pagefaults 0swaps
      0.06user 0.34system 0:00.31elapsed 134%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6581minor)pagefaults 0swaps
      0.05user 0.38system 0:00.31elapsed 138%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6600minor)pagefaults 0swaps
      -----------------wo end   --------------------------
      
      
      with patch:
      ------------------w begin --------------------------
      0.02user 0.31system 0:00.24elapsed 141%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6554minor)pagefaults 0swaps
      0.05user 0.34system 0:00.31elapsed 127%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6606minor)pagefaults 0swaps
      0.07user 0.33system 0:00.26elapsed 155%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6559minor)pagefaults 0swaps
      0.07user 0.32system 0:00.26elapsed 151%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6562minor)pagefaults 0swaps
      0.05user 0.34system 0:00.26elapsed 150%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6603minor)pagefaults 0swaps
      0.03user 0.36system 0:00.31elapsed 124%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6562minor)pagefaults 0swaps
      0.04user 0.35system 0:00.26elapsed 147%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6586minor)pagefaults 0swaps
      0.03user 0.37system 0:00.27elapsed 146%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6562minor)pagefaults 0swaps
      0.04user 0.36system 0:00.26elapsed 154%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6594minor)pagefaults 0swaps
      0.04user 0.35system 0:00.26elapsed 154%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+6557minor)pagefaults 0swaps
      ------------------w end   --------------------------
      
      The middle value of elapsed time is:
      wo cryptwq: 0.31
      w  cryptwq: 0.26
      
      The performance gain is about (0.31-0.26)/0.26 = 0.192.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      254eff77
    • H
      crypto: api - Use dedicated workqueue for crypto subsystem · 25c38d3f
      Huang Ying 提交于
      Use dedicated workqueue for crypto subsystem
      
      A dedicated workqueue named kcrypto_wq is created to be used by crypto
      subsystem. The system shared keventd_wq is not suitable for
      encryption/decryption, because of potential starvation problem.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      25c38d3f
  11. 18 2月, 2009 8 次提交
    • H
      crypto: testmgr - Test skciphers with no IVs · 6fe4a28d
      Herbert Xu 提交于
      As it is an skcipher with no IV escapes testing altogether because
      we only test givcipher objects.  This patch fixes the bypass logic
      to test these algorithms.
      
      Conversely, we're currently testing nivaead algorithms with IVs,
      which would have deadlocked had it not been for the fact that no
      nivaead algorithms have any test vectors.  This patch also fixes
      that case.
      
      Both fixes are ugly as hell, but this ugliness should hopefully
      disappear once we move them into the per-type code (i.e., the
      AEAD test would live in aead.c and the skcipher stuff in ablkcipher.c).
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      6fe4a28d
    • H
      crypto: aead - Avoid infinite loop when nivaead fails selftest · 5852ae42
      Herbert Xu 提交于
      When an aead constructed through crypto_nivaead_default fails
      its selftest, we'll loop forever trying to construct new aead
      objects but failing because it already exists.
      
      The crux of the issue is that once an aead fails the selftest,
      we'll ignore it on the next run through crypto_aead_lookup and
      attempt to construct a new aead.
      
      We should instead return an error to the caller if we find an
      an that has failed the test.
      
      This bug hasn't manifested itself yet because we don't have any
      test vectors for the existing nivaead algorithms.  They're tested
      through the underlying algorithms only.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      5852ae42
    • H
      crypto: skcipher - Avoid infinite loop when cipher fails selftest · b170a137
      Herbert Xu 提交于
      When an skcipher constructed through crypto_givcipher_default fails
      its selftest, we'll loop forever trying to construct new skcipher
      objects but failing because it already exists.
      
      The crux of the issue is that once a givcipher fails the selftest,
      we'll ignore it on the next run through crypto_skcipher_lookup and
      attempt to construct a new givcipher.
      
      We should instead return an error to the caller if we find a
      givcipher that has failed the test.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      b170a137
    • H
      crypto: api - Fix crypto_alloc_tfm/create_create_tfm return convention · 3f683d61
      Herbert Xu 提交于
      This is based on a report and patch by Geert Uytterhoeven.
      
      The functions crypto_alloc_tfm and create_create_tfm return a
      pointer that needs to be adjusted by the caller when successful
      and otherwise an error value.  This means that the caller has
      to check for the error and only perform the adjustment if the
      pointer returned is valid.
      
      Since all callers want to make the adjustment and we know how
      to adjust it ourselves, it's much easier to just return adjusted
      pointer directly.
      
      The only caveat is that we have to return a void * instead of
      struct crypto_tfm *.  However, this isn't that bad because both
      of these functions are for internal use only (by types code like
      shash.c, not even algorithms code).
      
      This patch also moves crypto_alloc_tfm into crypto/internal.h
      (crypto_create_tfm is already there) to reflect this.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      3f683d61
    • H
      crypto: api - crypto_alg_mod_lookup either tested or untested · ff753308
      Herbert Xu 提交于
      As it stands crypto_alg_mod_lookup will search either tested or
      untested algorithms, but never both at the same time.  However,
      we need exactly that when constructing givcipher and aead so
      this patch adds support for that by setting the tested bit in
      type but clearing it in mask.  This combination is currently
      unused.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ff753308
    • N
      crypto: ansi_cprng - Panic on CPRNG test failure when in FIPS mode · c5b1e545
      Neil Horman 提交于
      FIPS 140-2 specifies that all access to various cryptographic modules be
      prevented in the event that any of the provided self tests fail on the various
      implemented algorithms.  We already panic when any of the test in testmgr.c
      fail when we are operating in fips mode.  The continuous test in the cprng here
      was missed when that was implmented.  This code simply checks for the
      fips_enabled flag if the test fails, and warns us via syslog or panics the box
      accordingly.
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      c5b1e545
    • N
      crypto: ansi_cprng - Force reset on allocation · d7992f42
      Neil Horman 提交于
      Pseudo RNGs provide predictable outputs based on input parateters {key, V, DT},
      the idea behind them is that only the user should know what the inputs are.
      While its nice to have default known values for testing purposes, it seems
      dangerous to allow the use of those default values without some sort of safety
      measure in place, lest an attacker easily guess the output of the cprng.  This
      patch forces the NEED_RESET flag on when allocating a cprng context, so that any
      user is forced to reseed it before use.  The defaults can still be used for
      testing, but this will prevent their inadvertent use, and be more secure.
      Signed-off-by: NNeil Horman <nhorman@redhat.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      d7992f42
    • H
      crypto: aes-ni - Add support to Intel AES-NI instructions for x86_64 platform · 54b6a1bd
      Huang Ying 提交于
      Intel AES-NI is a new set of Single Instruction Multiple Data (SIMD)
      instructions that are going to be introduced in the next generation of
      Intel processor, as of 2009. These instructions enable fast and secure
      data encryption and decryption, using the Advanced Encryption Standard
      (AES), defined by FIPS Publication number 197.  The architecture
      introduces six instructions that offer full hardware support for
      AES. Four of them support high performance data encryption and
      decryption, and the other two instructions support the AES key
      expansion procedure.
      
      The white paper can be downloaded from:
      
      http://softwarecommunity.intel.com/isn/downloads/intelavx/AES-Instructions-Set_WP.pdf
      
      AES may be used in soft_irq context, but MMX/SSE context can not be
      touched safely in soft_irq context. So in_interrupt() is checked, if
      in IRQ or soft_irq context, the general x86_64 implementation are used
      instead.
      Signed-off-by: NHuang Ying <ying.huang@intel.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      54b6a1bd