内核加密机制
- linux 3.3.8
总体框架
仅显示关键结构

内核加密机制在内核中保存两个全局链表crypto_template_list和crypto_alg_list
crypto_template_list 保存所有的加密方式
- e.g cbc ecb
crypto_alg_list 保存所有的加密算法
- e.g md5 sha128 aes
crypto_template_list由各个算法通过crypto_register_template函数添加到链表中
crypto_alg_list由各个算法通过crypto_register_alg函数添加到链表中
数据结构说明
crypto_alg结构可以理解为真正保存加密接口的一个通用结构
struct list_head cra_users;
指向crypto_spawn结构所在的链表
union cra_u;
union { struct ablkcipher_alg ablkcipher; struct aead_alg aead; struct blkcipher_alg blkcipher; struct cipher_alg cipher; struct compress_alg compress; struct rng_alg rng; } cra_u;保存实际算法实现的函数接口和算法相关信息
- blkcipher_alg
struct blkcipher_alg { int (* setkey) (struct crypto_tfm *tfm, const u8 *key,unsigned int keylen); int (* encrypt) (struct blkcipher_desc *desc,struct scatterlist *dst, struct scatterlist *src,unsigned int nbytes); int (* decrypt) (struct blkcipher_desc *desc,struct scatterlist *dst, struct scatterlist *src,unsigned int nbytes); const char * geniv; unsigned int min_keysize; unsigned int max_keysize; unsigned

本文介绍了Linux内核3.3.8中的加密机制,包括总体框架、数据结构和算法流程。内核加密机制涉及两个全局链表:crypto_template_list和crypto_alg_list,分别用于保存加密方式和加密算法。加密算法的注册过程涉及到crypto_alg和crypto_template结构体,以及crypto_spawn结构。以Ecryptfs为例,展示了加密算法的使用,包括确定算法、模块注册和相关结构体的细节。
最低0.47元/天 解锁文章
1455

被折叠的 条评论
为什么被折叠?



