linux/drivers/crypto/aspeed/aspeed-hace-hash.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) 2021 Aspeed Technology Inc.
 */

#include "aspeed-hace.h"
#include <crypto/engine.h>
#include <crypto/hmac.h>
#include <crypto/internal/hash.h>
#include <crypto/scatterwalk.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/string.h>

#ifdef CONFIG_CRYPTO_DEV_ASPEED_DEBUG
#define AHASH_DBG(h, fmt, ...)
#else
#define AHASH_DBG
#endif

/* Initialization Vectors for SHA-family */
static const __be32 sha1_iv[8] =;

static const __be32 sha224_iv[8] =;

static const __be32 sha256_iv[8] =;

static const __be64 sha384_iv[8] =;

static const __be64 sha512_iv[8] =;

/* The purpose of this padding is to ensure that the padded message is a
 * multiple of 512 bits (SHA1/SHA224/SHA256) or 1024 bits (SHA384/SHA512).
 * The bit "1" is appended at the end of the message followed by
 * "padlen-1" zero bits. Then a 64 bits block (SHA1/SHA224/SHA256) or
 * 128 bits block (SHA384/SHA512) equals to the message length in bits
 * is appended.
 *
 * For SHA1/SHA224/SHA256, padlen is calculated as followed:
 *  - if message length < 56 bytes then padlen = 56 - message length
 *  - else padlen = 64 + 56 - message length
 *
 * For SHA384/SHA512, padlen is calculated as followed:
 *  - if message length < 112 bytes then padlen = 112 - message length
 *  - else padlen = 128 + 112 - message length
 */
static void aspeed_ahash_fill_padding(struct aspeed_hace_dev *hace_dev,
				      struct aspeed_sham_reqctx *rctx)
{}

/*
 * Prepare DMA buffer before hardware engine
 * processing.
 */
static int aspeed_ahash_dma_prepare(struct aspeed_hace_dev *hace_dev)
{}

/*
 * Prepare DMA buffer as SG list buffer before
 * hardware engine processing.
 */
static int aspeed_ahash_dma_prepare_sg(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_ahash_complete(struct aspeed_hace_dev *hace_dev)
{}

/*
 * Copy digest to the corresponding request result.
 * This function will be called at final() stage.
 */
static int aspeed_ahash_transfer(struct aspeed_hace_dev *hace_dev)
{}

/*
 * Trigger hardware engines to do the math.
 */
static int aspeed_hace_ahash_trigger(struct aspeed_hace_dev *hace_dev,
				     aspeed_hace_fn_t resume)
{}

/*
 * HMAC resume aims to do the second pass produces
 * the final HMAC code derived from the inner hash
 * result and the outer key.
 */
static int aspeed_ahash_hmac_resume(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_ahash_req_final(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_ahash_update_resume_sg(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_ahash_update_resume(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_ahash_req_update(struct aspeed_hace_dev *hace_dev)
{}

static int aspeed_hace_hash_handle_queue(struct aspeed_hace_dev *hace_dev,
				  struct ahash_request *req)
{}

static int aspeed_ahash_do_request(struct crypto_engine *engine, void *areq)
{}

static void aspeed_ahash_prepare_request(struct crypto_engine *engine,
					 void *areq)
{}

static int aspeed_ahash_do_one(struct crypto_engine *engine, void *areq)
{}

static int aspeed_sham_update(struct ahash_request *req)
{}

static int aspeed_sham_shash_digest(struct crypto_shash *tfm, u32 flags,
				    const u8 *data, unsigned int len, u8 *out)
{}

static int aspeed_sham_final(struct ahash_request *req)
{}

static int aspeed_sham_finup(struct ahash_request *req)
{}

static int aspeed_sham_init(struct ahash_request *req)
{}

static int aspeed_sham_digest(struct ahash_request *req)
{}

static int aspeed_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
			      unsigned int keylen)
{}

static int aspeed_sham_cra_init(struct crypto_tfm *tfm)
{}

static void aspeed_sham_cra_exit(struct crypto_tfm *tfm)
{}

static int aspeed_sham_export(struct ahash_request *req, void *out)
{}

static int aspeed_sham_import(struct ahash_request *req, const void *in)
{}

static struct aspeed_hace_alg aspeed_ahash_algs[] =;

static struct aspeed_hace_alg aspeed_ahash_algs_g6[] =;

void aspeed_unregister_hace_hash_algs(struct aspeed_hace_dev *hace_dev)
{}

void aspeed_register_hace_hash_algs(struct aspeed_hace_dev *hace_dev)
{}