GitHub/LineageOS/android_kernel_motorola_exynos9610.git
7 years agocrypto: sun4i-ss - fix large block size support
Antoine Ténart [Thu, 1 Jun 2017 19:39:03 +0000 (21:39 +0200)]
crypto: sun4i-ss - fix large block size support

The run-time self-tests fail quite early, as soon as the input block
size is larger than 64 bytes:

  alg: hash: Test 4 failed for sha1-sun4i-ss
  00000000: b9 c9 1e 52 c0 26 d8 39 81 ff f2 3c 99 b1 27 b2
  00000010: 30 d6 c9 85

One thing to notice is the value of the last word, which is the one
expected (it can sometime be the last two words). The datasheet isn't
very clear about when the digest is ready to retrieve and is seems the
bit SS_DATA_END is cleared when the digest was computed *but* that
doesn't mean the digest is ready to retrieve in the registers.

A ndelay(1) is added before reading the computed digest to ensure it is
available in the SS_MD[] registers.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - add the CRYPTO_ALG_KERN_DRIVER_ONLY flag
Antoine Ténart [Thu, 1 Jun 2017 19:39:02 +0000 (21:39 +0200)]
crypto: sun4i-ss - add the CRYPTO_ALG_KERN_DRIVER_ONLY flag

The CRYPTO_ALG_KERN_DRIVER_ONLY flag is set for hardware accelerated
ciphers accessible through a kernel driver only. This is the case for
ciphers exposed by the sun4i-ss driver. This patch sets this flag.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - move from ablkcipher to skcipher API
Antoine Ténart [Thu, 1 Jun 2017 19:39:01 +0000 (21:39 +0200)]
crypto: sun4i-ss - move from ablkcipher to skcipher API

Update the sun4i-ss driver to use the skcipher API instead of the old
ablkcipher one. It's a bit more tricky than s/ablkcipher/skcipher/, but
still nothing special and the driver's logic stays the same.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - use GENMASK to generate masks
Antoine Ténart [Thu, 1 Jun 2017 19:39:00 +0000 (21:39 +0200)]
crypto: sun4i-ss - use GENMASK to generate masks

Use the GENMASK helper instead of custom calculations to generate masks,
It also helps the readability.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - simplify the appended bit assignment
Antoine Ténart [Thu, 1 Jun 2017 19:38:59 +0000 (21:38 +0200)]
crypto: sun4i-ss - simplify the appended bit assignment

A bit is appended at the end of the input buffer for sha1. Simplify the
code assigning it.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - simplify the pad length calculation
Antoine Ténart [Thu, 1 Jun 2017 19:38:58 +0000 (21:38 +0200)]
crypto: sun4i-ss - simplify the pad length calculation

When sending the last block of data to the engine, it should be padded
so that the total length of the request can be given to the engine as
the last 2 words of the last 64 bytes block.

Simplify the calculation of this pad offset.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - do not dynamically set parts of the last buffer to 0
Antoine Ténart [Thu, 1 Jun 2017 19:38:57 +0000 (21:38 +0200)]
crypto: sun4i-ss - do not dynamically set parts of the last buffer to 0

Parts of the bf buffer were dynamically set to 0. Change this to set the
whole buffer to 0 by default to avoid any mistake.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - cannot use DMA is the request is 0 length
Antoine Ténart [Thu, 1 Jun 2017 19:38:56 +0000 (21:38 +0200)]
crypto: sun4i-ss - cannot use DMA is the request is 0 length

Do not use DMA is the request is 0 length.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - use lower/upper_32_bits helpers
Antoine Ténart [Thu, 1 Jun 2017 19:38:55 +0000 (21:38 +0200)]
crypto: sun4i-ss - use lower/upper_32_bits helpers

Replace custom bit shifts and masks with lower/upper_32_bits helpers.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - remove conditional checks against 0
Antoine Ténart [Thu, 1 Jun 2017 19:38:54 +0000 (21:38 +0200)]
crypto: sun4i-ss - remove conditional checks against 0

Cosmetic clean up if conditional checks on 0s values.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sun4i-ss - group variable definitions in sun4i_hash()
Antoine Ténart [Thu, 1 Jun 2017 19:38:53 +0000 (21:38 +0200)]
crypto: sun4i-ss - group variable definitions in sun4i_hash()

Cosmetic change to avoid having a full screen a variable definitions. It
also helps to see which variables share the same type.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: algapi - Use pr_err common logging style.
Karim Eshapa [Sat, 13 May 2017 19:05:19 +0000 (21:05 +0200)]
crypto: algapi - Use pr_err common logging style.

Use more common error logging style.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: doc - Fixed bugs, added example usage of calc_hash().
Kamil Konieczny [Fri, 12 May 2017 15:38:02 +0000 (17:38 +0200)]
crypto: doc - Fixed bugs, added example usage of calc_hash().

- Fixed bugs in example for shash and rng (added missing "*" and " *").
- Corrected pr_info() in calc_hash().
- Added example usage of calc_hash().
- No need for negate PTR_ERR to get error code, as crypto_alloc_rng
  already returns negative values like ERR_PTR(-ENOMEM). Fixed.

Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: glue_helper - Delete some dead code
Dan Carpenter [Wed, 10 May 2017 05:52:26 +0000 (08:52 +0300)]
crypto: glue_helper - Delete some dead code

We checked (nbytes < bsize) inside the loops so it's not possible to hit
the "goto done;" here.  This code is cut and paste from other slightly
different loops where we don't have the check inside the loop.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aes_ti - fix comment for MixColumns step
Eric Biggers [Wed, 10 May 2017 00:20:27 +0000 (17:20 -0700)]
crypto: aes_ti - fix comment for MixColumns step

mix_columns() contains a comment which shows the matrix used by the
MixColumns step of AES, but the last entry in this matrix was incorrect

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: mediatek - drop .owner field in mtk_crypto_driver
Geliang Tang [Sat, 6 May 2017 15:35:29 +0000 (23:35 +0800)]
crypto: mediatek - drop .owner field in mtk_crypto_driver

Drop .owner field in mtk_crypto_driver, since platform_driver_register()
will set it automatically.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Add more algorithms
George Cherian [Thu, 4 May 2017 11:34:46 +0000 (11:34 +0000)]
crypto: cavium - Add more algorithms

Add more algorithm support for the driver.
Add support for ecb(aes), cfb(aes) and ecb(des3_ede).

Signed-off-by: George Cherian <george.cherian@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Remove the individual encrypt/decrypt function for each algorithm
George Cherian [Thu, 4 May 2017 11:34:45 +0000 (11:34 +0000)]
crypto: cavium - Remove the individual encrypt/decrypt function for each algorithm

Remove the individual encrypt/decrypt function for easch algorithm.
This is in prepration of adding more crypto algorithms supported by
hardware. While at that simplify create_ctx_hdr/create_input_list
function interfaces.

Signed-off-by: George Cherian <george.cherian@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Downgrade the annoying misc interrupt print from dev_err to dev_dbg
George Cherian [Thu, 4 May 2017 11:34:44 +0000 (11:34 +0000)]
crypto: cavium - Downgrade the annoying misc interrupt print from dev_err to dev_dbg

Mailbox interrupt is common and it is not an error interrupt.
So downgrade the print from dev_err to  dev_dbg.

Signed-off-by: George Cherian <george.cherian@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ccp - return NULL instead of 0
pjambhlekar [Wed, 3 May 2017 04:02:09 +0000 (09:32 +0530)]
crypto: ccp - return NULL instead of 0

This change is to handle sparse warning. Return type of function is a pointer to the structure and
it returns 0. Instead it should return NULL.

Signed-off-by: Pushkar Jambhlekar <pushkar.iit@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ccp - Add debugfs entries for CCP information
Gary R Hook [Tue, 2 May 2017 22:33:40 +0000 (17:33 -0500)]
crypto: ccp - Add debugfs entries for CCP information

Expose some data about the configuration and operation of the CCP
through debugfs entries: device name, capabilities, configuration,
statistics.

Allow the user to reset the counters to zero by writing (any value)
to the 'stats' file. This can be done per queue or per device.

Changes from V1:
 - Correct polarity of test when destroying devices at module unload

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: talitos - Extend max key length for SHA384/512-HMAC and AEAD
Martin Hicks [Tue, 2 May 2017 13:38:35 +0000 (09:38 -0400)]
crypto: talitos - Extend max key length for SHA384/512-HMAC and AEAD

An updated patch that also handles the additional key length requirements
for the AEAD algorithms.

The max keysize is not 96.  For SHA384/512 it's 128, and for the AEAD
algorithms it's longer still.  Extend the max keysize for the
AEAD size for AES256 + HMAC(SHA512).

Cc: <stable@vger.kernel.org> # 3.6+
Fixes: 357fb60502ede ("crypto: talitos - add sha224, sha384 and sha512 to existing AEAD algorithms")
Signed-off-by: Martin Hicks <mort@bork.org>
Acked-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agodt-bindings: crypto: remove mediatek ethif clock
Ryder Lee [Thu, 1 Jun 2017 02:30:22 +0000 (10:30 +0800)]
dt-bindings: crypto: remove mediatek ethif clock

This patch removes the parent clock 'ethif' in bindings, since we don't
need to control the parent of a clock in current clock framework.

Moreover, the clocks are get by name in the driver, thus this change
does not break backwards compatibility.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: mediatek - remove redundant clock setting
Ryder Lee [Thu, 1 Jun 2017 02:30:21 +0000 (10:30 +0800)]
crypto: mediatek - remove redundant clock setting

This patch removes redundant clock setting for 'clk_ethif', which is
the parent of 'clk_cryp'. Hence, we just need to handle its child.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: testmgr - add genkey kpp test
Tudor-Dan Ambarus [Tue, 30 May 2017 14:52:49 +0000 (17:52 +0300)]
crypto: testmgr - add genkey kpp test

The test considers a party that already has a private-public
key pair and a party that provides a NULL key. The kernel will
generate the private-public key pair for the latter, computes
the shared secret on both ends and verifies if it's the same.

The explicit private-public key pair was copied from
the previous test vector.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ecdh - add privkey generation support
Tudor-Dan Ambarus [Tue, 30 May 2017 14:52:48 +0000 (17:52 +0300)]
crypto: ecdh - add privkey generation support

Add support for generating ecc private keys.

Generation of ecc private keys is helpful in a user-space to kernel
ecdh offload because the keys are not revealed to user-space. Private
key generation is also helpful to implement forward secrecy.

If the user provides a NULL ecc private key, the kernel will generate it
and further use it for ecdh.

Move ecdh's object files below drbg's. drbg must be present in the kernel
at the time of calling.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Stephan Müller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Register the CNN55XX supported crypto algorithms.
Srikanth Jampala [Tue, 30 May 2017 11:58:03 +0000 (17:28 +0530)]
crypto: cavium - Register the CNN55XX supported crypto algorithms.

Register the Symmetric crypto algorithms supported by
CNN55XX driver with crypto subsystem.

The following Symmetric crypto algorithms are supported,
  - aes with cbc, ecb, cfb, xts, ctr and cts modes
  - des3_ede with cbc and ecb modes

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Add debugfs support in CNN55XX driver.
Srikanth Jampala [Tue, 30 May 2017 11:58:02 +0000 (17:28 +0530)]
crypto: cavium - Add debugfs support in CNN55XX driver.

Add debugfs support in CNN55XX Physical Function driver.
Provides hardware counters and firmware information.

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: cavium - Add support for CNN55XX adapters.
Srikanth Jampala [Tue, 30 May 2017 11:58:01 +0000 (17:28 +0530)]
crypto: cavium - Add support for CNN55XX adapters.

Add Physical Function driver support for CNN55XX crypto adapters.
CNN55XX adapters belongs to Cavium NITROX family series,
which accelerate both Symmetric and Asymmetric crypto workloads.

These adapters have crypto engines that need firmware
to become operational.

Signed-off-by: Srikanth Jampala <Jampala.Srikanth@cavium.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agoX.509: Fix error code in x509_cert_parse()
Dan Carpenter [Mon, 29 May 2017 13:26:22 +0000 (16:26 +0300)]
X.509: Fix error code in x509_cert_parse()

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: drbg - Fixes panic in wait_for_completion call
Stephan Mueller [Fri, 26 May 2017 10:12:51 +0000 (12:12 +0200)]
crypto: drbg - Fixes panic in wait_for_completion call

Initialise ctr_completion variable before use.

Signed-off-by: Harsh Jain <harshjain.prof@gmail.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: pkcs1pad - comply with crypto_akcipher_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:16 +0000 (10:18 +0300)]
crypto: pkcs1pad - comply with crypto_akcipher_maxsize()

crypto_akcipher_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

crypto_akcipher_maxsize() now returns an unsigned int.
Remove the unnecessary check.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: qat - comply with crypto_akcipher_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:15 +0000 (10:18 +0300)]
crypto: qat - comply with crypto_akcipher_maxsize()

crypto_akcipher_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: caampkc - comply with crypto_akcipher_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:14 +0000 (10:18 +0300)]
crypto: caampkc - comply with crypto_akcipher_maxsize()

crypto_akcipher_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: rsa - comply with crypto_akcipher_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:13 +0000 (10:18 +0300)]
crypto: rsa - comply with crypto_akcipher_maxsize()

crypto_akcipher_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: akcipher - assume key is already set in maxsize
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:12 +0000 (10:18 +0300)]
crypto: akcipher - assume key is already set in maxsize

As of now, crypto_akcipher_maxsize() can not be reached without
successfully setting the key for the transformation. akcipher
algorithm implementations check if the key was set and then return
the output buffer size required for the given key.

Change the return type to unsigned int and always assume that this
function is called after a successful setkey of the transformation.
akcipher algorithm implementations will remove the check if key is not NULL
and directly return the max size.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: qat - comply with crypto_kpp_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:11 +0000 (10:18 +0300)]
crypto: qat - comply with crypto_kpp_maxsize()

crypto_kpp_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ecdh - comply with crypto_kpp_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:10 +0000 (10:18 +0300)]
crypto: ecdh - comply with crypto_kpp_maxsize()

crypto_kpp_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

nbytes has no sense now, remove it and directly return the maxsize.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: dh - comply with crypto_kpp_maxsize()
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:09 +0000 (10:18 +0300)]
crypto: dh - comply with crypto_kpp_maxsize()

crypto_kpp_maxsize() asks for the output buffer size without
caring for errors. It allways assume that will be called after
a valid setkey. Comply with it and return what he wants.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: kpp - assume key is already set in maxsize
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:08 +0000 (10:18 +0300)]
crypto: kpp - assume key is already set in maxsize

As of now, crypto_kpp_maxsize() can not be reached without successfully
setting the key for the transformation. kpp algorithm implementations
check if the key was set and then return the output buffer size
required for the given key.

Change the return type to unsigned int and always assume that this
function is called after a successful setkey of the transformation.
kpp algorithm implementations will remove the check if key is not NULL
and directly return the max size.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: dh - fix memleak in setkey
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:07 +0000 (10:18 +0300)]
crypto: dh - fix memleak in setkey

setkey can be called multiple times during the existence
of the transformation object. In case of multiple setkey calls,
the old key was not freed and we leaked memory.
Free the old MPI key if any.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ecc - rename ecdh_make_pub_key()
Tudor-Dan Ambarus [Tue, 30 May 2017 12:37:56 +0000 (15:37 +0300)]
crypto: ecc - rename ecdh_make_pub_key()

Rename ecdh_make_pub_key() to ecc_make_pub_key().
ecdh_make_pub_key() is not dh specific and the reference
to dh is wrong.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ecc - remove unnecessary casts
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:05 +0000 (10:18 +0300)]
crypto: ecc - remove unnecessary casts

ecc software implementation works with chunks of u64 data. There were some
unnecessary casts to u8 and then back to u64 for the ecc keys. This patch
removes the unnecessary casts.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ecc - remove unused function arguments
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:04 +0000 (10:18 +0300)]
crypto: ecc - remove unused function arguments

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: kpp, (ec)dh - fix typos
Tudor-Dan Ambarus [Thu, 25 May 2017 07:18:03 +0000 (10:18 +0300)]
crypto: kpp, (ec)dh - fix typos

While here, add missing argument description (ndigits).

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agoMAINTAINERS: add a maintainer for the Inside Secure crypto driver
Antoine Ténart [Wed, 24 May 2017 14:10:35 +0000 (16:10 +0200)]
MAINTAINERS: add a maintainer for the Inside Secure crypto driver

A new cryptographic engine driver was added in
drivers/crypto/inside-secure. Add myself as a maintainer for this
driver.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: inside-secure - add SafeXcel EIP197 crypto engine driver
Antoine Ténart [Wed, 24 May 2017 14:10:34 +0000 (16:10 +0200)]
crypto: inside-secure - add SafeXcel EIP197 crypto engine driver

Add support for Inside Secure SafeXcel EIP197 cryptographic engine,
which can be found on Marvell Armada 7k and 8k boards. This driver
currently implements: ecb(aes), cbc(aes), sha1, sha224, sha256 and
hmac(sah1) algorithms.

Two firmwares are needed for this engine to work. Their are mostly used
for more advanced operations than the ones supported (as of now), but we
still need them to pass the data to the internal cryptographic engine.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-sham - force word alignment on the xmit-buf also
Tero Kristo [Wed, 24 May 2017 07:35:34 +0000 (10:35 +0300)]
crypto: omap-sham - force word alignment on the xmit-buf also

This was previously missed from the code, causing SDMA to hang in
some cases where the buffer ended up being not aligned.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-sham - fix closing of hash with separate finalize call
Tero Kristo [Wed, 24 May 2017 07:35:33 +0000 (10:35 +0300)]
crypto: omap-sham - fix closing of hash with separate finalize call

Currently there is an interesting corner case failure with omap-sham
driver, if the finalize call is done separately with no data, but
all previous data has already been processed. In this case, it is not
possible to close the hash with the hardware without providing any data,
so we get incorrect results. Fix this by adjusting the size of data
sent to the hardware crypto engine in case the non-final data size falls
on the block size boundary, by reducing the amount of data sent by one
full block. This makes it sure that we always have some data available
for the finalize call and we can close the hash properly.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Reported-by: Aparna Balasubramanian <aparnab@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-sham - buffer handling fixes for hashing later
Tero Kristo [Wed, 24 May 2017 07:35:32 +0000 (10:35 +0300)]
crypto: omap-sham - buffer handling fixes for hashing later

Currently, the hash later code only handles the cases when we have
either new data coming in with the request or old data in the buffer,
but not the combination when we have both. Fix this by changing the
ordering of the code a bit and handling both cases properly
simultaneously if needed. Also, fix an issue with omap_sham_update
that surfaces with this fix, so that the code checks the bufcnt
instead of total data amount against buffer length to avoid any
buffer overflows.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - Add support for GCM mode
Tero Kristo [Wed, 24 May 2017 07:35:31 +0000 (10:35 +0300)]
crypto: omap-aes - Add support for GCM mode

OMAP AES hw supports AES-GCM mode. This patch adds support for GCM and
RFC4106 GCM mode in omap-aes driver. The GCM implementation is mostly
written into its own source file, which gets built into the same driver
binary as the existing AES support.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
[t-kristo@ti.com: forward port to latest upstream kernel, conversion to use
 omap-crypto lib and some additional fixes]
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - export some AES driver functionality locally
Tero Kristo [Wed, 24 May 2017 07:35:30 +0000 (10:35 +0300)]
crypto: omap-aes - export some AES driver functionality locally

These are going to be required by the addition of the GCM support.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - move definitions over to a separate header file
Tero Kristo [Wed, 24 May 2017 07:35:29 +0000 (10:35 +0300)]
crypto: omap-aes - move definitions over to a separate header file

Move over most of the omap-aes driver internal definitions to a separate
header file. This is done so that the same definitions can be used in
the upcoming AES-GCM support code.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - use base omap crypto support library
Tero Kristo [Wed, 24 May 2017 07:35:28 +0000 (10:35 +0300)]
crypto: omap-aes - use base omap crypto support library

Use the SG alignment APIs from the OMAP crypto support library instead
of using own implementations.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-des - use base omap crypto support library
Tero Kristo [Wed, 24 May 2017 07:35:27 +0000 (10:35 +0300)]
crypto: omap-des - use base omap crypto support library

Use the SG alignment APIs from the OMAP crypto support library instead
of using own implementations. This reduces the amount of copy-paste
code.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap - add base support library for common routines
Tero Kristo [Wed, 24 May 2017 07:35:26 +0000 (10:35 +0300)]
crypto: omap - add base support library for common routines

This contains the generic APIs for aligning SG buffers.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-des - use runtime_pm autosuspend for clock handling
Tero Kristo [Wed, 24 May 2017 07:35:25 +0000 (10:35 +0300)]
crypto: omap-des - use runtime_pm autosuspend for clock handling

Convert the driver to use autosuspend for runtime_pm. This boosts the
performance, and optimizes the power consumption for the driver. By
default, the timeout value for autosuspend is set to one second.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-des - add check for weak keys
Tero Kristo [Wed, 24 May 2017 07:35:24 +0000 (10:35 +0300)]
crypto: omap-des - add check for weak keys

OMAP DES crypto accelerator itself is unable to detect weak keys, so
add a specific call to the generic des driver to check the key strength
if requested.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - fix context handling for multiple cores
Tero Kristo [Wed, 24 May 2017 07:35:23 +0000 (10:35 +0300)]
crypto: omap-aes - fix context handling for multiple cores

AES can have multiple HW accelerator cores in the system, in which case
each core has its own crypto engine in use. Currently, the used hardware
device is stored under the omap_aes_ctx struct, which is global for
the algorithm itself, causing conflicts when used with multiple cores.
Fix this by moving the used HW device under reqctx, which is stored
per-request basis.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-aes - drop unused flags attribute from omap_aes_ctx
Tero Kristo [Wed, 24 May 2017 07:35:22 +0000 (10:35 +0300)]
crypto: omap-aes - drop unused flags attribute from omap_aes_ctx

This is not used for anything, so drop it.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: rng - Remove unused function __crypto_rng_cast()
Matthias Kaehlcke [Mon, 22 May 2017 22:49:43 +0000 (15:49 -0700)]
crypto: rng - Remove unused function __crypto_rng_cast()

This fixes the following warning when building with clang:

crypto/rng.c:35:34: error: unused function '__crypto_rng_cast'
    [-Werror,-Wunused-function]

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agohw_random: timeriomem_rng: Allow setting RNG quality from platform data
Rick Altherr [Mon, 22 May 2017 21:12:24 +0000 (14:12 -0700)]
hw_random: timeriomem_rng: Allow setting RNG quality from platform data

When a hw_random device's quality is non-zero, it will automatically be
used to fill the kernel's entropy pool.  Since timeriomem_rng is used by
many different devices, the quality needs to be provided by platform
data or device tree.

Signed-off-by: Rick Altherr <raltherr@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agodt-bindings: timeriomem_rng: Add entropy quality property
Rick Altherr [Mon, 22 May 2017 21:12:23 +0000 (14:12 -0700)]
dt-bindings: timeriomem_rng: Add entropy quality property

Signed-off-by: Rick Altherr <raltherr@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm/crc32 - enable module autoloading based on CPU feature bits
Ard Biesheuvel [Sun, 21 May 2017 10:23:40 +0000 (10:23 +0000)]
crypto: arm/crc32 - enable module autoloading based on CPU feature bits

Make the module autoloadable by tying it to the CPU feature bits that
describe whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm/sha2-ce - enable module autoloading based on CPU feature bits
Ard Biesheuvel [Sun, 21 May 2017 10:23:39 +0000 (10:23 +0000)]
crypto: arm/sha2-ce - enable module autoloading based on CPU feature bits

Make the module autoloadable by tying it to the CPU feature bit that
describes whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm/sha1-ce - enable module autoloading based on CPU feature bits
Ard Biesheuvel [Sun, 21 May 2017 10:23:38 +0000 (10:23 +0000)]
crypto: arm/sha1-ce - enable module autoloading based on CPU feature bits

Make the module autoloadable by tying it to the CPU feature bit that
describes whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm/ghash-ce - enable module autoloading based on CPU feature bits
Ard Biesheuvel [Sun, 21 May 2017 10:23:37 +0000 (10:23 +0000)]
crypto: arm/ghash-ce - enable module autoloading based on CPU feature bits

Make the module autoloadable by tying it to the CPU feature bit that
describes whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm/aes-ce - enable module autoloading based on CPU feature bits
Ard Biesheuvel [Sun, 21 May 2017 10:23:36 +0000 (10:23 +0000)]
crypto: arm/aes-ce - enable module autoloading based on CPU feature bits

Make the module autoloadable by tying it to the CPU feature bit that
describes whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ccp - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:31 +0000 (08:53 +0200)]
crypto: ccp - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: mediatek - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:30 +0000 (08:53 +0200)]
crypto: mediatek - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: qat - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:29 +0000 (08:53 +0200)]
crypto: qat - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: omap-sham - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:28 +0000 (08:53 +0200)]
crypto: omap-sham - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: mv_cesa - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:27 +0000 (08:53 +0200)]
crypto: mv_cesa - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: marvell - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:26 +0000 (08:53 +0200)]
crypto: marvell - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ixp4xx - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:25 +0000 (08:53 +0200)]
crypto: ixp4xx - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: brcm - Use IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:24 +0000 (08:53 +0200)]
crypto: brcm - Use IPAD/OPAD constant

This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: hmac - add hmac IPAD/OPAD constant
Corentin LABBE [Fri, 19 May 2017 06:53:23 +0000 (08:53 +0200)]
crypto: hmac - add hmac IPAD/OPAD constant

Many HMAC users directly use directly 0x36/0x5c values.
It's better with crypto to use a name instead of directly some crypto
constant.

This patch simply add HMAC_IPAD_VALUE/HMAC_OPAD_VALUE defines in a new
include file "crypto/hmac.h" and use them in crypto/hmac.c

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: x86/aes - Don't use %rbp as temporary register
Eric Biggers [Wed, 17 May 2017 04:03:08 +0000 (21:03 -0700)]
crypto: x86/aes - Don't use %rbp as temporary register

When using the "aes-asm" implementation of AES (*not* the AES-NI
implementation) on an x86_64, v4.12-rc1 kernel with lockdep enabled, the
following warning was reported, along with a long unwinder dump:

WARNING: kernel stack regs at ffffc90000643558 in kworker/u4:2:155 has bad 'bp' value 000000000000001c

The problem is that aes_enc_block() and aes_dec_block() use %rbp as a
temporary register, which breaks stack traces if an interrupt occurs.

Fix this by replacing %rbp with %r9, which was being used to hold the
saved value of %rbp.  This required rearranging the AES round macro
slightly since %r9d cannot be used as the target of a move from %ah-%dh.

Performance is essentially unchanged --- actually about 0.2% faster than
before.  Interestingly, I also measured aes-generic as being nearly 7%
faster than aes-asm, so perhaps aes-asm has outlived its usefulness...

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: qat - use pcie_flr instead of duplicating it
Christoph Hellwig [Tue, 16 May 2017 14:21:05 +0000 (16:21 +0200)]
crypto: qat - use pcie_flr instead of duplicating it

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: img-hash - Handle return value of clk_prepare_enable
Arvind Yadav [Tue, 16 May 2017 08:27:41 +0000 (13:57 +0530)]
crypto: img-hash - Handle return value of clk_prepare_enable

Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agohwrng: omap3-rom - Handle return value of clk_prepare_enable
Arvind Yadav [Mon, 15 May 2017 08:22:03 +0000 (13:52 +0530)]
hwrng: omap3-rom - Handle return value of clk_prepare_enable

Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - add generic gcm(aes)
Sabrina Dubroca [Fri, 28 Apr 2017 16:12:02 +0000 (18:12 +0200)]
crypto: aesni - add generic gcm(aes)

Now that the asm side of things can support all the valid lengths of ICV
and all lengths of associated data, provide the glue code to expose a
generic gcm(aes) crypto algorithm.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make AVX2 AES-GCM work with all valid auth_tag_len
Sabrina Dubroca [Fri, 28 Apr 2017 16:12:01 +0000 (18:12 +0200)]
crypto: aesni - make AVX2 AES-GCM work with all valid auth_tag_len

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make AVX2 AES-GCM work with any aadlen
Sabrina Dubroca [Fri, 28 Apr 2017 16:12:00 +0000 (18:12 +0200)]
crypto: aesni - make AVX2 AES-GCM work with any aadlen

This is the first step to make the aesni AES-GCM implementation
generic. The current code was written for rfc4106, so it handles only
some specific sizes of associated data.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make AVX AES-GCM work with all valid auth_tag_len
Sabrina Dubroca [Fri, 28 Apr 2017 16:11:59 +0000 (18:11 +0200)]
crypto: aesni - make AVX AES-GCM work with all valid auth_tag_len

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make AVX AES-GCM work with any aadlen
Sabrina Dubroca [Fri, 28 Apr 2017 16:11:58 +0000 (18:11 +0200)]
crypto: aesni - make AVX AES-GCM work with any aadlen

This is the first step to make the aesni AES-GCM implementation
generic. The current code was written for rfc4106, so it handles
only some specific sizes of associated data.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make non-AVX AES-GCM work with all valid auth_tag_len
Sabrina Dubroca [Fri, 28 Apr 2017 16:11:57 +0000 (18:11 +0200)]
crypto: aesni - make non-AVX AES-GCM work with all valid auth_tag_len

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: aesni - make non-AVX AES-GCM work with any aadlen
Sabrina Dubroca [Fri, 28 Apr 2017 16:11:56 +0000 (18:11 +0200)]
crypto: aesni - make non-AVX AES-GCM work with any aadlen

This is the first step to make the aesni AES-GCM implementation
generic. The current code was written for rfc4106, so it handles only
some specific sizes of associated data.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: arm64/sha - avoid non-standard inline asm tricks
Ard Biesheuvel [Wed, 26 Apr 2017 16:11:32 +0000 (17:11 +0100)]
crypto: arm64/sha - avoid non-standard inline asm tricks

Replace the inline asm which exports struct offsets as ELF symbols
with proper const variables exposing the same values. This works
around an issue with Clang which does not interpret the "i" (or "I")
constraints in the same way as GCC.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: ccp - Add a module author
Gary R Hook [Tue, 25 Apr 2017 13:59:44 +0000 (08:59 -0500)]
crypto: ccp - Add a module author

CC: <stable@vger.kernel.org> # 4.9.x+
Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: caam - add support for RSA key form 3
Radu Alexe [Tue, 25 Apr 2017 13:26:39 +0000 (16:26 +0300)]
crypto: caam - add support for RSA key form 3

CAAM RSA private key may have either of three representations.

1. The first representation consists of the pair (n, d), where the
   components have the following meanings:
      n      the RSA modulus
      d      the RSA private exponent

2. The second representation consists of the triplet (p, q, d), where
the
   components have the following meanings:
      p      the first prime factor of the RSA modulus n
      q      the second prime factor of the RSA modulus n
      d      the RSA private exponent

3. The third representation consists of the quintuple (p, q, dP, dQ,
qInv),
   where the components have the following meanings:
      p      the first prime factor of the RSA modulus n
      q      the second prime factor of the RSA modulus n
      dP     the first factors's CRT exponent
      dQ     the second factors's CRT exponent
      qInv   the (first) CRT coefficient

The benefit of using the third or the second key form is lower
computational cost for the decryption and signature operations.

This patch adds support for the third RSA private key
representations and extends caampkc to use the fastest key when all
related components are present in the private key.

Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: caam - add support for RSA key form 2
Radu Alexe [Tue, 25 Apr 2017 13:26:38 +0000 (16:26 +0300)]
crypto: caam - add support for RSA key form 2

CAAM RSA private key may have either of three representations.

1. The first representation consists of the pair (n, d), where the
   components have the following meanings:
      n      the RSA modulus
      d      the RSA private exponent

2. The second representation consists of the triplet (p, q, d), where
the
   components have the following meanings:
      p      the first prime factor of the RSA modulus n
      q      the second prime factor of the RSA modulus n
      d      the RSA private exponent

3. The third representation consists of the quintuple (p, q, dP, dQ,
qInv),
   where the components have the following meanings:
      p      the first prime factor of the RSA modulus n
      q      the second prime factor of the RSA modulus n
      dP     the first factors's CRT exponent
      dQ     the second factors's CRT exponent
      qInv   the (first) CRT coefficient

The benefit of using the third or the second key form is lower
computational cost for the decryption and signature operations.

This patch adds support for the second RSA private key
representation.

Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: caam - incapsulate dropping leading zeros into function
Radu Alexe [Tue, 25 Apr 2017 13:26:37 +0000 (16:26 +0300)]
crypto: caam - incapsulate dropping leading zeros into function

This function will be used into further patches.

Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: caam - avoid kzalloc(0) in caam_read_raw_data
Tudor Ambarus [Tue, 25 Apr 2017 13:26:36 +0000 (16:26 +0300)]
crypto: caam - avoid kzalloc(0) in caam_read_raw_data

The function returns NULL if buf is composed only of zeros.

Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: sha512-mb - add some missing unlock on error
Dan Carpenter [Tue, 25 Apr 2017 09:18:54 +0000 (12:18 +0300)]
crypto: sha512-mb - add some missing unlock on error

We recently added some new locking but missed the unlocks on these
error paths in sha512_ctx_mgr_submit().

Fixes: c459bd7beda0 ("crypto: sha512-mb - Protect sha512 mb ctx mgr access")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: tcrypt - don't disable irqs and wait
Gilad Ben-Yossef [Tue, 25 Apr 2017 08:25:40 +0000 (11:25 +0300)]
crypto: tcrypt - don't disable irqs and wait

The tcrypt AEAD cycles speed tests disables irqs during the test, which is
broken at the very least since commit
'1425d2d17f7309c6 ("crypto: tcrypt - Fix AEAD speed tests")'
adds a wait for completion as part of the test and probably since
switching to the new AEAD API.

While the result of taking a cycle count diff may not mean much on SMP
systems if the task migrates, it's good enough for tcrypt being the quick
& dirty dev tool it is. It's also what all the other (i.e. hash) cycle
speed tests do.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Reported-by: Ofir Drang <ofir.drang@arm.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agocrypto: skcipher - Add missing API setkey checks
Herbert Xu [Tue, 9 May 2017 19:48:23 +0000 (03:48 +0800)]
crypto: skcipher - Add missing API setkey checks

The API setkey checks for key sizes and alignment went AWOL during the
skcipher conversion.  This patch restores them.

Cc: <stable@vger.kernel.org>
Fixes: 4e6c3df4d729 ("crypto: skcipher - Add low-level skcipher...")
Reported-by: Baozeng <sploving1@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
7 years agoLinux 4.12-rc1
Linus Torvalds [Sat, 13 May 2017 20:19:49 +0000 (13:19 -0700)]
Linux 4.12-rc1

7 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Linus Torvalds [Sat, 13 May 2017 17:25:05 +0000 (10:25 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/dtor/input

Pull some more input subsystem updates from Dmitry Torokhov:
 "An updated xpad driver with a few more recognized device IDs, and a
  new psxpad-spi driver, allowing connecting Playstation 1 and 2 joypads
  via SPI bus"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: cros_ec_keyb - remove extraneous 'const'
  Input: add support for PlayStation 1/2 joypads connected via SPI
  Input: xpad - add USB IDs for Mad Catz Brawlstick and Razer Sabertooth
  Input: xpad - sync supported devices with xboxdrv
  Input: xpad - sort supported devices by USB ID

7 years agoMerge tag 'upstream-4.12-rc1' of git://git.infradead.org/linux-ubifs
Linus Torvalds [Sat, 13 May 2017 17:23:12 +0000 (10:23 -0700)]
Merge tag 'upstream-4.12-rc1' of git://git.infradead.org/linux-ubifs

Pull UBI/UBIFS updates from Richard Weinberger:

 - new config option CONFIG_UBIFS_FS_SECURITY

 - minor improvements

 - random fixes

* tag 'upstream-4.12-rc1' of git://git.infradead.org/linux-ubifs:
  ubi: Add debugfs file for tracking PEB state
  ubifs: Fix a typo in comment of ioctl2ubifs & ubifs2ioctl
  ubifs: Remove unnecessary assignment
  ubifs: Fix cut and paste error on sb type comparisons
  ubi: fastmap: Fix slab corruption
  ubifs: Add CONFIG_UBIFS_FS_SECURITY to disable/enable security labels
  ubi: Make mtd parameter readable
  ubi: Fix section mismatch