Re: XTS does not get the expected result for non-byte-aligned NIST vectors

Jeffrey Walton <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <[email protected]>

On Wednesday, May 19, 2021 at 11:53:54 PM UTC-4 [email protected] wrote:

> I intend to use Crypto++  XTS-AES for encrypting data.  I tested XTS-AES 
> with the following NIST vector and got an unexpected 
> CT= 54a8629d76db46d0c516fca52c9c903baa3a635ddd56f09760f63252c8b46140 .   
>
> I call the following function:
> XTS_Mode< AES >::Encryption e;
> e.SetKeyWithIV(in_key, KeySize, in_iv, IVSize);
>     StringSource(in_plain_txt,svSize(plain_txt, 1),true, 
> new StreamTransformationFilter(e,
> new StringSink(cipher),
>                 StreamTransformationFilter::NO_PADDING
> ) // StreamTransformationFilter
> ); // StringSource
>
> My questions:
>
>    - Does  Crypto++  XTS-AES  not support non-byte aligned data 
>    encryption and decryption
>    
>
XTS mode should support non-aligned data. For SSE, it uses _mm_loadu_si128 
and _mm_storeu_si128, which are unaligned loads and stores. The class also 
uses 'GetWord<word64>(false, LITTLE_ENDIAN_ORDER, ...)' and 
'PutWord<word64>(false, LITTLE_ENDIAN_ORDER, ...)'. The 'false' says the 
data is not aligned, so a memcpy is used. Also see 
https://github.com/weidai11/cryptopp/blob/master/xts.cpp.

We've seen some trouble with bad code generation when two pointers happen 
to be the same in strcipher.cpp. But I don't believe XTS uses it. Also see 
https://github.com/weidai11/cryptopp/issues/1010.

Do you have a reproducer?

Jeff

-- 
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/02885d8a-b28d-4e65-9153-5409d288632dn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.