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

參考鏈接

  • Linux加密框架中的主要數據結構(三)_家有一希的博客-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算法模板定義的創建實例接口為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);
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/446094.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/446094.shtml
英文地址,請注明出處:http://en.pswp.cn/news/446094.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

leetcode數組匯總_LeetCode刷題實戰43:字符串相乘

算法的重要性,我就不多說了吧,想去大廠,就必須要經過基礎知識和業務邏輯面試算法面試。所以,為了提高大家的算法能力,這個公眾號后續每天帶大家做一道算法題,題目就從LeetCode上面選 !今天和大家…

Linux加密框架 crypto 算法模板 HMAC模板舉例

參考鏈接 Linux加密框架中的主要數據結構(三)_家有一希的博客-CSDN博客Linux加密框架 crypto 算法模板_CHYabc123456hh的博客-CSDN博客 HMAC算法模板 hmac.c - crypto/hmac.c - Linux source code (v5.15.11) - Bootlinhmac.c - crypto/hmac.c - Linux…

判斷非負整數是否是3的倍數_五年級數學因數與倍數知識點匯總與解題方法技巧...

在日常教學過程中,我發現孩子們和某些家長對學習數學的方法有一些誤區,就是覺著數學,單純就是邏輯思維,只要多做練習題就能學好,但是不是這樣的,低年級的學生,學習數學還是以背誦為主&#xff0…

tcp通訊一次最多能發送多少數據?_關于TCP/IP,必須知道的十個知識點

本文整理了一些TCP/IP協議簇中需要必知必會的十大問題,既是面試高頻問題,又是程序員必備基礎素養。一、TCP/IP模型TCP/IP協議模型(Transmission Control Protocol/Internet Protocol),包含了一系列構成互聯網基礎的網絡…

Linux內核crypto子系統的調用邏輯

testmgr.c - crypto/testmgr.c - Linux source code (v5.15.11) - Bootlin上述代碼是內核內部即crypto子系統對外提供密碼服務的測試程序調用流程&#xff1a;crypto API <—> crypto core <—> crypto_register_alg處于用戶態的程序想要調用處于內核態的密碼算法&…

python成語填空_python定期循環成語?

我有一個工作單位我希望每N秒發生一次.如果我使用簡單化minute 60while True:doSomeWork()time.sleep(minute)取決于doSomeWork()花費的時間,實際循環周期將是一分鐘加上那個時間.如果doSomeWork()所花費的時間不是確定性的,則工作周期更加難以預測.我想做的就是這樣minute 6…

Linux加密框架 crypto算法模板 以及CBC算法模板實例

參考鏈接 Linux加密框架中的主要數據結構&#xff08;四&#xff09;_家有一希的博客-CSDN博客algapi.h - include/crypto/algapi.h - Linux source code (v5.15.11) - Bootlin struct crypto_instance {struct crypto_alg alg;struct crypto_template *tmpl;union {/* Node i…

tomcat temp 大量 upload 文件_滲透測試之文件上傳漏洞總結

文末下載上傳環境源碼客戶端js檢查一般都是在網頁上寫一段javascript腳本&#xff0c;校驗上傳文件的后綴名&#xff0c;有白名單形式也有黑名單形式。查看源代碼可以看到有如下代碼對上傳文件類型進行了限制&#xff1a;我們可以看到對上傳文件類型進行了限制。繞過方法1.我們…

Linux加密框架 crypto算法模板 以及HMAC算法模板實例

HMAC算法模板實例 HMAC算法模板的創建實例的接口是hmac_create函數hmac.c - crypto/hmac.c - Linux source code (v5.15.11) - Bootlin hmac_create輸入的參數包括 算法模板 tmpl 和 算法模板實例參數 tbhmac_cretae函數返回的結果為0表示算法模板實例已經創建注冊算法模…

python判斷密碼強度并輸出_密碼強度判斷

[python]代碼庫def pdsz(cd):nnnn Falsefor c in cd:if c.isnumeric():nnnn Truebreakreturn nnnndef pdzm(cd):nnnn Falsefor c in cd:if c.isupper():nnnn Truebreakreturn nnnndef pdhh(cd):nnnn Falsefor c in cd:if c.islower():nnnn Truebreakreturn nnnndef main(…

linux加密框架 crypto 算法crypto_register_alg的注冊流程

算法注冊流程 靜態算法模塊初始化 分組算法模塊初始化 AES算法模塊&#xff08;aes_generic.c&#xff09;的初始化接口aes_init實現向加密框架注冊AES算法的功能&#xff0c;如下所示。aes_generic.c - crypto/aes_generic.c - Linux source code (v5.15.12) - Bootlin sta…

python 方法的實例_python調用自定義函數的實例操作

在python中&#xff0c;想要調用自定義函數必須先聲明&#xff0c;然后才能調用。使用函數時&#xff0c;只要按照函數定義的形式&#xff0c;向函數傳遞必需的參數&#xff0c;就可以調用函數完成相應的功能或者獲得函數返回的處理結果。(1)聲明函數python中使用 def 可以聲明…

linux加密框架 crypto 靜態哈希算法crypto_register_shash注冊流程

參考鏈接 Linux加密框架的算法管理&#xff08;一&#xff09;_家有一希的博客-CSDN博客_linux加密框架設計與實現shash.c - crypto/shash.c - Linux source code (v5.15.12) - Bootlin 函數介紹 crypto_register_shash函數實現向加密框架注冊靜態哈希算法的功能&#xff0c;…

多個線程訪問統一對象的不同方法_C#多線程讀寫同一文件處理

在多線程訪問讀寫同一個文件時&#xff0c;經常遇到異常&#xff1a;“文件正在由另一進程使用&#xff0c;因此該進程無法訪問此文件”。多線程訪問統一資源的異常&#xff0c;解決方案1&#xff0c;保證讀寫操作單線程執行&#xff0c;可以使用lock解決方案2&#xff0c;使用…

linux加密框架 crypto 通用算法注冊接口__crypto_register_alg注冊流程

函數介紹 __crypto_register_alg函數實現向加密框架注冊算法&#xff08;包括靜態算法和動態算法&#xff09;的功能&#xff0c;輸入參數為算法說明alg&#xff0c;注冊成功時返回算法注冊用的算法幼蟲larval&#xff0c;注冊失敗時返回失敗原因。__crypto_register_alg函數執…

spark官方文檔_Spark整合Ray思路漫談

什么是Ray之前花了大概兩到三天把Ray相關的論文&#xff0c;官網文檔看了一遍&#xff0c;同時特意去找了一些中文資料看Ray當前在國內的發展情況(以及目前國內大部分人對Ray的認知程度)。先來簡單介紹下我對Ray的認知。首先基因很重要&#xff0c;所以我們先需要探查下Ray最初…

python用http協議傳數據_python基礎 -- 簡單實現HTTP協議

標簽&#xff1a;一、直接代碼# -*- coding: utf-8 -*-import socket__author__ ‘lpe234‘__date__ ‘2015-03-12‘if __name__ ‘__main__‘:sock socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.bind((‘127.0.0.1‘, 8001))sock.listen(5)while True:connecti…

linux加密框架 crypto 算法管理 - 算法查找接口 crypto_find_alg

算法查找接口crypto_find_alg 算法實例tfm是算法的一個可運行的副本&#xff0c;因此在創建算法實例前首先要查找確認算法是否已經注冊有效&#xff0c;此時算法查找由函數crypto_find_alg實現。補充&#xff1a; struct crypto_tfm *tfm; crypto_tfm類型指針tfm可以理解為指代…

linux加密框架 crypto 算法管理 - 算法查找接口 crypto_alg_mod_lookup

參考鏈接 Linux加密框架的算法管理&#xff08;二&#xff09;_家有一希的博客-CSDN博客linux加密框架 crypto 算法管理 - 算法查找接口 crypto_find_alg_CHYabc123456hh的博客-CSDN博客 函數介紹 crypto_alg_mod_lookup函數輸入參數包括待查找的算法名name、算法類型type和算…

qt triggered信號_Qt之網絡編程UDP通信

點擊上方“Qt學視覺”&#xff0c;選擇“星標”公眾號重磅干貨&#xff0c;第一時間送達想要學習的同學們還請認真閱讀每篇文章&#xff0c;相信你一定會有所收獲UDP通信概述UDP(UserDatagramProtocol&#xff0c;用戶數據報協議)是輕量的、不可靠的、面向數據報(datagram)、無…