• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ crypto_instance_ctx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中crypto_instance_ctx函数的典型用法代码示例。如果您正苦于以下问题:C++ crypto_instance_ctx函数的具体用法?C++ crypto_instance_ctx怎么用?C++ crypto_instance_ctx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了crypto_instance_ctx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pcrypt_aead_init_tfm

static int pcrypt_aead_init_tfm(struct crypto_tfm *tfm)
{
	int cpu, cpu_index;
	struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
	struct pcrypt_instance_ctx *ictx = crypto_instance_ctx(inst);
	struct pcrypt_aead_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_aead *cipher;

	ictx->tfm_count++;

	cpu_index = ictx->tfm_count % cpumask_weight(cpu_online_mask);

	ctx->cb_cpu = cpumask_first(cpu_online_mask);
	for (cpu = 0; cpu < cpu_index; cpu++)
		ctx->cb_cpu = cpumask_next(ctx->cb_cpu, cpu_online_mask);

	cipher = crypto_spawn_aead(crypto_instance_ctx(inst));

	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	ctx->child = cipher;
	tfm->crt_aead.reqsize = sizeof(struct pcrypt_request)
		+ sizeof(struct aead_givcrypt_request)
		+ crypto_aead_reqsize(cipher);

	return 0;
}
开发者ID:0x000000FF,项目名称:edison-linux,代码行数:28,代码来源:pcrypt.c


示例2: crypto_rfc3686_free

static void crypto_rfc3686_free(struct crypto_instance *inst)
{
	struct crypto_skcipher_spawn *spawn = crypto_instance_ctx(inst);

	crypto_drop_skcipher(spawn);
	kfree(inst);
}
开发者ID:03199618,项目名称:linux,代码行数:7,代码来源:ctr.c


示例3: pcrypt_free

static void pcrypt_free(struct crypto_instance *inst)
{
	struct pcrypt_instance_ctx *ctx = crypto_instance_ctx(inst);

	crypto_drop_spawn(&ctx->spawn);
	kfree(inst);
}
开发者ID:0x000000FF,项目名称:edison-linux,代码行数:7,代码来源:pcrypt.c


示例4: crypto_ccm_init_tfm

static int crypto_ccm_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct ccm_instance_ctx *ictx = crypto_instance_ctx(inst);
	struct crypto_ccm_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_cipher *cipher;
	struct crypto_ablkcipher *ctr;
	unsigned long align;
	int err;

	cipher = crypto_spawn_cipher(&ictx->cipher);
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	ctr = crypto_spawn_skcipher(&ictx->ctr);
	err = PTR_ERR(ctr);
	if (IS_ERR(ctr))
		goto err_free_cipher;

	ctx->cipher = cipher;
	ctx->ctr = ctr;

	align = crypto_tfm_alg_alignmask(tfm);
	align &= ~(crypto_tfm_ctx_alignment() - 1);
	tfm->crt_aead.reqsize = align +
				sizeof(struct crypto_ccm_req_priv_ctx) +
				crypto_ablkcipher_reqsize(ctr);

	return 0;

err_free_cipher:
	crypto_free_cipher(cipher);
	return err;
}
开发者ID:Kanel,项目名称:CloudMAC-VAP-Driver,代码行数:34,代码来源:crypto-ccm.c


示例5: crypto_gcm_free

static void crypto_gcm_free(struct crypto_instance *inst)
{
	struct gcm_instance_ctx *ctx = crypto_instance_ctx(inst);

	crypto_drop_skcipher(&ctx->ctr);
	kfree(inst);
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:7,代码来源:gcm.c


示例6: crypto_cbc_init_tfm

static int crypto_cbc_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_spawn *spawn = crypto_instance_ctx(inst);
	struct crypto_cbc_ctx *ctx = crypto_tfm_ctx(tfm);

	switch (crypto_tfm_alg_blocksize(tfm)) {
	case 8:
		ctx->xor = xor_64;
		break;

	case 16:
		ctx->xor = xor_128;
		break;

	default:
		if (crypto_tfm_alg_blocksize(tfm) % 4)
			ctx->xor = xor_byte;
		else
			ctx->xor = xor_quad;
	}

	tfm = crypto_spawn_tfm(spawn);
	if (IS_ERR(tfm))
		return PTR_ERR(tfm);

	ctx->child = crypto_cipher_cast(tfm);
	return 0;
}
开发者ID:Voskrese,项目名称:mipsonqemu,代码行数:29,代码来源:cbc.c


示例7: crypto_rfc4543_free

static void crypto_rfc4543_free(struct crypto_instance *inst)
{
    struct crypto_rfc4543_instance_ctx *ctx = crypto_instance_ctx(inst);

    crypto_drop_aead(&ctx->aead);
    crypto_drop_skcipher(&ctx->null);

    kfree(inst);
}
开发者ID:jtcriswell,项目名称:linux256,代码行数:9,代码来源:gcm.c


示例8: crypto_ecb_init_tfm

static int crypto_ecb_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_spawn *spawn = crypto_instance_ctx(inst);
	struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(tfm);

	tfm = crypto_spawn_tfm(spawn);
	if (IS_ERR(tfm))
		return PTR_ERR(tfm);

	ctx->child = crypto_cipher_cast(tfm);
	return 0;
}
开发者ID:Voskrese,项目名称:mipsonqemu,代码行数:13,代码来源:ecb.c


示例9: aead_geniv_init

int aead_geniv_init(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_aead *aead;

	aead = crypto_spawn_aead(crypto_instance_ctx(inst));
	if (IS_ERR(aead))
		return PTR_ERR(aead);

	tfm->crt_aead.base = aead;
	tfm->crt_aead.reqsize += crypto_aead_reqsize(aead);

	return 0;
}
开发者ID:robcore,项目名称:Hulk-Kernel-V2,代码行数:14,代码来源:aead.c


示例10: skcipher_geniv_init

int skcipher_geniv_init(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_ablkcipher *cipher;

	cipher = crypto_spawn_skcipher(crypto_instance_ctx(inst));
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	tfm->crt_ablkcipher.base = cipher;
	tfm->crt_ablkcipher.reqsize += crypto_ablkcipher_reqsize(cipher);

	return 0;
}
开发者ID:1111saeid,项目名称:jb_kernel_3.0.16_htc_golfu,代码行数:14,代码来源:blkcipher.c


示例11: crypto_cts_init_tfm

static int crypto_cts_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_spawn *spawn = crypto_instance_ctx(inst);
	struct crypto_cts_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_blkcipher *cipher;

	cipher = crypto_spawn_blkcipher(spawn);
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	ctx->child = cipher;
	return 0;
}
开发者ID:JonnyH,项目名称:pandora-kernel,代码行数:14,代码来源:cts.c


示例12: cryptd_blkcipher_init_tfm

static int cryptd_blkcipher_init_tfm(struct crypto_tfm *tfm)
{
    struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
    struct cryptd_instance_ctx *ictx = crypto_instance_ctx(inst);
    struct crypto_spawn *spawn = &ictx->spawn;
    struct cryptd_blkcipher_ctx *ctx = crypto_tfm_ctx(tfm);
    struct crypto_blkcipher *cipher;

    cipher = crypto_spawn_blkcipher(spawn);
    if (IS_ERR(cipher))
        return PTR_ERR(cipher);

    ctx->child = cipher;
    tfm->crt_ablkcipher.reqsize =
        sizeof(struct cryptd_blkcipher_request_ctx);
    return 0;
}
开发者ID:274914765,项目名称:C,代码行数:17,代码来源:cryptd.c


示例13: crypto_ecb_init_tfm

static int crypto_ecb_init_tfm(struct crypto_tfm *tfm)
{
    struct crypto_instance *inst = (void *)tfm->__crt_alg;
    struct crypto_spawn *spawn = crypto_instance_ctx(inst);
    struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(tfm);
    struct crypto_cipher *cipher;

    cipher = crypto_spawn_cipher(spawn);
    if (IS_ERR(cipher))
        return PTR_ERR(cipher);

    ctx->child = cipher;
#ifdef CONFIG_CRYPTO_DEV_REALTEK
    rtl_cipher_init_ctx(tfm, &ctx->rtl_ctx);
#endif
    return 0;
}
开发者ID:jhbsz,项目名称:DIR-850L_A1,代码行数:17,代码来源:ecb.c


示例14: skcipher_geniv_init

int skcipher_geniv_init(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_ablkcipher *cipher;

#ifdef CONFIG_CRYPTO_FIPS
    if (unlikely(in_fips_err()))
        return (-EACCES);
#endif

	cipher = crypto_spawn_skcipher(crypto_instance_ctx(inst));
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	tfm->crt_ablkcipher.base = cipher;
	tfm->crt_ablkcipher.reqsize += crypto_ablkcipher_reqsize(cipher);

	return 0;
}
开发者ID:kykdev,项目名称:lolliwiz_lentislte,代码行数:19,代码来源:blkcipher.c


示例15: kzalloc

static struct crypto_instance *cryptd_alloc_instance(struct crypto_alg *alg,
                             struct cryptd_state *state)
{
    struct crypto_instance *inst;
    struct cryptd_instance_ctx *ctx;
    int err;

    inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
    if (!inst) {
        inst = ERR_PTR(-ENOMEM);
        goto out;
    }

    err = -ENAMETOOLONG;
    if (snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
             "cryptd(%s)", alg->cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
        goto out_free_inst;

    ctx = crypto_instance_ctx(inst);
    err = crypto_init_spawn(&ctx->spawn, alg, inst,
                CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
    if (err)
        goto out_free_inst;

    ctx->state = state;

    memcpy(inst->alg.cra_name, alg->cra_name, CRYPTO_MAX_ALG_NAME);

    inst->alg.cra_priority = alg->cra_priority + 50;
    inst->alg.cra_blocksize = alg->cra_blocksize;
    inst->alg.cra_alignmask = alg->cra_alignmask;

out:
    return inst;

out_free_inst:
    kfree(inst);
    inst = ERR_PTR(err);
    goto out;
}
开发者ID:274914765,项目名称:C,代码行数:40,代码来源:cryptd.c


示例16: crypto_rfc3686_init_tfm

static int crypto_rfc3686_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_skcipher_spawn *spawn = crypto_instance_ctx(inst);
	struct crypto_rfc3686_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_ablkcipher *cipher;
	unsigned long align;

	cipher = crypto_spawn_skcipher(spawn);
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	ctx->child = cipher;

	align = crypto_tfm_alg_alignmask(tfm);
	align &= ~(crypto_tfm_ctx_alignment() - 1);
	tfm->crt_ablkcipher.reqsize = align +
		sizeof(struct crypto_rfc3686_req_ctx) +
		crypto_ablkcipher_reqsize(cipher);

	return 0;
}
开发者ID:03199618,项目名称:linux,代码行数:22,代码来源:ctr.c


示例17: crypto_rfc4309_init_tfm

static int crypto_rfc4309_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct crypto_aead_spawn *spawn = crypto_instance_ctx(inst);
	struct crypto_rfc4309_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_aead *aead;
	unsigned long align;

	aead = crypto_spawn_aead(spawn);
	if (IS_ERR(aead))
		return PTR_ERR(aead);

	ctx->child = aead;

	align = crypto_aead_alignmask(aead);
	align &= ~(crypto_tfm_ctx_alignment() - 1);
	tfm->crt_aead.reqsize = sizeof(struct aead_request) +
				ALIGN(crypto_aead_reqsize(aead),
				      crypto_tfm_ctx_alignment()) +
				align + 16;

	return 0;
}
开发者ID:Kanel,项目名称:CloudMAC-VAP-Driver,代码行数:23,代码来源:crypto-ccm.c


示例18: crypto_gcm_init_tfm

static int crypto_gcm_init_tfm(struct crypto_tfm *tfm)
{
    struct crypto_instance *inst = (void *)tfm->__crt_alg;
    struct gcm_instance_ctx *ictx = crypto_instance_ctx(inst);
    struct crypto_gcm_ctx *ctx = crypto_tfm_ctx(tfm);
    struct crypto_ablkcipher *ctr;
    struct crypto_ahash *ghash;
    unsigned long align;
    int err;

    ghash = crypto_spawn_ahash(&ictx->ghash);
    if (IS_ERR(ghash))
        return PTR_ERR(ghash);

    ctr = crypto_spawn_skcipher(&ictx->ctr);
    err = PTR_ERR(ctr);
    if (IS_ERR(ctr))
        goto err_free_hash;

    ctx->ctr = ctr;
    ctx->ghash = ghash;

    align = crypto_tfm_alg_alignmask(tfm);
    align &= ~(crypto_tfm_ctx_alignment() - 1);
    tfm->crt_aead.reqsize = align +
                            offsetof(struct crypto_gcm_req_priv_ctx, u) +
                            max(sizeof(struct ablkcipher_request) +
                                crypto_ablkcipher_reqsize(ctr),
                                sizeof(struct ahash_request) +
                                crypto_ahash_reqsize(ghash));

    return 0;

err_free_hash:
    crypto_free_ahash(ghash);
    return err;
}
开发者ID:jtcriswell,项目名称:linux256,代码行数:37,代码来源:gcm.c


示例19: crypto_rfc4543_init_tfm

static int crypto_rfc4543_init_tfm(struct crypto_tfm *tfm)
{
    struct crypto_instance *inst = (void *)tfm->__crt_alg;
    struct crypto_rfc4543_instance_ctx *ictx = crypto_instance_ctx(inst);
    struct crypto_aead_spawn *spawn = &ictx->aead;
    struct crypto_rfc4543_ctx *ctx = crypto_tfm_ctx(tfm);
    struct crypto_aead *aead;
    struct crypto_blkcipher *null;
    unsigned long align;
    int err = 0;

    aead = crypto_spawn_aead(spawn);
    if (IS_ERR(aead))
        return PTR_ERR(aead);

    null = crypto_spawn_blkcipher(&ictx->null.base);
    err = PTR_ERR(null);
    if (IS_ERR(null))
        goto err_free_aead;

    ctx->child = aead;
    ctx->null = null;

    align = crypto_aead_alignmask(aead);
    align &= ~(crypto_tfm_ctx_alignment() - 1);
    tfm->crt_aead.reqsize = sizeof(struct crypto_rfc4543_req_ctx) +
                            ALIGN(crypto_aead_reqsize(aead),
                                  crypto_tfm_ctx_alignment()) +
                            align + 16;

    return 0;

err_free_aead:
    crypto_free_aead(aead);
    return err;
}
开发者ID:jtcriswell,项目名称:linux256,代码行数:36,代码来源:gcm.c


示例20: crypto_get_attr_type

static struct crypto_instance *crypto_rfc4309_alloc(struct rtattr **tb)
{
	struct crypto_attr_type *algt;
	struct crypto_instance *inst;
	struct crypto_aead_spawn *spawn;
	struct crypto_alg *alg;
	const char *ccm_name;
	int err;

	algt = crypto_get_attr_type(tb);
	if (IS_ERR(algt))
		return ERR_CAST(algt);

	if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
		return ERR_PTR(-EINVAL);

	ccm_name = crypto_attr_alg_name(tb[1]);
	if (IS_ERR(ccm_name))
		return ERR_CAST(ccm_name);

	inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
	if (!inst)
		return ERR_PTR(-ENOMEM);

	spawn = crypto_instance_ctx(inst);
	crypto_set_aead_spawn(spawn, inst);
	err = crypto_grab_aead(spawn, ccm_name, 0,
			       crypto_requires_sync(algt->type, algt->mask));
	if (err)
		goto out_free_inst;

	alg = crypto_aead_spawn_alg(spawn);

	err = -EINVAL;

	/* We only support 16-byte blocks. */
	if (alg->cra_aead.ivsize != 16)
		goto out_drop_alg;

	/* Not a stream cipher? */
	if (alg->cra_blocksize != 1)
		goto out_drop_alg;

	err = -ENAMETOOLONG;
	if (snprintf(inst->alg.cra_name, CRYPTO_MAX_ALG_NAME,
		     "rfc4309(%s)", alg->cra_name) >= CRYPTO_MAX_ALG_NAME ||
	    snprintf(inst->alg.cra_driver_name, CRYPTO_MAX_ALG_NAME,
		     "rfc4309(%s)", alg->cra_driver_name) >=
	    CRYPTO_MAX_ALG_NAME)
		goto out_drop_alg;

	inst->alg.cra_flags = CRYPTO_ALG_TYPE_AEAD;
	inst->alg.cra_flags |= alg->cra_flags & CRYPTO_ALG_ASYNC;
	inst->alg.cra_priority = alg->cra_priority;
	inst->alg.cra_blocksize = 1;
	inst->alg.cra_alignmask = alg->cra_alignmask;
	inst->alg.cra_type = &crypto_nivaead_type;

	inst->alg.cra_aead.ivsize = 8;
	inst->alg.cra_aead.maxauthsize = 16;

	inst->alg.cra_ctxsize = sizeof(struct crypto_rfc4309_ctx);

	inst->alg.cra_init = crypto_rfc4309_init_tfm;
	inst->alg.cra_exit = crypto_rfc4309_exit_tfm;

	inst->alg.cra_aead.setkey = crypto_rfc4309_setkey;
	inst->alg.cra_aead.setauthsize = crypto_rfc4309_setauthsize;
	inst->alg.cra_aead.encrypt = crypto_rfc4309_encrypt;
	inst->alg.cra_aead.decrypt = crypto_rfc4309_decrypt;

	inst->alg.cra_aead.geniv = "seqiv";

out:
	return inst;

out_drop_alg:
	crypto_drop_aead(spawn);
out_free_inst:
	kfree(inst);
	inst = ERR_PTR(err);
	goto out;
}
开发者ID:Kanel,项目名称:CloudMAC-VAP-Driver,代码行数:83,代码来源:crypto-ccm.c



注:本文中的crypto_instance_ctx函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ crypto_mod_put函数代码示例发布时间:2022-05-30
下一篇:
C++ crypto_init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap