drivers/crypto/inside-secure/eip93/eip93-aead.c

Source file repositories/reference/linux-study-clean/drivers/crypto/inside-secure/eip93/eip93-aead.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/inside-secure/eip93/eip93-aead.c
Extension
.c
Size
21407 bytes
Lines
712
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2019 - 2021
 *
 * Richard van Schagen <vschagen@icloud.com>
 * Christian Marangi <ansuelsmth@gmail.com>
 */

#include <crypto/aead.h>
#include <crypto/aes.h>
#include <crypto/authenc.h>
#include <crypto/ctr.h>
#include <crypto/hmac.h>
#include <crypto/internal/aead.h>
#include <crypto/md5.h>
#include <crypto/null.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>

#include <crypto/internal/des.h>

#include <linux/crypto.h>
#include <linux/dma-mapping.h>

#include "eip93-aead.h"
#include "eip93-cipher.h"
#include "eip93-common.h"
#include "eip93-regs.h"

void eip93_aead_handle_result(struct crypto_async_request *async, int err)
{
	struct eip93_crypto_ctx *ctx = crypto_tfm_ctx(async->tfm);
	struct eip93_device *eip93 = ctx->eip93;
	struct aead_request *req = aead_request_cast(async);
	struct eip93_cipher_reqctx *rctx = aead_request_ctx(req);

	eip93_unmap_dma(eip93, rctx, req->src, req->dst);
	eip93_handle_result(eip93, rctx, req->iv);

	aead_request_complete(req, err);
}

static int eip93_aead_send_req(struct crypto_async_request *async)
{
	struct aead_request *req = aead_request_cast(async);
	struct eip93_cipher_reqctx *rctx = aead_request_ctx(req);
	int err;

	err = check_valid_request(rctx);
	if (err) {
		aead_request_complete(req, err);
		return err;
	}

	return eip93_send_req(async, req->iv, rctx);
}

/* Crypto aead API functions */
static int eip93_aead_cra_init(struct crypto_tfm *tfm)
{
	struct eip93_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
	struct eip93_alg_template *tmpl = container_of(tfm->__crt_alg,
				struct eip93_alg_template, alg.aead.base);

	crypto_aead_set_reqsize(__crypto_aead_cast(tfm),
				sizeof(struct eip93_cipher_reqctx));

	ctx->eip93 = tmpl->eip93;
	ctx->flags = tmpl->flags;
	ctx->type = tmpl->type;
	ctx->set_assoc = true;

	ctx->sa_record = kzalloc_obj(*ctx->sa_record);
	if (!ctx->sa_record)
		return -ENOMEM;

	return 0;
}

static void eip93_aead_cra_exit(struct crypto_tfm *tfm)
{
	struct eip93_crypto_ctx *ctx = crypto_tfm_ctx(tfm);

	dma_unmap_single(ctx->eip93->dev, ctx->sa_record_base,
			 sizeof(*ctx->sa_record), DMA_TO_DEVICE);
	kfree(ctx->sa_record);
}

static int eip93_aead_setkey(struct crypto_aead *ctfm, const u8 *key,
			     unsigned int len)

Annotation

Implementation Notes