Incorrect use of CRYPTO_ALG_ASYNC in crypto_alloc_sync_skcipher()?
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?
David
Herbert Xu
maintainerQuoted 7 lines · David Howells
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;
Quoted 8 lines
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_ASYNCto 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,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt