mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
crypto: eip93 - Add Inside Secure SafeXcel EIP-93 crypto engine support
Add support for the Inside Secure SafeXcel EIP-93 Crypto Engine used on Mediatek MT7621 SoC and new Airoha SoC. EIP-93 IP supports AES/DES/3DES ciphers in ECB/CBC and CTR modes as well as authenc(HMAC(x), cipher(y)) using HMAC MD5, SHA1, SHA224 and SHA256. EIP-93 provide regs to signal support for specific chipers and the driver dynamically register only the supported one by the chip. Signed-off-by: Richard van Schagen <vschagen@icloud.com> Co-developed-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
bbbbd1d149
commit
9739f5f93b
82
drivers/crypto/inside-secure/eip93/eip93-hash.h
Normal file
82
drivers/crypto/inside-secure/eip93/eip93-hash.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0
|
||||
*
|
||||
* Copyright (C) 2019 - 2021
|
||||
*
|
||||
* Richard van Schagen <vschagen@icloud.com>
|
||||
* Christian Marangi <ansuelsmth@gmail.com
|
||||
*/
|
||||
#ifndef _EIP93_HASH_H_
|
||||
#define _EIP93_HASH_H_
|
||||
|
||||
#include <crypto/sha2.h>
|
||||
|
||||
#include "eip93-main.h"
|
||||
#include "eip93-regs.h"
|
||||
|
||||
struct eip93_hash_ctx {
|
||||
struct eip93_device *eip93;
|
||||
u32 flags;
|
||||
|
||||
u8 ipad[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
|
||||
u8 opad[SHA256_DIGEST_SIZE] __aligned(sizeof(u32));
|
||||
};
|
||||
|
||||
struct eip93_hash_reqctx {
|
||||
/* Placement is important for DMA align */
|
||||
struct {
|
||||
struct sa_record sa_record;
|
||||
struct sa_record sa_record_hmac;
|
||||
struct sa_state sa_state;
|
||||
} __aligned(CRYPTO_DMA_ALIGN);
|
||||
|
||||
dma_addr_t sa_record_base;
|
||||
dma_addr_t sa_record_hmac_base;
|
||||
dma_addr_t sa_state_base;
|
||||
|
||||
/* Don't enable HASH_FINALIZE when last block is sent */
|
||||
bool partial_hash;
|
||||
|
||||
/* Set to signal interrupt is for final packet */
|
||||
bool finalize;
|
||||
|
||||
/*
|
||||
* EIP93 requires data to be accumulated in block of 64 bytes
|
||||
* for intermediate hash calculation.
|
||||
*/
|
||||
u64 len;
|
||||
u32 data_used;
|
||||
|
||||
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
|
||||
dma_addr_t data_dma;
|
||||
|
||||
struct list_head blocks;
|
||||
};
|
||||
|
||||
struct mkt_hash_block {
|
||||
struct list_head list;
|
||||
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
|
||||
dma_addr_t data_dma;
|
||||
};
|
||||
|
||||
struct eip93_hash_export_state {
|
||||
u64 len;
|
||||
u32 data_used;
|
||||
|
||||
u32 state_len[2];
|
||||
u8 state_hash[SHA256_DIGEST_SIZE] __aligned(sizeof(u32));
|
||||
|
||||
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
|
||||
};
|
||||
|
||||
void eip93_hash_handle_result(struct crypto_async_request *async, int err);
|
||||
|
||||
extern struct eip93_alg_template eip93_alg_md5;
|
||||
extern struct eip93_alg_template eip93_alg_sha1;
|
||||
extern struct eip93_alg_template eip93_alg_sha224;
|
||||
extern struct eip93_alg_template eip93_alg_sha256;
|
||||
extern struct eip93_alg_template eip93_alg_hmac_md5;
|
||||
extern struct eip93_alg_template eip93_alg_hmac_sha1;
|
||||
extern struct eip93_alg_template eip93_alg_hmac_sha224;
|
||||
extern struct eip93_alg_template eip93_alg_hmac_sha256;
|
||||
|
||||
#endif /* _EIP93_HASH_H_ */
|
||||
Reference in New Issue
Block a user