Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jan 16, 2020
    • Jason A. Donenfeld's avatar
      crypto: poly1305 - add new 32 and 64-bit generic versions · 1c08a104
      Jason A. Donenfeld authored
      
      These two C implementations from Zinc -- a 32x32 one and a 64x64 one,
      depending on the platform -- come from Andrew Moon's public domain
      poly1305-donna portable code, modified for usage in the kernel. The
      precomputation in the 32-bit version and the use of 64x64 multiplies in
      the 64-bit version make these perform better than the code it replaces.
      Moon's code is also very widespread and has received many eyeballs of
      scrutiny.
      
      There's a bit of interference between the x86 implementation, which
      relies on internal details of the old scalar implementation. In the next
      commit, the x86 implementation will be replaced with a faster one that
      doesn't rely on this, so none of this matters much. But for now, to keep
      this passing the tests, we inline the bits of the old implementation
      that the x86 implementation relied on. Also, since we now support a
      slightly larger key space, via the union, some offsets had to be fixed
      up.
      
      Nonce calculation was folded in with the emit function, to take
      advantage of 64x64 arithmetic. However, Adiantum appeared to rely on no
      nonce handling in emit, so this path was conditionalized. We also
      introduced a new struct, poly1305_core_key, to represent the precise
      amount of space that particular implementation uses.
      
      Testing with kbench9000, depending on the CPU, the update function for
      the 32x32 version has been improved by 4%-7%, and for the 64x64 by
      19%-30%. The 32x32 gains are small, but I think there's great value in
      having a parallel implementation to the 64x64 one so that the two can be
      compared side-by-side as nice stand-alone units.
      
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      1c08a104
  2. Nov 16, 2019
  3. Apr 18, 2019
    • Eric Biggers's avatar
      crypto: run initcalls for generic implementations earlier · c4741b23
      Eric Biggers authored
      
      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: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c4741b23
  4. Dec 13, 2018
    • Eric Biggers's avatar
      crypto: adiantum - adjust some comments to match latest paper · c6018e1a
      Eric Biggers authored
      
      The 2018-11-28 revision of the Adiantum paper has revised some notation:
      
      - 'M' was replaced with 'L' (meaning "Left", for the left-hand part of
        the message) in the definition of Adiantum hashing, to avoid confusion
        with the full message
      - ε-almost-∆-universal is now abbreviated as ε-∆U instead of εA∆U
      - "block" is now used only to mean block cipher and Poly1305 blocks
      
      Also, Adiantum hashing was moved from the appendix to the main paper.
      
      To avoid confusion, update relevant comments in the code to match.
      
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      c6018e1a
  5. Nov 20, 2018