SO Question1 & SO Question2 are good starting points for you.
There are nothing called asynchronous and synchronous functions.All functions(callees) need to return to the callers.
But there are asynchronous and synchronous operations.
crypto_alloc_ahash()
& crypto_alloc_shash()
differ in that the
first consist of the asynchronous operations and the latter consist of
synchronous operations.
In case of the first the function when called returns immediately to the main programme leaving behind its operations to complete. When the operations complete they usually use SIGNALS/INTERRUPTS to let the main programme know that they have completed. You can see the implementation here and an excerpt is given below.
struct crypto_ahash *crypto_alloc_ahash(const char *alg_name, u32 type,
u32 mask)
{
return crypto_alloc_tfm(alg_name, &crypto_ahash_type, type, mask);
}
In case of the latter the main programme(caller) has to wait for the operation in the function to complete to continue. I can't think of specific scenarios
where synchronization is mandatory in this context. You can see the implementation here
Indeed both the functions look the same but for the type of the values they return.
Async variants of functions is normally what you should look for the speed reasons of your programme. Also you cannot make async calls from sync variants for obvious reasons.
Edit :
crypto_alloc_hash is synchronous hash and I couldn't find out the difference between hash and shash.
Both returns allocated cipher handle in case of success; IS_ERR is true in case of an error, PTR_ERR returns the error code.
See shash vs hash.