2015-03-30 17:59:48

by Corentin Labbe

[permalink] [raw]
Subject: problem with testing a CTR block cipher mode which is partially working

hello

I am trying to add the CTR (counter) block cipher mode for AES on my Security System driver.

When testing with the tcrypt module I got the following result:
[ 1256.986989] alg: skcipher: Test 1 failed on encryption for ctr-aes-sunxi-ss
[ 1256.987004] 00000000: 87 4d 61 91 b6 20 e3 26 1b ef 68 64 99 0d b6 ce
[ 1256.987013] 00000010: 40 94 25 91 d7 b4 4f 49 ab c1 9d 33 a4 4e f6 54
[ 1256.987023] 00000020: ce 58 d2 f0 01 8f 92 a2 5f 2c bb 66 13 8b 9d 76
[ 1256.987032] 00000030: 30 fa 4a 40 b1 67 2e f3 46 b7 9a 7c ba 91 0b a2

As you can see the first ciphered block is correct (according to testmgr.h), the subsequent blocks are bad.

So Could I assume that the setting of key and IV are good (at least for the first cipher pass.

The number of inputs(register) are limited and I have tested near all the possibility.
Any idea of what could be wrong.

Regards
Thanks in advance


2015-03-30 18:08:33

by Markus Stockhausen

[permalink] [raw]
Subject: AW: problem with testing a CTR block cipher mode which is partially working

> Von: [email protected] [[email protected]]" im Auftrag von "Corentin LABBE [[email protected]]
> Gesendet: Montag, 30. M?rz 2015 19:59
> An: [email protected]
> Cc: [email protected]
> Betreff: problem with testing a CTR block cipher mode which is partially working
>
> hello
>
> I am trying to add the CTR (counter) block cipher mode for AES on my Security System driver.
>
> When testing with the tcrypt module I got the following result:
> [ 1256.986989] alg: skcipher: Test 1 failed on encryption for ctr-aes-sunxi-ss
> [ 1256.987004] 00000000: 87 4d 61 91 b6 20 e3 26 1b ef 68 64 99 0d b6 ce
> [ 1256.987013] 00000010: 40 94 25 91 d7 b4 4f 49 ab c1 9d 33 a4 4e f6 54
> [ 1256.987023] 00000020: ce 58 d2 f0 01 8f 92 a2 5f 2c bb 66 13 8b 9d 76
> [ 1256.987032] 00000030: 30 fa 4a 40 b1 67 2e f3 46 b7 9a 7c ba 91 0b a2
>
> As you can see the first ciphered block is correct (according to testmgr.h), the subsequent blocks are bad.
>
> So Could I assume that the setting of key and IV are good (at least for the first cipher pass.
>
> The number of inputs(register) are limited and I have tested near all the possibility.
> Any idea of what could be wrong.
>

had a similar challenge a few months ago. I had to take care about

- counter IV is big endian (implemented it little endian in first place)
- CTR allows to encrypt data that does not need to be amultiple of 16 bytes.

Markus


Attachments:
InterScan_Disclaimer.txt (1.61 kB)

2015-03-30 19:11:35

by Stephan Müller

[permalink] [raw]
Subject: Re: AW: problem with testing a CTR block cipher mode which is partially working

Am Montag, 30. M?rz 2015, 18:08:28 schrieb Markus Stockhausen:

Hi Markus,

> > Von: [email protected]
> > [[email protected]]" im Auftrag von "Corentin
> > LABBE [[email protected]] Gesendet: Montag, 30. M?rz 2015 19:59
> > An: [email protected]
> > Cc: [email protected]
> > Betreff: problem with testing a CTR block cipher mode which is partially
> > working
> >
> > hello
> >
> > I am trying to add the CTR (counter) block cipher mode for AES on my
> > Security System driver.
> >
> > When testing with the tcrypt module I got the following result:
> > [ 1256.986989] alg: skcipher: Test 1 failed on encryption for
> > ctr-aes-sunxi-ss [ 1256.987004] 00000000: 87 4d 61 91 b6 20 e3 26 1b ef
> > 68 64 99 0d b6 ce [ 1256.987013] 00000010: 40 94 25 91 d7 b4 4f 49 ab c1
> > 9d 33 a4 4e f6 54 [ 1256.987023] 00000020: ce 58 d2 f0 01 8f 92 a2 5f 2c
> > bb 66 13 8b 9d 76 [ 1256.987032] 00000030: 30 fa 4a 40 b1 67 2e f3 46 b7
> > 9a 7c ba 91 0b a2
> >
> > As you can see the first ciphered block is correct (according to
> > testmgr.h), the subsequent blocks are bad.
> >
> > So Could I assume that the setting of key and IV are good (at least for
> > the first cipher pass.
> >
> > The number of inputs(register) are limited and I have tested near all the
> > possibility. Any idea of what could be wrong.
>
> had a similar challenge a few months ago. I had to take care about
>
> - counter IV is big endian (implemented it little endian in first place)

Use crypto_inc for the counter which properly increments in big endian.

> - CTR allows to encrypt data that does not need to be amultiple of 16 bytes.
>
> Markus


--
Ciao
Stephan

2015-03-31 18:02:40

by Corentin Labbe

[permalink] [raw]
Subject: Re: AW: problem with testing a CTR block cipher mode which is partially working

Le 30/03/2015 20:08, Markus Stockhausen a écrit :
>> Von: [email protected] [[email protected]]" im Auftrag von "Corentin LABBE [[email protected]]
>> Gesendet: Montag, 30. März 2015 19:59
>> An: [email protected]
>> Cc: linux-sunxi-/[email protected]
>> Betreff: problem with testing a CTR block cipher mode which is partially working
>>
>> hello
>>
>> I am trying to add the CTR (counter) block cipher mode for AES on my Security System driver.
>>
>> When testing with the tcrypt module I got the following result:
>> [ 1256.986989] alg: skcipher: Test 1 failed on encryption for ctr-aes-sunxi-ss
>> [ 1256.987004] 00000000: 87 4d 61 91 b6 20 e3 26 1b ef 68 64 99 0d b6 ce
>> [ 1256.987013] 00000010: 40 94 25 91 d7 b4 4f 49 ab c1 9d 33 a4 4e f6 54
>> [ 1256.987023] 00000020: ce 58 d2 f0 01 8f 92 a2 5f 2c bb 66 13 8b 9d 76
>> [ 1256.987032] 00000030: 30 fa 4a 40 b1 67 2e f3 46 b7 9a 7c ba 91 0b a2
>>
>> As you can see the first ciphered block is correct (according to testmgr.h), the subsequent blocks are bad.
>>
>> So Could I assume that the setting of key and IV are good (at least for the first cipher pass.
>>
>> The number of inputs(register) are limited and I have tested near all the possibility.
>> Any idea of what could be wrong.
>>
>
> had a similar challenge a few months ago. I had to take care about
>
> - counter IV is big endian (implemented it little endian in first place)
> - CTR allows to encrypt data that does not need to be amultiple of 16 bytes.
>
> Markus
>

Sorry but if I change endianness of anything, the first block became invalid.

I have tryed ctr(des) but the same problem rise, the first block (so the first 8bytes) are correctly ciphered then everything is bad.
So I suspect the hardware to not increasing counter between blocks, but why..


--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

2015-04-01 02:06:37

by [email protected]

[permalink] [raw]
Subject: Re: Re: AW: problem with testing a CTR block cipher mode which is partially working

Dear All,

About the SS module, there is some detail information.
There is some issues on the SS hardware module, the issues make the some
AES/DES/3DS algorithm be not available.
1. The byte order of the counter is wrong, make the result error, so, the CTR
mode is not available.
2. Hardware don't support the continuous subcontracting, make the CTS mode is
not available.
3. Another issue need be taken attention is that hardware will modify the key
register when do AES encrypt, so, it need software to restore the key register
when doing every frame.

These issues are presented on the A10, A13, A20, A31 and A33.
The issues of SS module have been fixed on the A83T platform, so, I suggest to
take more attention to the A83T platform if any interest in the SS module.

If any problem, please don't hesitate to contact me(kevin-0TFLnhJekD6UEPyfVivIlAC/[email protected])
or Shuge(shuge-0TFLnhJekD6UEPyfVivIlAC/[email protected]).



[email protected]

From: Corentin LABBE
Date: 2015-04-01 02:02
To: Markus Stockhausen; [email protected]
CC: linux-sunxi-/[email protected]
Subject: [linux-sunxi] Re: AW: problem with testing a CTR block cipher mode which is partially working
Le 30/03/2015 20:08, Markus Stockhausen a écrit :
>> Von: [email protected] [[email protected]]" im Auftrag von "Corentin LABBE [[email protected]]
>> Gesendet: Montag, 30. März 2015 19:59
>> An: [email protected]
>> Cc: linux-sunxi-/[email protected]
>> Betreff: problem with testing a CTR block cipher mode which is partially working
>>
>> hello
>>
>> I am trying to add the CTR (counter) block cipher mode for AES on my Security System driver.
>>
>> When testing with the tcrypt module I got the following result:
>> [ 1256.986989] alg: skcipher: Test 1 failed on encryption for ctr-aes-sunxi-ss
>> [ 1256.987004] 00000000: 87 4d 61 91 b6 20 e3 26 1b ef 68 64 99 0d b6 ce
>> [ 1256.987013] 00000010: 40 94 25 91 d7 b4 4f 49 ab c1 9d 33 a4 4e f6 54
>> [ 1256.987023] 00000020: ce 58 d2 f0 01 8f 92 a2 5f 2c bb 66 13 8b 9d 76
>> [ 1256.987032] 00000030: 30 fa 4a 40 b1 67 2e f3 46 b7 9a 7c ba 91 0b a2
>>
>> As you can see the first ciphered block is correct (according to testmgr.h), the subsequent blocks are bad.
>>
>> So Could I assume that the setting of key and IV are good (at least for the first cipher pass.
>>
>> The number of inputs(register) are limited and I have tested near all the possibility.
>> Any idea of what could be wrong.
>>
>
> had a similar challenge a few months ago. I had to take care about
>
> - counter IV is big endian (implemented it little endian in first place)
> - CTR allows to encrypt data that does not need to be amultiple of 16 bytes.
>
> Markus
>

Sorry but if I change endianness of anything, the first block became invalid.

I have tryed ctr(des) but the same problem rise, the first block (so the first 8bytes) are correctly ciphered then everything is bad.
So I suspect the hardware to not increasing counter between blocks, but why..


--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

2015-04-01 11:18:38

by Corentin Labbe

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: AW: problem with testing a CTR block cipher mode which is partially working

On 04/01/15 04:06, [email protected] wrote:
> Dear All,
>
>
> About the SS module, there is some detail information.
> There is some issues on the SS hardware module, the issues make the some
> AES/DES/3DS algorithm be not available.
> 1. The byte order of the counter is wrong, make the result error, so, the CTR
> mode is not available.
> 2. Hardware don't support the continuous subcontracting, make the CTS mode is
> not available.
> 3. Another issue need be taken attention is that hardware will modify the key
> register when do AES encrypt, so, it need software to restore the key register
>
> when doing every frame.
>
> These issues are presented on the A10, A13, A20, A31 and A33.
> The issues of SS module have been fixed on the A83T platform, so, I suggest to
> take more attention to the A83T platform if any interest in the SS module.
>
> If any problem, please don't hesitate to contact me([email protected])
>
> or Shuge([email protected]).
>

Thanks for your answer, I have loose hours on that problem.

Perhaps you could update all datasheet/user manual about this known issue ?

Regards

2015-04-02 02:10:29

by [email protected]

[permalink] [raw]
Subject: Re: Re: Re: AW: problem with testing a CTR block cipher mode which is partially working

> Thanks for your answer, I have loose hours on that problem.
I'm sorry to hear that.

> Perhaps you could update all datasheet/user manual about this known issue ?
We have updated the user manual and datasheet, the latest version is 1.3 for
A20 which is released in Oct. 2014. The CTR block mode is not support.
You can download it from the github: https://github.com/allwinner-zh/documents
and check the details of the SS moudle.

Best Regards,


[email protected]

From: Corentin LABBE
Date: 2015-04-01 19:16
To: linux-sunxi; [email protected]
Subject: Re: [linux-sunxi] Re: AW: problem with testing a CTR block cipher mode which is partially working
On 04/01/15 04:06, [email protected] wrote:
> Dear All,
>
>
> About the SS module, there is some detail information.
> There is some issues on the SS hardware module, the issues make the some
> AES/DES/3DS algorithm be not available.
> 1. The byte order of the counter is wrong, make the result error, so, the CTR
> mode is not available.
> 2. Hardware don't support the continuous subcontracting, make the CTS mode is
> not available.
> 3. Another issue need be taken attention is that hardware will modify the key
> register when do AES encrypt, so, it need software to restore the key register
>
> when doing every frame.
>
> These issues are presented on the A10, A13, A20, A31 and A33.
> The issues of SS module have been fixed on the A83T platform, so, I suggest to
> take more attention to the A83T platform if any interest in the SS module.
>
> If any problem, please don't hesitate to contact me(kevin-0TFLnhJekD6UEPyfVivIlAC/[email protected])
>
> or Shuge(shuge-0TFLnhJekD6UEPyfVivIlAC/[email protected]).
>

Thanks for your answer, I have loose hours on that problem.

Perhaps you could update all datasheet/user manual about this known issue ?

Regards

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

2015-04-02 19:02:42

by Corentin Labbe

[permalink] [raw]
Subject: Re: Re: AW: problem with testing a CTR block cipher mode which is partially working

On 04/02/15 04:10, [email protected] wrote:
>> Thanks for your answer, I have loose hours on that problem.
> I'm sorry to hear that.
>
>> Perhaps you could update all datasheet/user manual about this known issue ?
> We have updated the user manual and datasheet, the latest version is 1.3 for
> A20 which is released in Oct. 2014. The CTR block mode is not support.
> You can download it from the github: https://github.com/allwinner-zh/documents
> and check the details of the SS moudle.

Sorry, I believed to have the latest user manual.

Great thanks for the information.

Regards

>
> Best Regards,
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> [email protected]
>
>
> *From:* Corentin LABBE <mailto:[email protected]>
> *Date:* 2015-04-01 19:16
> *To:* linux-sunxi <mailto:linux-sunxi-/[email protected]>; [email protected] <mailto:[email protected]>
> *Subject:* Re: [linux-sunxi] Re: AW: problem with testing a CTR block cipher mode which is partially working
> On 04/01/15 04:06, [email protected] wrote:
> > Dear All,
> >
> >
> > About the SS module, there is some detail information.
> > There is some issues on the SS hardware module, the issues make the some
> > AES/DES/3DS algorithm be not available.
> > 1. The byte order of the counter is wrong, make the result error, so, the CTR
> > mode is not available.
> > 2. Hardware don't support the continuous subcontracting, make the CTS mode is
> > not available.
> > 3. Another issue need be taken attention is that hardware will modify the key
> > register when do AES encrypt, so, it need software to restore the key register
> >
> > when doing every frame.
> >
> > These issues are presented on the A10, A13, A20, A31 and A33.
> > The issues of SS module have been fixed on the A83T platform, so, I suggest to
> > take more attention to the A83T platform if any interest in the SS module.
> >
> > If any problem, please don't hesitate to contact me([email protected])
> >
> > or Shuge(shuge-0TFLnhJekD6UEPyfVivIlAC/[email protected]).
> >
>
> Thanks for your answer, I have loose hours on that problem.
>
> Perhaps you could update all datasheet/user manual about this known issue ?
>
> Regards
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/[email protected] <mailto:linux-sunxi+unsubscribe-/[email protected]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.