Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1672305 > unrolled thread
| Started by | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| First post | 2017-06-22 06:50 +0200 |
| Last post | 2017-06-23 20:30 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v6 0/2] IV Generation algorithms for dm-crypt Binoy Jayan <binoy.jayan@linaro.org> - 2017-06-22 06:50 +0200
Re: [PATCH v6 0/2] IV Generation algorithms for dm-crypt Herbert Xu <herbert@gondor.apana.org.au> - 2017-06-23 10:20 +0200
Re: [PATCH v6 0/2] IV Generation algorithms for dm-crypt Eric Biggers <ebiggers3@gmail.com> - 2017-06-23 20:30 +0200
| From | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| Date | 2017-06-22 06:50 +0200 |
| Subject | [PATCH v6 0/2] IV Generation algorithms for dm-crypt |
| Message-ID | <tV2e5-89c-11@gated-at.bofh.it> |
===============================================================================
dm-crypt optimization for larger block sizes
===============================================================================
Currently, the iv generation algorithms are implemented in dm-crypt.c. The goal
is to move these algorithms from the dm layer to the kernel crypto layer by
implementing them as template ciphers so they can be used in relation with
algorithms like aes, and with multiple modes like cbc, ecb etc. As part of this
patchset, the iv-generation code is moved from the dm layer to the crypto layer
and adapt the dm-layer to send a whole 'bio' (as defined in the block layer)
at a time. Each bio contains the in memory representation of physically
contiguous disk blocks. Since the bio itself may not be contiguous in main
memory, the dm layer sets up a chained scatterlist of these blocks split into
physically contiguous segments in memory so that DMA can be performed.
One challenge in doing so is that the IVs are generated based on a 512-byte
sector number. This infact limits the block sizes to 512 bytes. But this should
not be a problem if a hardware with iv generation support is used. The geniv
itself splits the segments into sectors so it could choose the IV based on
sector number. But it could be modelled in hardware effectively by not
splitting up the segments in the bio.
Another challenge faced is that dm-crypt has an option to use multiple keys.
The key selection is done based on the sector number. If the whole bio is
encrypted / decrypted with the same key, the encrypted volumes will not be
compatible with the original dm-crypt [without the changes]. So, the key
selection code is moved to crypto layer so the neighboring sectors are
encrypted with a different key.
The dm layer allocates space for iv. The hardware drivers can choose to make
use of this space to generate their IVs sequentially or allocate it on their
own. This can be moved to crypto layer too. Postponing this decision until
the requirement to integrate milan's changes are clear.
Interface to the crypto layer - include/crypto/geniv.h
More information on test procedure can be found in v1.
Results of performance tests with software crypto in v5.
The patch 'crypto: Multikey template for essiv' depends on
the following patches by Gilad:
MAINTAINERS: add Gilad BY as maintainer for ccree
staging: ccree: add devicetree bindings
staging: ccree: add TODO list
staging: add ccree crypto driver
Revisions:
----------
v1: https://patchwork.kernel.org/patch/9439175
v2: https://patchwork.kernel.org/patch/9471923
v3: https://lkml.org/lkml/2017/1/18/170
v4: https://patchwork.kernel.org/patch/9559665
v5: https://patchwork.kernel.org/patch/9669237
v5 --> v6:
----------
1. Moved allocation of initialization vectors to the iv-generator
2. Few consmetic changes as the consequence of the above
3. Few logical to boolean expressions for faster calculation
4. Included multikey template for splitting keys.
This needs testing with real hardware (juno with ccree)
and also modification. It is only for testing and not
for inclusion upstream.
v4 --> v5
----------
1. Fix for the multiple instance issue in /proc/crypto
2. Few cosmetic changes including struct alignment
3. Simplified 'struct geniv_req_info'
v3 --> v4
----------
Fix for the bug reported by Gilad Ben-Yossef.
The element '__ctx' in 'struct skcipher_request req' overflowed into the
element 'struct scatterlist src' which immediately follows 'req' in
'struct geniv_subreq' and corrupted src.
v2 --> v3
----------
1. Moved iv algorithms in dm-crypt.c for control
2. Key management code moved from dm layer to cryto layer
so that cipher instance selection can be made depending on key_index
3. The revision v2 had scatterlist nodes created for every sector in the bio.
It is modified to create only once scatterlist node to reduce memory
foot print. Synchronous requests are processed sequentially. Asynchronous
requests are processed in parallel and is freed in the async callback.
4. Changed allocation for sub-requests using mempool
v1 --> v2
----------
1. dm-crypt changes to process larger block sizes (one segment in a bio)
2. Incorporated changes w.r.t. comments from Herbert.
Binoy Jayan (2):
crypto: Add IV generation algorithms
crypto: Multikey template for essiv
drivers/md/dm-crypt.c | 1940 +++++++++++++++++++++++++++-----------
drivers/staging/ccree/Makefile | 2 +-
drivers/staging/ccree/essiv.c | 777 +++++++++++++++
drivers/staging/ccree/essiv_sw.c | 1040 ++++++++++++++++++++
include/crypto/geniv.h | 46 +
5 files changed, 3251 insertions(+), 554 deletions(-)
create mode 100644 drivers/staging/ccree/essiv.c
create mode 100644 drivers/staging/ccree/essiv_sw.c
create mode 100644 include/crypto/geniv.h
--
Binoy Jayan
[toc] | [next] | [standalone]
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Date | 2017-06-23 10:20 +0200 |
| Message-ID | <tVrYS-8aL-23@gated-at.bofh.it> |
| In reply to | #1672305 |
Binoy Jayan <binoy.jayan@linaro.org> wrote: > =============================================================================== > dm-crypt optimization for larger block sizes > =============================================================================== > > Currently, the iv generation algorithms are implemented in dm-crypt.c. The goal > is to move these algorithms from the dm layer to the kernel crypto layer by > implementing them as template ciphers so they can be used in relation with > algorithms like aes, and with multiple modes like cbc, ecb etc. As part of this > patchset, the iv-generation code is moved from the dm layer to the crypto layer > and adapt the dm-layer to send a whole 'bio' (as defined in the block layer) > at a time. Each bio contains the in memory representation of physically > contiguous disk blocks. Since the bio itself may not be contiguous in main > memory, the dm layer sets up a chained scatterlist of these blocks split into > physically contiguous segments in memory so that DMA can be performed. There is currently a patch-set for fscrypt to add essiv support. It would be interesting to know whether your implementation of essiv can also be used in that patchset. That would confirm that we're on the right track. Cheers, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[toc] | [prev] | [next] | [standalone]
| From | Eric Biggers <ebiggers3@gmail.com> |
|---|---|
| Date | 2017-06-23 20:30 +0200 |
| Message-ID | <tVBvc-5CD-17@gated-at.bofh.it> |
| In reply to | #1673354 |
On Fri, Jun 23, 2017 at 04:13:41PM +0800, Herbert Xu wrote: > Binoy Jayan <binoy.jayan@linaro.org> wrote: > > =============================================================================== > > dm-crypt optimization for larger block sizes > > =============================================================================== > > > > Currently, the iv generation algorithms are implemented in dm-crypt.c. The goal > > is to move these algorithms from the dm layer to the kernel crypto layer by > > implementing them as template ciphers so they can be used in relation with > > algorithms like aes, and with multiple modes like cbc, ecb etc. As part of this > > patchset, the iv-generation code is moved from the dm layer to the crypto layer > > and adapt the dm-layer to send a whole 'bio' (as defined in the block layer) > > at a time. Each bio contains the in memory representation of physically > > contiguous disk blocks. Since the bio itself may not be contiguous in main > > memory, the dm layer sets up a chained scatterlist of these blocks split into > > physically contiguous segments in memory so that DMA can be performed. > > There is currently a patch-set for fscrypt to add essiv support. It > would be interesting to know whether your implementation of essiv > can also be used in that patchset. That would confirm that we're on > the right track. > You can find the fscrypt patch at https://patchwork.kernel.org/patch/9795327/ Note that it's encrypting 4096-byte blocks, not 512-byte. Also, it's using AES-256 for the ESSIV tfm (since it uses a SHA-256 hash) but AES-128 for the "real" encryption. It's possible this is a mistake and it should be AES-128 for both. (If it is, it needs to be fixed before it's released in 4.13.) Eric
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web