2010-11-08 08:47:57

by Dmitry Kasatkin

[permalink] [raw]
Subject: crypto ahash error handling

Hello,

When using crypto ahash API, is it necessary/mandatory to call
crypto_ahash_final() if crypto_ahash_update() returns error...

Basically it might happen after several calls while calculating hash if
HW error happens.
It is not possible to continue hash calculation. it is necessary to
reset HW and start whole hash again..

Any comments?

Thanks,
Dmitry


2010-11-10 12:28:02

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto ahash error handling

Dmitry Kasatkin <[email protected]> wrote:
> Hello,
>
> When using crypto ahash API, is it necessary/mandatory to call
> crypto_ahash_final() if crypto_ahash_update() returns error...
>
> Basically it might happen after several calls while calculating hash if
> HW error happens.
> It is not possible to continue hash calculation. it is necessary to
> reset HW and start whole hash again..
>
> Any comments?

>From the driver's perspective you cannot expect that the user
will call crypto_ahash_final in this case, or for that matter in
any other case as the user is always free to leave a hash in
an unfinalised state.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-11-10 14:55:22

by Dmitry Kasatkin

[permalink] [raw]
Subject: Re: crypto ahash error handling

This is not good.

Driver might allocate some resources, which needs to be released.
crypto_ahash_final() should do some kind of "cleanup" task.

- Dmitry

On 10/11/10 14:27, ext Herbert Xu wrote:
> Dmitry Kasatkin <[email protected]> wrote:
>
>> Hello,
>>
>> When using crypto ahash API, is it necessary/mandatory to call
>> crypto_ahash_final() if crypto_ahash_update() returns error...
>>
>> Basically it might happen after several calls while calculating hash if
>> HW error happens.
>> It is not possible to continue hash calculation. it is necessary to
>> reset HW and start whole hash again..
>>
>> Any comments?
>>
> From the driver's perspective you cannot expect that the user
> will call crypto_ahash_final in this case, or for that matter in
> any other case as the user is always free to leave a hash in
> an unfinalised state.
>
> Cheers,
>

2010-11-11 16:17:11

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto ahash error handling

On Wed, Nov 10, 2010 at 04:54:51PM +0200, Dmitry Kasatkin wrote:
> This is not good.
>
> Driver might allocate some resources, which needs to be released.
> crypto_ahash_final() should do some kind of "cleanup" task.

Then your driver is broken. The whole hash API is designed around
the fact that each update operation completely stores all output
state in the memory provided, leaving no state behind in the
hardware.

Is your hardware capable of producing unfinalised hashes? If not
then you shouldn't even be implementing an update operation in
hardware. You should instead use a software fallback.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-11-11 18:11:53

by Dmitry Kasatkin

[permalink] [raw]
Subject: Re: crypto ahash error handling

Hi,

Yes. Our HW is capable of producing unfinalised hashes.
Everything is fine.

No. It is not broken.. It cleans up if error...

- Dmitry


On 11/11/10 18:17, ext Herbert Xu wrote:
> On Wed, Nov 10, 2010 at 04:54:51PM +0200, Dmitry Kasatkin wrote:
>
>> This is not good.
>>
>> Driver might allocate some resources, which needs to be released.
>> crypto_ahash_final() should do some kind of "cleanup" task.
>>
> Then your driver is broken. The whole hash API is designed around
> the fact that each update operation completely stores all output
> state in the memory provided, leaving no state behind in the
> hardware.
>
> Is your hardware capable of producing unfinalised hashes? If not
> then you shouldn't even be implementing an update operation in
> hardware. You should instead use a software fallback.
>
> Cheers,
>

2010-11-12 00:05:35

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto ahash error handling

On Thu, Nov 11, 2010 at 08:11:21PM +0200, Dmitry Kasatkin wrote:
> Hi,
>
> Yes. Our HW is capable of producing unfinalised hashes.
> Everything is fine.

OK then you should be fine even if the user never makes the "final"
call, right?

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-11-12 11:31:19

by Dmitry Kasatkin

[permalink] [raw]
Subject: Re: crypto ahash error handling

Well.. That was not the case before.
I made a new patch set.

I will send updates for SHA and AES soon after some more testing.

- Dmitry


On 12/11/10 02:05, ext Herbert Xu wrote:
> On Thu, Nov 11, 2010 at 08:11:21PM +0200, Dmitry Kasatkin wrote:
>
>> Hi,
>>
>> Yes. Our HW is capable of producing unfinalised hashes.
>> Everything is fine.
>>
> OK then you should be fine even if the user never makes the "final"
> call, right?
>
> Cheers,
>