Re: Incorrect use of CRYPTO_ALG_ASYNC in crypto_alloc_sync_skcipher()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 09, 2024 at 10:51:30AM +0100, David Howells wrote:
> Hi Herbert,
> 
> Is the following code in crypto_alloc_sync_skcipher() wrong:
> 
> 	/* Only sync algorithms allowed. */
> 	mask |= CRYPTO_ALG_ASYNC | CRYPTO_ALG_SKCIPHER_REQSIZE_LARGE;
> 
> in its specification of CRYPTO_ALG_ASYNC?  Given what the docs say:
> 
>     The mask flag restricts the type of cipher. The only allowed flag is
>     CRYPTO_ALG_ASYNC to restrict the cipher lookup function to
>     asynchronous ciphers. Usually, a caller provides a 0 for the mask flag.
>     ^^^^^^^^^^^^
> 
> or are the docs wrong?

The mask is used together with the type bitfield.  You need to set
CRYPTO_ALG_ASYNC in both bitfields if you want to guarantee getting
an async cipher.

If you set CRYPTO_ALG_ASYNC in the mask but leave it unset in the
type bitfield then you are guaranteed to get an algorithm with this
bit turned off, in other words a synchronous cipher.

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




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux