当前位置:首页>Linux>Linux Crypto驱动开发之对称加密算法

Linux Crypto驱动开发之对称加密算法

  • 2026-01-10 16:53:24
Linux Crypto驱动开发之对称加密算法

概述

对称加密是 Linux 内核 Crypto 框架中另一类核心算法,广泛应用于数据加密、安全传输和存储等场景。与哈希算法类似,对称加密驱动的适配过程也遵循 Crypto 引擎的统一架构,但在具体实现上存在一些关键差异。

对称加密算法(如 AES、DES、SM4 等)通常以分组密码方式工作,支持多种操作模式,如 ECB、CBC、CTR 等。在驱动开发中,我们不仅需要处理算法本身的加解密逻辑,还需要考虑数据块对齐、初始向量(IV)处理、密钥管理等额外因素。

本文将以 AES-ECB 算法为例,详细介绍对称加密算法的驱动适配流程。与哈希算法开发指南一致,本文仍采用内核中的软件实现接口模拟硬件处理过程,重点说明驱动适配的通用架构、关键数据结构和核心实现方法。实际开发时,可将示例中的软件计算部分替换为具体的硬件操作。

核心驱动

demo_crypto_core.h

对称加密算法同样需要定义专用的上下文结构和请求上下文结构,以管理算法状态和处理过程中的临时数据:

#define CIPHER_DECRYPT  BIT(0)/* 对称加密算法上下文 */structdemo_cipher_ctx {structcrypto_engine_ctxenginectx;structdemo_crypto_dev *crypto_dev;unsignedint keylen; u8 key[AES_MAX_KEY_SIZE]; u8 iv[AES_BLOCK_SIZE];/* for fallback */structcrypto_skcipher *fallback_tfm;};/* 对称加密算法请求上下文 */structdemo_cipher_rctx { u32 flags;unsignedint total_len; /* 请求总长度 */structscatterlist *sgs;/* 源散列表 */structscatterlist *sgd;/* 目的散列表 */int nsgs; /* 已映射的散列表个数 */int nsgd; /* 已映射的散列表个数 */unsignedint sg_off; /* 当前散列表偏移 */unsignedint block_size; u8 buf[HASH_BLOCK_SIZE_MAX] __aligned(sizeof(u32)); /* 缓存数据 */size_t buf_len; /* 缓存数据长度 *//* for fallback request */structskcipher_requestfallback_req;/* 对称加密算法回退请求 */};

结构体struct demo_cipher_ctx定义转换操作上下文,用于保存密钥、IV 等持久化数据。结构体struct demo_cipher_rctx定义加密请求上下文,用于管理单个请求的处理状态和数据缓存。

同样也需要定义一个宏,方便后续定义加密算法实例。

/* 对称加密算法 */enum demo_cipher_algo { CIPHER_ALGO_AES_ECB, CIPHER_ALGO_AES_CBC, CIPHER_ALGO_AES_CTR,};/* 对称加密算法实例定义 */#define DEMO_CIPHER_ALGO_INIT(cipher_algo, mode, algo_name) {\ .name = #algo_name,\ .type = ALG_TYPE_CIPHER,\    .algo = CIPHER_ALGO_##cipher_algo##_##mode,\ .alg.cipher = {\  .setkey = demo_cipher_setkey,\  .encrypt = demo_cipher_encrypt,\  .decrypt = demo_cipher_decrypt,\  .init = demo_cipher_init,\  .exit = demo_cipher_exit,\  .min_keysize = cipher_algo##_MIN_KEY_SIZE,\  .max_keysize = cipher_algo##_MAX_KEY_SIZE,\  .ivsize = cipher_algo##_BLOCK_SIZE,\  .chunksize = cipher_algo##_BLOCK_SIZE,\  .walksize = cipher_algo##_BLOCK_SIZE,\  .base = {\   .cra_name = #algo_name,\   .cra_driver_name = #algo_name"-demo",\   .cra_priority = DEMO_CRYPTO_PRIORITY,\   .cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY |\     CRYPTO_ALG_ASYNC |\     CRYPTO_ALG_NEED_FALLBACK,\   .cra_blocksize = cipher_algo##_BLOCK_SIZE,\   .cra_ctxsize = sizeof(struct demo_cipher_ctx),\   .cra_alignmask = 3,\   .cra_module = THIS_MODULE,\  } \ } \}
  • name:算法名称
  • type:算法类型
  • algo:加密具体算法,如CIPHER_ALGO_AES_ECB、CIPHER_ALGO_AES_CTR等。
  • alg.cipher:驱动需要实现的函数接口,如配置密钥、加密和解密等。
  • init:初始化加密转换对象。
  • exit:释放加密转换对象。
  • min_keysize:该算法支持的最小密钥长度。
  • max_keysize:该算法支持的最大密钥长度。
  • ivsize:初始向量(IV)长度。
  • chunksize:通常等于块大小。
  • walksize:通常等于chunksize
  • cra_name:转换算法的通用名称,如sha256。
  • cra_driver_name:转换提供者的唯一名称,如sha256-demo。
  • cra_priority:转换实现的优先级,这里需要大于内核自实现的优先级100。
  • cra_flags:转换标志,如异步标志,需要回退处理等。
  • cra_blocksize:此转换的最小块大小,如AES算法为16字节。
  • cra_ctxsize:转换操作上下文的大小,用于告知内核Crypto API需要为转换上下文分配的内存大小。
  • cra_alignmask:输入输出数据缓冲区的对齐掩码,这里值3要求word对齐。
  • cra_module:转换实现的所有者。

加密驱动

这里我们以 AES-ECB 算法为例,详细介绍对称加密驱动的实现。加密驱动需要实现算法实例定义中声明的三个核心接口:

  • setkey:设置密钥,用于将提供的密钥写入到硬件中,或存储在转换上下文中。
  • encrypt:用于加密数据块的散列表(scatterlist)。
  • decrypt:用于解密数据块的散列表(scatterlist)。

由于硬件加速引擎通常是安装块进行进行计算的,因此对于长度非块对齐或者缓存地址非word对齐的请求等交给crypto框架进行fallback处理。值得注意的是算法实例定义时需要声明回退标志,即.cra_flags添加CRYPTO_ALG_NEED_FALLBACK

算法实例初始化和释放

首先需要初始化算法实例,主要设置软件回退方案和引擎请求回调处理接口。

staticintdemo_cipher_init(struct crypto_skcipher *tfm){/* 获取算法上下文 */structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);/* 获取算法定义 */structskcipher_alg *alg = crypto_skcipher_alg(tfm);structdemo_crypto_alg *algt;/* 获取算法实例,并关联到crypto设备 */ algt = container_of(alg, struct demo_crypto_alg, alg.cipher); ctx->crypto_dev = algt->crypto_dev; dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__);/* 分配回退TFM */ ctx->fallback_tfm = crypto_alloc_skcipher(crypto_tfm_alg_name(&tfm->base), 0, CRYPTO_ALG_NEED_FALLBACK);if (IS_ERR(ctx->fallback_tfm)) {  dev_err(ctx->crypto_dev->dev, "Could not load fallback driver.\n");return PTR_ERR(ctx->fallback_tfm); } /* 设置请求上下文大小 */ crypto_skcipher_set_reqsize(tfm, sizeof(struct demo_cipher_rctx) +   crypto_skcipher_reqsize(ctx->fallback_tfm));/* 设置引擎请求回调接口 */ ctx->enginectx.op.do_one_request = demo_cipher_do_one_request; ctx->enginectx.op.prepare_request = demo_cipher_prepare_request; ctx->enginectx.op.unprepare_request = demo_cipher_unprepare_request;return0;}staticvoiddemo_cipher_exit(struct crypto_skcipher *tfm){structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm); memzero_explicit(ctx->key, ctx->keylen); crypto_free_skcipher(ctx->fallback_tfm);}

加密接口

首先是配置密钥接口,这里需要暂存密钥,另外可能进行回退处理,同样需要设置到回退tfm中。

staticintdemo_cipher_setkey(struct crypto_skcipher *tfm, const u8 *key, unsignedint keylen){structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm); dev_dbg(ctx->crypto_dev->dev, "\n\n**********************A new cipher request**********************\n"); dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__); dev_dbg(ctx->crypto_dev->dev, "%s: key[%d] = %*ph\n", __func__, keylen, keylen, key);if (keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_192 && keylen != AES_KEYSIZE_256) {return -EINVAL; } ctx->keylen = keylen;memcpy(ctx->key, key, keylen);return crypto_skcipher_setkey(ctx->fallback_tfm, key, keylen);}

接着我们需要编写回退处理函数,检查非块对齐长度的请求和非word对齐的buffer,如果是这种情形,需要进行回退:

staticintdemo_cipher_need_fallback(struct skcipher_request *req){structcrypto_skcipher *tfm = crypto_skcipher_reqtfm(req);structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);// struct demo_cipher_rctx *rctx = skcipher_request_ctx(req);unsignedint bs = crypto_skcipher_blocksize(tfm);structscatterlist *sgs, *sgd;unsignedint stodo, dtodo, len; dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__);/* 不支持0字节加解密 */if (!req->cryptlen) {return1; }/* 不支持非块对齐的sg */ len = req->cryptlen; sgs = req->src; sgd = req->dst;while (sgs && sgd) {if (!IS_ALIGNED(sgs->offset, sizeof(u32))) {returntrue;  }if (!IS_ALIGNED(sgd->offset, sizeof(u32))) {returntrue;  }  stodo = min(len, sgs->length);  dtodo = min(len, sgd->length);if (stodo % bs || dtodo % bs) {return1;  }if (stodo != dtodo) {return1;  }  len -= stodo;  sgs = sg_next(sgs);  sgd = sg_next(sgd); }return0;}staticintdemo_cipher_do_fallback(struct skcipher_request *req){structcrypto_skcipher *tfm = crypto_skcipher_reqtfm(req);structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);structdemo_cipher_rctx *rctx = skcipher_request_ctx(req);int err; dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__); skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback_tfm); skcipher_request_set_callback(&rctx->fallback_req, req->base.flags,        req->base.complete, req->base.data); skcipher_request_set_crypt(&rctx->fallback_req, req->src, req->dst,        req->cryptlen, req->iv);if (rctx->flags & CIPHER_DECRYPT) {  err = crypto_skcipher_decrypt(&rctx->fallback_req); } else {  err = crypto_skcipher_encrypt(&rctx->fallback_req); }return err;}

最后适配加解密驱动接口,检查是否需要回退,如果不需要就提交加密请求给引擎队列:

staticintdemo_cipher_encrypt(struct skcipher_request *req){structcrypto_skcipher *tfm = crypto_skcipher_reqtfm(req);structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);structdemo_cipher_rctx *rctx = skcipher_request_ctx(req); dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__); rctx->flags = 0;/* 检查是否需要fallback */if (demo_cipher_need_fallback(req)) {return demo_cipher_do_fallback(req); }/* 提交加密请求给引擎队列 */return crypto_transfer_skcipher_request_to_engine(ctx->crypto_dev->engine, req);}staticintdemo_cipher_decrypt(struct skcipher_request *req){structcrypto_skcipher *tfm = crypto_skcipher_reqtfm(req);structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);structdemo_cipher_rctx *rctx = skcipher_request_ctx(req); dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__); rctx->flags = CIPHER_DECRYPT;if (demo_cipher_need_fallback(req)) {return demo_cipher_do_fallback(req); }return crypto_transfer_skcipher_request_to_engine(ctx->crypto_dev->engine, req);}

请求处理

加密引擎框架收到请求后,会排队进行处理,调用回调接口,这里核心接口就是do_one_request

staticintdemo_cipher_do_one_request(struct crypto_engine *engine, void *areq){int err, decrypt;/* 获取原始加密请求 */structskcipher_request *req = skcipher_request_cast(areq);/* 获取加密转换 */structcrypto_skcipher *tfm = crypto_skcipher_reqtfm(req);/* 获取加密上下文 */structdemo_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);/* 获取加密请求上下文 */structdemo_cipher_rctx *rctx = skcipher_request_ctx(req);/* 获取加密算法定义 */structskcipher_alg *alg = crypto_skcipher_alg(tfm);structdemo_crypto_alg *algt;unsignedint ivsize;unsignedint bs = crypto_skcipher_blocksize(tfm);/* 获取加密算法实例 */ algt = container_of(alg, struct demo_crypto_alg, alg.cipher); dev_dbg(ctx->crypto_dev->dev, "%s\n", __func__); dev_dbg(ctx->crypto_dev->dev, "%s: algo: %s, req->cryptlen = %d\n", __func__, algt->name, req->cryptlen); rctx->total_len = ALIGN(req->cryptlen, bs); rctx->sgs = req->src; rctx->sgd = req->dst; rctx->sg_off = 0; rctx->buf_len = 0; rctx->block_size = bs; decrypt = rctx->flags & CIPHER_DECRYPT; ivsize = crypto_skcipher_ivsize(tfm);/* 加密计算 */ err = demo_cipher_compute(ctx->crypto_dev, rctx, ctx->key, ctx->keylen);if (err) {  dev_err(ctx->crypto_dev->dev, "cipher compute error\n");gotoexit; }/* 获取输出IV */if (req->iv && ivsize) {// 对于CBC/CTR等模式,需要输出IV给req->ivif (err) {   dev_err(ctx->crypto_dev->dev, "cipher get out iv error\n");gotoexit;  } }exit:/* 完成请求 */ crypto_finalize_skcipher_request(engine, req, err);return0;}

每个请求的长度为req->cryptlen,源数据放到req->src散列表中,目标数据放到req->dst中。通常如果有硬件加速引擎,就可以启动硬件,触发DMA传输,进行加解密计算。计算的结果需要通过req->dst返回给调用者,最后需要调用crypto_finalize_skcipher_request函数完成加密请求,否则会导致请求阻塞。

这里我们使用软实现进行加解密,调用内核的软实现接口:

  • aes_expandkey:密钥扩展
  • aes_decrypt:数据解密
  • aes_encrypt:数据加密
staticintdemo_cipher_compute(struct demo_crypto_dev *crypto_dev, struct demo_cipher_rctx *rctx, u8 *key, size_t keylen){int err = 0;structscatterlist *sgs, *sgd;unsignedint total_len = rctx->total_len;unsignedint bs, processed = 0;structcrypto_aes_ctxaes_ctx; dev_dbg(crypto_dev->dev, "%s\n", __func__);    sgs = rctx->sgs;    sgd = rctx->sgd; bs = rctx->block_size; err = aes_expandkey(&aes_ctx, key, keylen);if (err) {  dev_err(crypto_dev->dev, "aes expand key error\n");return err; }/* 遍历sg列表 */while (processed < total_len) {/* 非对齐应当已经fallback处理 */if (sgs->length % bs) {   dev_err(crypto_dev->dev, "sg data length must be multiple of %d\n", bs);return -EFAULT;  }for (int i = 0; i < sgs->length; i += bs) {if (rctx->flags & CIPHER_DECRYPT) {    aes_decrypt(&aes_ctx, sg_virt(sgd) + i, sg_virt(sgs) + i);   } else {    aes_encrypt(&aes_ctx, sg_virt(sgd) + i, sg_virt(sgs) + i);   }  }  processed += sgs->length;  sgs = sg_next(sgs);  sgd = sg_next(sgd);    }return0;}

最后需要进行加密算法实例的定义,并放到密码算法数组中crypto_algs。当我们进行驱动注册时,就可以将这个ecb(aes)算法注册到系统中。

structdemo_crypto_algdemo_cipher_aes_ecb = DEMO_CIPHER_ALGO_INIT(AESECBecb(aes));

驱动测试

执行模块编译,生成文件demo_crypto.kocrypto_engine.ko。然后拷贝到目标系统上,注意需要先安装引擎KO,再安装驱动KO:

$ insmod crypto_engine.ko$ insmod demo_crypto.ko[75304.994703] demo-crypto 53050000.crypto: will run requests pump with realtime priority[75305.009286] demo-crypto 53050000.crypto: Demo Crypto(V0.1) platform driver probed

如果哈希算法驱动没有问题,功能测试通过,会打印如上日志,否则会打印具体测试失败在哪一项。加密驱动加载成功后,我们可以通过命令查看是否已经注册成功:

name         : ecb(aes)driver       : ecb(aes)-demomodule       : demo_cryptopriority     : 300refcnt       : 1selftest     : passedinternal     : notype         : skcipherasync        : yesblocksize    : 16min keysize  : 16max keysize  : 32ivsize       : 16chunksize    : 16walksize     : 16

如果想查看更多测试日志,可以调整打印等级。可以看出系统测试框架会测试所有驱动接口实现,不同的消息长度,非对齐的buffer等情形:

echo 8 > /proc/sys/kernel/printk$ insmod demo_crypto.ko[ 2378.819875] demo-crypto 53050000.crypto: will run requests pump with realtime priority[ 2378.828018] demo-crypto 53050000.crypto: demo_crypto_register[ 2378.871256] demo-crypto 53050000.crypto: demo_cipher_init[ 2378.876741] demo-crypto 53050000.crypto: [ 2378.876741] [ 2378.876741] **********************A new cipher request**********************[ 2378.889372] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2378.895025] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2378.905824] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2378.911570] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2378.917782] demo-crypto 53050000.crypto: demo_cipher_do_one_request[ 2378.924111] demo-crypto 53050000.crypto: demo_cipher_do_one_request: algo: ecb(aes), req->cryptlen = 16[ 2378.933554] demo-crypto 53050000.crypto: demo_cipher_compute[ 2378.939274] demo-crypto 53050000.crypto: [ 2378.939274] [ 2378.939274] **********************A new cipher request**********************[ 2378.951849] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2378.957428] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2378.968178] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2378.973879] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2378.980079] demo-crypto 53050000.crypto: demo_cipher_do_one_request[ 2378.986392] demo-crypto 53050000.crypto: demo_cipher_do_one_request: algo: ecb(aes), req->cryptlen = 16[ 2378.995835] demo-crypto 53050000.crypto: demo_cipher_compute[ 2379.001572] demo-crypto 53050000.crypto: [ 2379.001572] [ 2379.001572] **********************A new cipher request**********************[ 2379.014128] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.019705] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.030447] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.036146] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.042376] demo-crypto 53050000.crypto: demo_cipher_do_one_request[ 2379.048649] demo-crypto 53050000.crypto: demo_cipher_do_one_request: algo: ecb(aes), req->cryptlen = 16[ 2379.058082] demo-crypto 53050000.crypto: demo_cipher_compute[ 2379.063813] demo-crypto 53050000.crypto: [ 2379.063813] [ 2379.063813] **********************A new cipher request**********************[ 2379.076368] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.081978] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.092727] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.098393] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.104622] demo-crypto 53050000.crypto: demo_cipher_do_fallback[ 2379.110678] demo-crypto 53050000.crypto: [ 2379.110678] [ 2379.110678] **********************A new cipher request**********************[ 2379.123236] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.128812] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.139557] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.145256] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.151492] demo-crypto 53050000.crypto: demo_cipher_do_one_request[ 2379.157765] demo-crypto 53050000.crypto: demo_cipher_do_one_request: algo: ecb(aes), req->cryptlen = 16[ 2379.167193] demo-crypto 53050000.crypto: demo_cipher_compute[ 2379.172927] demo-crypto 53050000.crypto: [ 2379.172927] [ 2379.172927] **********************A new cipher request**********************[ 2379.185484] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.191092] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.201837] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.207505] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.213732] demo-crypto 53050000.crypto: demo_cipher_do_fallback[ 2379.219781] demo-crypto 53050000.crypto: [ 2379.219781] [ 2379.219781] **********************A new cipher request**********************[ 2379.232335] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.237913] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.248663] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.254363] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.260548] demo-crypto 53050000.crypto: demo_cipher_do_fallback[ 2379.266617] demo-crypto 53050000.crypto: [ 2379.266617] [ 2379.266617] **********************A new cipher request**********************[ 2379.279174] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.284781] demo-crypto 53050000.crypto: demo_cipher_setkey: key[16] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f[ 2379.295525] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.301225] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.307410] demo-crypto 53050000.crypto: demo_cipher_do_fallback[ 2379.313475] demo-crypto 53050000.crypto: [ 2379.313475] [ 2379.313475] **********************A new cipher request**********************[ 2379.326038] demo-crypto 53050000.crypto: demo_cipher_setkey[ 2379.331649] demo-crypto 53050000.crypto: demo_cipher_setkey: key[24] = 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17[ 2379.344473] demo-crypto 53050000.crypto: demo_cipher_encrypt[ 2379.350139] demo-crypto 53050000.crypto: demo_cipher_need_fallback[ 2379.356373] demo-crypto 53050000.crypto: demo_cipher_do_one_request[ 2379.362682] demo-crypto 53050000.crypto: demo_cipher_do_one_request: algo: ecb(aes), req->cryptlen = 16[ 2379.372109] demo-crypto 53050000.crypto: demo_cipher_compute

另外我们也可以通过tcryp测试程序检查对称加密算法驱动实现:

$ insmod tcrypt.ko mode=10

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-10 10:29:05 HTTP/2.0 GET : https://f.mffb.com.cn/a/458980.html
  2. 运行时间 : 0.152530s [ 吞吐率:6.56req/s ] 内存消耗:5,158.55kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=a38dd82d8875a82639613e22cc650f85
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000850s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000876s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000300s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000313s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000454s ]
  6. SELECT * FROM `set` [ RunTime:0.000196s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000598s ]
  8. SELECT * FROM `article` WHERE `id` = 458980 LIMIT 1 [ RunTime:0.000490s ]
  9. UPDATE `article` SET `lasttime` = 1770690545 WHERE `id` = 458980 [ RunTime:0.013497s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000239s ]
  11. SELECT * FROM `article` WHERE `id` < 458980 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000434s ]
  12. SELECT * FROM `article` WHERE `id` > 458980 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.005769s ]
  13. SELECT * FROM `article` WHERE `id` < 458980 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001126s ]
  14. SELECT * FROM `article` WHERE `id` < 458980 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002067s ]
  15. SELECT * FROM `article` WHERE `id` < 458980 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001741s ]
0.155675s