日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux加密框架 crypto 算法模板 CBC模板举例

發(fā)布時間:2023/12/13 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux加密框架 crypto 算法模板 CBC模板举例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

參考鏈接

  • Linux加密框架中的主要數(shù)據(jù)結構(三)_家有一希的博客-CSDN博客
  • https://blog.csdn.net/CHYabc123456hh/article/details/122194754

CBC算法模板

  • cbc.c - crypto/cbc.c - Linux source code (v5.15.11) - Bootlin
  • CBC算法模板屬性
    • 1)CBC算法模板名為"cbc"。
    • 2)CBC算法模板定義的創(chuàng)建實例接口為crypto_cbc_create,內部調用

  • skcipher.c - crypto/skcipher.c - Linux source code (v5.15.11) - Bootlin? ?內存分配
/*** skcipher_alloc_instance_simple - allocate instance of simple block cipher mode** Allocate an skcipher_instance for a simple block cipher mode of operation,* e.g. cbc or ecb. The instance context will have just a single crypto_spawn,* that for the underlying cipher. The {min,max}_keysize, ivsize, blocksize,* alignmask, and priority are set from the underlying cipher but can be* overridden if needed. The tfm context defaults to skcipher_ctx_simple, and* default ->setkey(), ->init(), and ->exit() methods are installed.** @tmpl: the template being instantiated* @tb: the template parameters** Return: a pointer to the new instance, or an ERR_PTR(). The caller still* needs to register the instance.*/struct skcipher_instance *skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr **tb) {u32 mask;struct skcipher_instance *inst;struct crypto_cipher_spawn *spawn;struct crypto_alg *cipher_alg;int err;err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SKCIPHER, &mask);if (err)return ERR_PTR(err);inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);if (!inst)return ERR_PTR(-ENOMEM);spawn = skcipher_instance_ctx(inst);err = crypto_grab_cipher(spawn, skcipher_crypto_instance(inst),crypto_attr_alg_name(tb[1]), 0, mask);if (err)goto err_free_inst;cipher_alg = crypto_spawn_cipher_alg(spawn);err = crypto_inst_setname(skcipher_crypto_instance(inst), tmpl->name,cipher_alg);if (err)goto err_free_inst;inst->free = skcipher_free_instance_simple;/* Default algorithm properties, can be overridden */inst->alg.base.cra_blocksize = cipher_alg->cra_blocksize;inst->alg.base.cra_alignmask = cipher_alg->cra_alignmask;inst->alg.base.cra_priority = cipher_alg->cra_priority;inst->alg.min_keysize = cipher_alg->cra_cipher.cia_min_keysize;inst->alg.max_keysize = cipher_alg->cra_cipher.cia_max_keysize;inst->alg.ivsize = cipher_alg->cra_blocksize;/* Use skcipher_ctx_simple by default, can be overridden */inst->alg.base.cra_ctxsize = sizeof(struct skcipher_ctx_simple);inst->alg.setkey = skcipher_setkey_simple;inst->alg.init = skcipher_init_tfm_simple;inst->alg.exit = skcipher_exit_tfm_simple;return inst;err_free_inst:skcipher_free_instance_simple(inst);return ERR_PTR(err); } 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的Linux加密框架 crypto 算法模板 CBC模板举例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。