Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1291804

Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode

From Baolin Wang <baolin.wang@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode
Date 2015-12-15 04:00 +0100
Message-ID <qFO0i-6pG-5@gated-at.bofh.it> (permalink)
References <qFwG6-3zr-11@gated-at.bofh.it> <qFwG6-3zr-27@gated-at.bofh.it> <qFKSK-4sB-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


>> +     /*
>> +      * Here we need to check if it can be encrypted or decrypted with
>> +      * bulk block, which means these encryption modes don't need IV or
>> +      * just need one initial IV. For bulk mode, we can expand the
>> +      * scatterlist entries to map the bio, then send all the scatterlists
>> +      * to the hardware engine at one time to improve the crypto engine
>> +      * efficiency. But it does not fit for other encryption modes, it has
>> +      * to do encryption and decryption sector by sector because every
>> +      * sector has different IV.
>> +      */
>> +     if (!strcmp(chainmode, "ecb") || !strcmp(chainmode, "xts"))
>> +             cc->bulk_crypto = 1;
>> +     else
>> +             cc->bulk_crypto = 0;n
>
> It is perfectly fine to use another IV even for XTS mode (despite it is not needed).
> You can use ESSIV for example, or benbi (big-endian variant of plain IV).
> (And it is really used for some LUKS devices.)
>
> How it is supposed to work in this case?
> If I read this patch correctly, it will completely corrupt data in this case because
> it expects plain (consecutive) IV...

The XTS mode can limit maximum size of each encrypted data unit
(typically a sector or disk block) to 2^20 AES blocks, so we can use
one bio as one encrypted data unit (we don't do it sector by sector).
It can generate one IV for each separate encrypted data unit. Please
correct me if I misunderstand something. Thanks.

>
> Also how it handles 32bit plain IV (that restart after 2TB)? (IOW plain IV, not plain64).
>
> Milan
>



-- 
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] Optimize the dm-crypt for XTS mode Baolin Wang <baolin.wang@linaro.org> - 2015-12-14 09:30 +0100
  [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode Baolin Wang <baolin.wang@linaro.org> - 2015-12-14 09:30 +0100
    Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode Milan Broz <gmazyland@gmail.com> - 2015-12-15 00:40 +0100
      Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode Baolin Wang <baolin.wang@linaro.org> - 2015-12-15 04:00 +0100
        Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode Milan Broz <gmazyland@gmail.com> - 2015-12-15 09:30 +0100
          Re: [PATCH 2/2] md: dm-crypt: Optimize the dm-crypt for XTS mode Baolin Wang <baolin.wang@linaro.org> - 2015-12-15 12:40 +0100

csiph-web