09 Nov, 2018

3 commits

  • For preventing uninitialized data to be given to user-space (and so leak
    potential useful data), the crypto_stat structure must be correctly
    initialized.

    Reported-by: Dan Carpenter
    Fixes: cac5818c25d0 ("crypto: user - Implement a generic crypto statistics")
    Signed-off-by: Corentin Labbe
    [EB: also fix it in crypto_reportstat_one()]
    [EB: use sizeof(var) rather than sizeof(type)]
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Corentin Labbe
     
  • All bytes of the NETLINK_CRYPTO report structures must be initialized,
    since they are copied to userspace. The change from strncpy() to
    strlcpy() broke this. As a minimal fix, change it back.

    Fixes: 4473710df1f8 ("crypto: user - Prepare for CRYPTO_MAX_ALG_NAME expansion")
    Cc: # v4.12+
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • The simd wrapper's skcipher request context structure consists
    of a single subrequest whose size is taken from the subordinate
    skcipher. However, in simd_skcipher_init(), the reqsize that is
    retrieved is not from the subordinate skcipher but from the
    cryptd request structure, whose size is completely unrelated to
    the actual wrapped skcipher.

    Reported-by: Qian Cai
    Signed-off-by: Ard Biesheuvel
    Tested-by: Qian Cai
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

26 Oct, 2018

20 commits

  • The sign operation can operate in a non-hashed mode by running the RSA
    sign operation directly on the input. This assumes that the input is
    less than key_size_in_bytes - 11. Since the TPM performs its own PKCS1
    padding, it isn't possible to support 'raw' mode, only 'pkcs1'.

    Alternatively, a hashed version is also possible. In this variant the
    input is hashed (by userspace) via the selected hash function first.
    Then this implementation takes care of converting the hash to ASN.1
    format and the sign operation is performed on the result. This is
    similar to the implementation inside crypto/rsa-pkcs1pad.c.

    ASN1 templates were copied from crypto/rsa-pkcs1pad.c. There seems to
    be no easy way to expose that functionality, but likely the templates
    should be shared somehow.

    The sign operation is implemented via TPM_Sign operation on the TPM.
    It is assumed that the TPM wrapped key provided uses
    TPM_SS_RSASSAPKCS1v15_DER signature scheme. This allows the TPM_Sign
    operation to work on data up to key_len_in_bytes - 11 bytes long.

    In theory, we could also use TPM_Unbind instead of TPM_Sign, but we would
    have to manually pkcs1 pad the digest first.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This patch implements the verify_signature operation. The public key
    portion extracted from the TPM key blob is used. The operation is
    performed entirely in software using the crypto API.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This patch implements the pkey_decrypt operation using the private key
    blob. The blob is first loaded into the TPM via tpm_loadkey2. Once the
    handle is obtained, tpm_unbind operation is used to decrypt the data on
    the TPM and the result is returned. The key loaded by tpm_loadkey2 is
    then evicted via tpm_flushspecific operation.

    This patch assumes that the SRK authorization is a well known 20-byte of
    zeros and the same holds for the key authorization of the provided key.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • Signed-off-by: Denis Kenzior
    Reviewed-by: James Morris
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This commit adds TPM_LoadKey2 and TPM_FlushSpecific operations.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Reviewed-by: James Morris
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This patch exposes some common functionality needed to send TPM commands.
    Several functions from keys/trusted.c are exposed for use by the new tpm
    key subtype and a module dependency is introduced.

    In the future, common functionality between the trusted key type and the
    asym_tpm subtype should be factored out into a common utility library.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This patch impelements the pkey_encrypt operation. The public key
    portion extracted from the TPM key blob is used. The operation is
    performed entirely in software using the crypto API.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This commit implements the pkey_query operation. This is accomplished
    by utilizing the public key portion to obtain max encryption size
    information for the operations that utilize the public key (encrypt,
    verify). The private key size extracted from the TPM_Key data structure
    is used to fill the information where the private key is used (decrypt,
    sign).

    The kernel uses a DER/BER format for public keys and does not support
    setting the key via the raw binary form. To get around this a simple
    DER/BER formatter is implemented which stores the DER/BER formatted key
    and exponent in a temporary buffer for use by the crypto API.

    The only exponent supported currently is 65537. This holds true for
    other Linux TPM tools such as 'create_tpm_key' and
    trousers-openssl_tpm_engine.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • For TPM based keys, the only standard seems to be described here:
    http://david.woodhou.se/draft-woodhouse-cert-best-practice.html#rfc.section.4.4

    Quote from the relevant section:
    "Rather, a common form of storage for "wrapped" keys is to encode the
    binary TCPA_KEY structure in a single ASN.1 OCTET-STRING, and store the
    result in PEM format with the tag "-----BEGIN TSS KEY BLOB-----". "

    This patch implements the above behavior. It is assumed that the PEM
    encoding is stripped out by userspace and only the raw DER/BER format is
    provided. This is similar to how PKCS7, PKCS8 and X.509 keys are
    handled.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • The parsed BER/DER blob obtained from user space contains a TPM_Key
    structure. This structure has some information about the key as well as
    the public key portion.

    This patch extracts this information for future use.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • This patch adds the basic skeleton for the asym_tpm asymmetric key
    subtype.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • The original pkcs1pad implementation allowed to pad/unpad raw RSA
    output. However, this has been taken out in commit:
    commit c0d20d22e0ad ("crypto: rsa-pkcs1pad - Require hash to be present")

    This patch restored this ability as it is needed by the asymmetric key
    implementation.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     
  • Implement PKCS#8 RSA Private Key format [RFC 5208] parser for the
    asymmetric key type. For the moment, this will only support unencrypted
    DER blobs. PEM and decryption can be added later.

    PKCS#8 keys can be loaded like this:

    openssl pkcs8 -in private_key.pem -topk8 -nocrypt -outform DER | \
    keyctl padd asymmetric foo @s

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Implement the encrypt, decrypt and sign operations for the software
    asymmetric key subtype. This mostly involves offloading the call to the
    crypto layer.

    Note that the decrypt and sign operations require a private key to be
    supplied. Encrypt (and also verify) will work with either a public or a
    private key. A public key can be supplied with an X.509 certificate and a
    private key can be supplied using a PKCS#8 blob:

    # j=`openssl pkcs8 -in ~/pkcs7/firmwarekey2.priv -topk8 -nocrypt -outform DER | keyctl padd asymmetric foo @s`
    # keyctl pkey_query $j - enc=pkcs1
    key_size=4096
    max_data_size=512
    max_sig_size=512
    max_enc_size=512
    max_dec_size=512
    encrypt=y
    decrypt=y
    sign=y
    verify=y
    # keyctl pkey_encrypt $j 0 data enc=pkcs1 >/tmp/enc
    # keyctl pkey_decrypt $j 0 /tmp/enc enc=pkcs1 >/tmp/dec
    # cmp data /tmp/dec
    # keyctl pkey_sign $j 0 data enc=pkcs1 hash=sha1 >/tmp/sig
    # keyctl pkey_verify $j 0 data /tmp/sig enc=pkcs1 hash=sha1
    #

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Put a flag in the public_key struct to indicate if the structure is holding
    a private key. The private key must be held ASN.1 encoded in the format
    specified in RFC 3447 A.1.2. This is the form required by crypto/rsa.c.

    The software encryption subtype's verification and query functions then
    need to select the appropriate crypto function to set the key.

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Provide a query function for the software public key implementation. This
    permits information about such a key to be obtained using
    query_asymmetric_key() or KEYCTL_PKEY_QUERY.

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Make the X.509 and PKCS7 parsers fill in the signature encoding type field
    recently added to the public_key_signature struct.

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Provide the missing asymmetric key subops for new key type ops. This
    include query, encrypt, decrypt and create signature. Verify signature
    already exists. Also provided are accessor functions for this:

    int query_asymmetric_key(const struct key *key,
    struct kernel_pkey_query *info);

    int encrypt_blob(struct kernel_pkey_params *params,
    const void *data, void *enc);
    int decrypt_blob(struct kernel_pkey_params *params,
    const void *enc, void *data);
    int create_signature(struct kernel_pkey_params *params,
    const void *data, void *enc);

    The public_key_signature struct gains an encoding field to carry the
    encoding for verify_signature().

    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Reviewed-by: Denis Kenzior
    Tested-by: Denis Kenzior
    Signed-off-by: James Morris

    David Howells
     
  • Pull crypto updates from Herbert Xu:
    "API:
    - Remove VLA usage
    - Add cryptostat user-space interface
    - Add notifier for new crypto algorithms

    Algorithms:
    - Add OFB mode
    - Remove speck

    Drivers:
    - Remove x86/sha*-mb as they are buggy
    - Remove pcbc(aes) from x86/aesni
    - Improve performance of arm/ghash-ce by up to 85%
    - Implement CTS-CBC in arm64/aes-blk, faster by up to 50%
    - Remove PMULL based arm64/crc32 driver
    - Use PMULL in arm64/crct10dif
    - Add aes-ctr support in s5p-sss
    - Add caam/qi2 driver

    Others:
    - Pick better transform if one becomes available in crc-t10dif"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (124 commits)
    crypto: chelsio - Update ntx queue received from cxgb4
    crypto: ccree - avoid implicit enum conversion
    crypto: caam - add SPDX license identifier to all files
    crypto: caam/qi - simplify CGR allocation, freeing
    crypto: mxs-dcp - make symbols 'sha1_null_hash' and 'sha256_null_hash' static
    crypto: arm64/aes-blk - ensure XTS mask is always loaded
    crypto: testmgr - fix sizeof() on COMP_BUF_SIZE
    crypto: chtls - remove set but not used variable 'csk'
    crypto: axis - fix platform_no_drv_owner.cocci warnings
    crypto: x86/aes-ni - fix build error following fpu template removal
    crypto: arm64/aes - fix handling sub-block CTS-CBC inputs
    crypto: caam/qi2 - avoid double export
    crypto: mxs-dcp - Fix AES issues
    crypto: mxs-dcp - Fix SHA null hashes and output length
    crypto: mxs-dcp - Implement sha import/export
    crypto: aegis/generic - fix for big endian systems
    crypto: morus/generic - fix for big endian systems
    crypto: lrw - fix rebase error after out of bounds fix
    crypto: cavium/nitrox - use pci_alloc_irq_vectors() while enabling MSI-X.
    crypto: cavium/nitrox - NITROX command queue changes.
    ...

    Linus Torvalds
     

24 Oct, 2018

1 commit

  • This reverts commit dd979b4df817e9976f18fb6f9d134d6bc4a3c317.

    This broke tcp_poll for SMC fallback: An AF_SMC socket establishes an
    internal TCP socket for the initial handshake with the remote peer.
    Whenever the SMC connection can not be established this TCP socket is
    used as a fallback. All socket operations on the SMC socket are then
    forwarded to the TCP socket. In case of poll, the file->private_data
    pointer references the SMC socket because the TCP socket has no file
    assigned. This causes tcp_poll to wait on the wrong socket.

    Signed-off-by: Karsten Graul
    Signed-off-by: David S. Miller

    Karsten Graul
     

12 Oct, 2018

1 commit

  • After allocation, output and decomp_output both point to memory chunks of
    size COMP_BUF_SIZE. Then, only the first bytes are zeroed out using
    sizeof(COMP_BUF_SIZE) as parameter to memset(), because
    sizeof(COMP_BUF_SIZE) provides the size of the constant and not the size of
    allocated memory.

    Instead, the whole allocated memory is meant to be zeroed out. Use
    COMP_BUF_SIZE as parameter to memset() directly in order to accomplish
    this.

    Fixes: 336073840a872 ("crypto: testmgr - Allow different compression results")

    Signed-off-by: Michael Schupikov
    Reviewed-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Michael Schupikov
     

08 Oct, 2018

2 commits

  • Use the correct __le32 annotation and accessors to perform the
    single round of AES encryption performed inside the AEGIS transform.
    Otherwise, tcrypt reports:

    alg: aead: Test 1 failed on encryption for aegis128-generic
    00000000: 6c 25 25 4a 3c 10 1d 27 2b c1 d4 84 9a ef 7f 6e
    alg: aead: Test 1 failed on encryption for aegis128l-generic
    00000000: cd c6 e3 b8 a0 70 9d 8e c2 4f 6f fe 71 42 df 28
    alg: aead: Test 1 failed on encryption for aegis256-generic
    00000000: aa ed 07 b1 96 1d e9 e6 f2 ed b5 8e 1c 5f dc 1c

    Fixes: f606a88e5823 ("crypto: aegis - Add generic AEGIS AEAD implementations")
    Cc: # v4.18+
    Signed-off-by: Ard Biesheuvel
    Reviewed-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Omit the endian swabbing when folding the lengths of the assoc and
    crypt input buffers into the state to finalize the tag. This is not
    necessary given that the memory representation of the state is in
    machine native endianness already.

    This fixes an error reported by tcrypt running on a big endian system:

    alg: aead: Test 2 failed on encryption for morus640-generic
    00000000: a8 30 ef fb e6 26 eb 23 b0 87 dd 98 57 f3 e1 4b
    00000010: 21
    alg: aead: Test 2 failed on encryption for morus1280-generic
    00000000: 88 19 1b fb 1c 29 49 0e ee 82 2f cb 97 a6 a5 ee
    00000010: 5f

    Fixes: 396be41f16fd ("crypto: morus - Add generic MORUS AEAD implementations")
    Cc: # v4.18+
    Reviewed-by: Ondrej Mosnacek
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

05 Oct, 2018

2 commits

  • Due to an unfortunate interaction between commit fbe1a850b3b1
    ("crypto: lrw - Fix out-of bounds access on counter overflow") and
    commit c778f96bf347 ("crypto: lrw - Optimize tweak computation"),
    we ended up with a version of next_index() that always returns 127.

    Fixes: c778f96bf347 ("crypto: lrw - Optimize tweak computation")
    Signed-off-by: Ard Biesheuvel
    Reviewed-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • For historical reasons, the AES-NI based implementation of the PCBC
    chaining mode uses a special FPU chaining mode wrapper template to
    amortize the FPU start/stop overhead over multiple blocks.

    When this FPU wrapper was introduced, it supported widely used
    chaining modes such as XTS and CTR (as well as LRW), but currently,
    PCBC is the only remaining user.

    Since there are no known users of pcbc(aes) in the kernel, let's remove
    this special driver, and rely on the generic pcbc driver to encapsulate
    the AES-NI core cipher.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

28 Sep, 2018

9 commits

  • We already have OFB test vectors and tcrypt OFB speed tests.
    Add OFB functional tests to tcrypt as well.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Add a generic version of output feedback mode. We already have support of
    several hardware based transformations of this mode and the needed test
    vectors but we somehow missed adding a generic software one. Fix this now.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Add additional test vectors from "The SM4 Blockcipher Algorithm And Its
    Modes Of Operations" draft-ribose-cfrg-sm4-10 and register cipher speed
    tests for sm4.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Commit 110492183c4b ("crypto: compress - remove unused pcomp interface")
    removed pcomp interface but missed cleaning up tcrypt.

    Signed-off-by: Horia Geantă
    Signed-off-by: Herbert Xu

    Horia Geantă
     
  • This patch implement a generic way to get statistics about all crypto
    usages.

    Signed-off-by: Corentin Labbe
    Signed-off-by: Herbert Xu

    Corentin Labbe
     
  • In the quest to remove all stack VLA usage from the kernel[1], this
    replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage
    with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
    which uses a fixed stack size.

    [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

    Signed-off-by: Kees Cook
    Signed-off-by: Herbert Xu

    Kees Cook
     
  • In the quest to remove all stack VLA usage from the kernel[1], this
    replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage
    with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
    which uses a fixed stack size.

    [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

    Signed-off-by: Kees Cook
    Signed-off-by: Herbert Xu

    Kees Cook
     
  • In preparation for removal of VLAs due to skcipher requests on the stack
    via SKCIPHER_REQUEST_ON_STACK() usage, this introduces the infrastructure
    for the "sync skcipher" tfm, which is for handling the on-stack cases of
    skcipher, which are always non-ASYNC and have a known limited request
    size.

    The crypto API additions:

    struct crypto_sync_skcipher (wrapper for struct crypto_skcipher)
    crypto_alloc_sync_skcipher()
    crypto_free_sync_skcipher()
    crypto_sync_skcipher_setkey()
    crypto_sync_skcipher_get_flags()
    crypto_sync_skcipher_set_flags()
    crypto_sync_skcipher_clear_flags()
    crypto_sync_skcipher_blocksize()
    crypto_sync_skcipher_ivsize()
    crypto_sync_skcipher_reqtfm()
    skcipher_request_set_sync_tfm()
    SYNC_SKCIPHER_REQUEST_ON_STACK() (with tfm type check)

    Signed-off-by: Kees Cook
    Reviewed-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Kees Cook
     
  • The encryption mode of pkcs1pad never uses out_sg and out_buf, so
    there's no need to allocate the buffer, which presently is not even
    being freed.

    CC: Herbert Xu
    CC: linux-crypto@vger.kernel.org
    CC: "David S. Miller"
    Signed-off-by: Dan Aloni
    Signed-off-by: Herbert Xu

    Dan Aloni
     

21 Sep, 2018

2 commits

  • This patch simplifies the LRW template to recompute the LRW tweaks from
    scratch in the second pass and thus also removes the need to allocate a
    dynamic buffer using kmalloc().

    As discussed at [1], the use of kmalloc causes deadlocks with dm-crypt.

    PERFORMANCE MEASUREMENTS (x86_64)
    Performed using: https://gitlab.com/omos/linux-crypto-bench
    Crypto driver used: lrw(ecb-aes-aesni)

    The results show that the new code has about the same performance as the
    old code. For 512-byte message it seems to be even slightly faster, but
    that might be just noise.

    Before:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    lrw(aes) 256 64 200 203
    lrw(aes) 320 64 202 204
    lrw(aes) 384 64 204 205
    lrw(aes) 256 512 415 415
    lrw(aes) 320 512 432 440
    lrw(aes) 384 512 449 451
    lrw(aes) 256 4096 1838 1995
    lrw(aes) 320 4096 2123 1980
    lrw(aes) 384 4096 2100 2119
    lrw(aes) 256 16384 7183 6954
    lrw(aes) 320 16384 7844 7631
    lrw(aes) 384 16384 8256 8126
    lrw(aes) 256 32768 14772 14484
    lrw(aes) 320 32768 15281 15431
    lrw(aes) 384 32768 16469 16293

    After:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    lrw(aes) 256 64 197 196
    lrw(aes) 320 64 200 197
    lrw(aes) 384 64 203 199
    lrw(aes) 256 512 385 380
    lrw(aes) 320 512 401 395
    lrw(aes) 384 512 415 415
    lrw(aes) 256 4096 1869 1846
    lrw(aes) 320 4096 2080 1981
    lrw(aes) 384 4096 2160 2109
    lrw(aes) 256 16384 7077 7127
    lrw(aes) 320 16384 7807 7766
    lrw(aes) 384 16384 8108 8357
    lrw(aes) 256 32768 14111 14454
    lrw(aes) 320 32768 15268 15082
    lrw(aes) 384 32768 16581 16250

    [1] https://lkml.org/lkml/2018/8/23/1315

    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ondrej Mosnacek
     
  • This patch rewrites the tweak computation to a slightly simpler method
    that performs less bswaps. Based on performance measurements the new
    code seems to provide slightly better performance than the old one.

    PERFORMANCE MEASUREMENTS (x86_64)
    Performed using: https://gitlab.com/omos/linux-crypto-bench
    Crypto driver used: lrw(ecb-aes-aesni)

    Before:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    lrw(aes) 256 64 204 286
    lrw(aes) 320 64 227 203
    lrw(aes) 384 64 208 204
    lrw(aes) 256 512 441 439
    lrw(aes) 320 512 456 455
    lrw(aes) 384 512 469 483
    lrw(aes) 256 4096 2136 2190
    lrw(aes) 320 4096 2161 2213
    lrw(aes) 384 4096 2295 2369
    lrw(aes) 256 16384 7692 7868
    lrw(aes) 320 16384 8230 8691
    lrw(aes) 384 16384 8971 8813
    lrw(aes) 256 32768 15336 15560
    lrw(aes) 320 32768 16410 16346
    lrw(aes) 384 32768 18023 17465

    After:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    lrw(aes) 256 64 200 203
    lrw(aes) 320 64 202 204
    lrw(aes) 384 64 204 205
    lrw(aes) 256 512 415 415
    lrw(aes) 320 512 432 440
    lrw(aes) 384 512 449 451
    lrw(aes) 256 4096 1838 1995
    lrw(aes) 320 4096 2123 1980
    lrw(aes) 384 4096 2100 2119
    lrw(aes) 256 16384 7183 6954
    lrw(aes) 320 16384 7844 7631
    lrw(aes) 384 16384 8256 8126
    lrw(aes) 256 32768 14772 14484
    lrw(aes) 320 32768 15281 15431
    lrw(aes) 384 32768 16469 16293

    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ondrej Mosnacek