哈希算法应用示例(四)
- 创建同步哈希算法实例hmac_md5_shash(一)
函数crypto_init_shash_ops_async初始化异步哈希算法实例hmac_md5_ahash流程如下所示:
1)调用crypto_create_tfm函数根据算法calg(即hmac_md5_alg)和算法类型常量frontend(&crypto_shash_type)创建同步哈希算法实例shash(即hmac_md5_shash)。
注意:此时创建算法实例hmac_md5_ahash时的crypto_create_tfm函数调用还未结束,再次调用crypto_create_tfm函数创建算法实例hmac_md5_shash,即对crypto_create_tfm函数进行了嵌套调用。
与创建异步哈希算法实例hmac_md5_ahash相同,算法实例的个性化部分和上下文通过算法类型常量frontend获得,不同的是此时输入的算法类型常量是同步哈希算法类型常量crypto_shash_type,定义如下所示。
static const struct crypto_type crypto_shash_type = {
.ctxsize = crypto_shash_ctxsize,
.extsize = crypto_shash_extsize,
.init = crypto_init_shash_ops,