linux/drivers/crypto/tegra/tegra-se.h

/* SPDX-License-Identifier: GPL-2.0-only
 * SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 *
 * Header file for NVIDIA Security Engine driver.
 */

#ifndef _TEGRA_SE_H
#define _TEGRA_SE_H

#include <linux/bitfield.h>
#include <linux/iommu.h>
#include <linux/host1x.h>
#include <crypto/aead.h>
#include <crypto/engine.h>
#include <crypto/hash.h>
#include <crypto/sha1.h>
#include <crypto/sha3.h>
#include <crypto/skcipher.h>

#define SE_OWNERSHIP
#define SE_OWNERSHIP_UID(x)
#define TEGRA_GPSE_ID

#define SE_STREAM_ID

#define SE_SHA_CFG
#define SE_SHA_KEY_ADDR
#define SE_SHA_KEY_DATA
#define SE_SHA_KEYMANIFEST
#define SE_SHA_CRYPTO_CFG
#define SE_SHA_KEY_DST
#define SE_SHA_SRC_KSLT
#define SE_SHA_TGT_KSLT
#define SE_SHA_MSG_LENGTH
#define SE_SHA_OPERATION
#define SE_SHA_HASH_RESULT

#define SE_SHA_ENC_MODE(x)
#define SE_SHA_ENC_MODE_SHA1
#define SE_SHA_ENC_MODE_SHA224
#define SE_SHA_ENC_MODE_SHA256
#define SE_SHA_ENC_MODE_SHA384
#define SE_SHA_ENC_MODE_SHA512
#define SE_SHA_ENC_MODE_SHA_CTX_INTEGRITY
#define SE_SHA_ENC_MODE_SHA3_224
#define SE_SHA_ENC_MODE_SHA3_256
#define SE_SHA_ENC_MODE_SHA3_384
#define SE_SHA_ENC_MODE_SHA3_512
#define SE_SHA_ENC_MODE_SHAKE128
#define SE_SHA_ENC_MODE_SHAKE256
#define SE_SHA_ENC_MODE_HMAC_SHA256_1KEY
#define SE_SHA_ENC_MODE_HMAC_SHA256_2KEY
#define SE_SHA_ENC_MODE_SM3_256

#define SE_SHA_CFG_ENC_ALG(x)
#define SE_SHA_ENC_ALG_NOP
#define SE_SHA_ENC_ALG_SHA_ENC
#define SE_SHA_ENC_ALG_RNG
#define SE_SHA_ENC_ALG_SHA
#define SE_SHA_ENC_ALG_SM3
#define SE_SHA_ENC_ALG_HMAC
#define SE_SHA_ENC_ALG_KDF
#define SE_SHA_ENC_ALG_KEY_INVLD
#define SE_SHA_ENC_ALG_KEY_INQUIRE
#define SE_SHA_ENC_ALG_INS

#define SE_SHA_OP_LASTBUF
#define SE_SHA_OP_WRSTALL

#define SE_SHA_OP_OP(x)
#define SE_SHA_OP_START
#define SE_SHA_OP_RESTART_OUT
#define SE_SHA_OP_RESTART_IN
#define SE_SHA_OP_RESTART_INOUT
#define SE_SHA_OP_DUMMY

#define SE_SHA_CFG_DEC_ALG(x)
#define SE_SHA_DEC_ALG_NOP
#define SE_SHA_DEC_ALG_AES_DEC
#define SE_SHA_DEC_ALG_HMAC
#define SE_SHA_DEC_ALG_HMAC_VERIFY

#define SE_SHA_CFG_DST(x)
#define SE_SHA_DST_MEMORY
#define SE_SHA_DST_HASH_REG
#define SE_SHA_DST_KEYTABLE
#define SE_SHA_DST_SRK

#define SE_SHA_TASK_HASH_INIT

/* AES Configuration */
#define SE_AES0_CFG
#define SE_AES0_CRYPTO_CONFIG
#define SE_AES0_KEY_DST
#define SE_AES0_OPERATION
#define SE_AES0_LINEAR_CTR
#define SE_AES0_LAST_BLOCK
#define SE_AES0_KEY_ADDR
#define SE_AES0_KEY_DATA
#define SE_AES0_CMAC_RESULT
#define SE_AES0_SRC_KSLT
#define SE_AES0_TGT_KSLT
#define SE_AES0_KEYMANIFEST
#define SE_AES0_AAD_LEN
#define SE_AES0_CRYPTO_MSG_LEN

#define SE_AES1_CFG
#define SE_AES1_CRYPTO_CONFIG
#define SE_AES1_KEY_DST
#define SE_AES1_OPERATION
#define SE_AES1_LINEAR_CTR
#define SE_AES1_LAST_BLOCK
#define SE_AES1_KEY_ADDR
#define SE_AES1_KEY_DATA
#define SE_AES1_CMAC_RESULT
#define SE_AES1_SRC_KSLT
#define SE_AES1_TGT_KSLT
#define SE_AES1_KEYMANIFEST
#define SE_AES1_AAD_LEN
#define SE_AES1_CRYPTO_MSG_LEN

#define SE_AES_CFG_ENC_MODE(x)
#define SE_AES_ENC_MODE_GMAC
#define SE_AES_ENC_MODE_GCM
#define SE_AES_ENC_MODE_GCM_FINAL
#define SE_AES_ENC_MODE_CMAC
#define SE_AES_ENC_MODE_CBC_MAC

#define SE_AES_CFG_DEC_MODE(x)
#define SE_AES_DEC_MODE_GMAC
#define SE_AES_DEC_MODE_GCM
#define SE_AES_DEC_MODE_GCM_FINAL
#define SE_AES_DEC_MODE_CBC_MAC

#define SE_AES_CFG_ENC_ALG(x)
#define SE_AES_ENC_ALG_NOP
#define SE_AES_ENC_ALG_AES_ENC
#define SE_AES_ENC_ALG_RNG
#define SE_AES_ENC_ALG_SHA
#define SE_AES_ENC_ALG_HMAC
#define SE_AES_ENC_ALG_KDF
#define SE_AES_ENC_ALG_INS

#define SE_AES_CFG_DEC_ALG(x)
#define SE_AES_DEC_ALG_NOP
#define SE_AES_DEC_ALG_AES_DEC

#define SE_AES_CFG_DST(x)
#define SE_AES_DST_MEMORY
#define SE_AES_DST_HASH_REG
#define SE_AES_DST_KEYTABLE
#define SE_AES_DST_SRK

/* AES Crypto Configuration */
#define SE_AES_KEY2_INDEX(x)
#define SE_AES_KEY_INDEX(x)

#define SE_AES_CRYPTO_CFG_SCC_DIS

#define SE_AES_CRYPTO_CFG_CTR_CNTN(x)

#define SE_AES_CRYPTO_CFG_IV_MODE(x)
#define SE_AES_IV_MODE_SWIV
#define SE_AES_IV_MODE_HWIV

#define SE_AES_CRYPTO_CFG_CORE_SEL(x)
#define SE_AES_CORE_SEL_DECRYPT
#define SE_AES_CORE_SEL_ENCRYPT

#define SE_AES_CRYPTO_CFG_IV_SEL(x)
#define SE_AES_IV_SEL_UPDATED
#define SE_AES_IV_SEL_REG
#define SE_AES_IV_SEL_RANDOM

#define SE_AES_CRYPTO_CFG_VCTRAM_SEL(x)
#define SE_AES_VCTRAM_SEL_MEMORY
#define SE_AES_VCTRAM_SEL_TWEAK
#define SE_AES_VCTRAM_SEL_AESOUT
#define SE_AES_VCTRAM_SEL_PREV_MEM

#define SE_AES_CRYPTO_CFG_INPUT_SEL(x)
#define SE_AES_INPUT_SEL_MEMORY
#define SE_AES_INPUT_SEL_RANDOM
#define SE_AES_INPUT_SEL_AESOUT
#define SE_AES_INPUT_SEL_LINEAR_CTR
#define SE_AES_INPUT_SEL_REG

#define SE_AES_CRYPTO_CFG_XOR_POS(x)
#define SE_AES_XOR_POS_BYPASS
#define SE_AES_XOR_POS_BOTH
#define SE_AES_XOR_POS_TOP
#define SE_AES_XOR_POS_BOTTOM

#define SE_AES_CRYPTO_CFG_HASH_EN(x)
#define SE_AES_HASH_DISABLE
#define SE_AES_HASH_ENABLE

#define SE_LAST_BLOCK_VAL(x)
#define SE_LAST_BLOCK_RES_BITS(x)

#define SE_AES_OP_LASTBUF
#define SE_AES_OP_WRSTALL
#define SE_AES_OP_FINAL
#define SE_AES_OP_INIT

#define SE_AES_OP_OP(x)
#define SE_AES_OP_START
#define SE_AES_OP_RESTART_OUT
#define SE_AES_OP_RESTART_IN
#define SE_AES_OP_RESTART_INOUT
#define SE_AES_OP_DUMMY

#define SE_KAC_SIZE(x)
#define SE_KAC_SIZE_128
#define SE_KAC_SIZE_192
#define SE_KAC_SIZE_256

#define SE_KAC_EXPORTABLE

#define SE_KAC_PURPOSE(x)
#define SE_KAC_ENC
#define SE_KAC_CMAC
#define SE_KAC_HMAC
#define SE_KAC_GCM_KW
#define SE_KAC_HMAC_KDK
#define SE_KAC_HMAC_KDD
#define SE_KAC_HMAC_KDD_KUW
#define SE_KAC_XTS
#define SE_KAC_GCM

#define SE_KAC_USER_NS

#define SE_AES_KEY_DST_INDEX(x)
#define SE_ADDR_HI_MSB(x)
#define SE_ADDR_HI_SZ(x)

#define SE_CFG_AES_ENCRYPT

#define SE_CFG_AES_DECRYPT

#define SE_CFG_GMAC_ENCRYPT

#define SE_CFG_GMAC_DECRYPT

#define SE_CFG_GCM_ENCRYPT

#define SE_CFG_GCM_DECRYPT

#define SE_CFG_GCM_FINAL_ENCRYPT

#define SE_CFG_GCM_FINAL_DECRYPT

#define SE_CFG_CMAC

#define SE_CFG_CBC_MAC

#define SE_CFG_INS

#define SE_CRYPTO_CFG_ECB_ENCRYPT

#define SE_CRYPTO_CFG_ECB_DECRYPT

#define SE_CRYPTO_CFG_CBC_ENCRYPT

#define SE_CRYPTO_CFG_CBC_DECRYPT

#define SE_CRYPTO_CFG_CTR

#define SE_CRYPTO_CFG_XTS_ENCRYPT

#define SE_CRYPTO_CFG_XTS_DECRYPT

#define SE_CRYPTO_CFG_XTS_DECRYPT

#define SE_CRYPTO_CFG_CBC_MAC

#define HASH_RESULT_REG_COUNT
#define CMAC_RESULT_REG_COUNT

#define SE_CRYPTO_CTR_REG_COUNT
#define SE_MAX_KEYSLOT
#define SE_MAX_MEM_ALLOC
#define SE_AES_BUFLEN
#define SE_SHA_BUFLEN

#define SHA_FIRST
#define SHA_UPDATE
#define SHA_FINAL

/* Security Engine operation modes */
enum se_aes_alg {};

enum se_hash_alg {};

struct tegra_se_alg {};

struct tegra_se_regs {};

struct tegra_se_hw {};

struct tegra_se {};

struct tegra_se_cmdbuf {};

struct tegra_se_datbuf {};

static inline int se_algname_to_algid(const char *name)
{}

/* Functions */
int tegra_init_aes(struct tegra_se *se);
int tegra_init_hash(struct tegra_se *se);
void tegra_deinit_aes(struct tegra_se *se);
void tegra_deinit_hash(struct tegra_se *se);
int tegra_key_submit(struct tegra_se *se, const u8 *key,
		     u32 keylen, u32 alg, u32 *keyid);
void tegra_key_invalidate(struct tegra_se *se, u32 keyid, u32 alg);
int tegra_se_host1x_submit(struct tegra_se *se, u32 size);

/* HOST1x OPCODES */
static inline u32 host1x_opcode_setpayload(unsigned int payload)
{}

static inline u32 host1x_opcode_incr_w(unsigned int offset)
{}

static inline u32 host1x_opcode_nonincr_w(unsigned int offset)
{}

static inline u32 host1x_opcode_incr(unsigned int offset, unsigned int count)
{}

static inline u32 host1x_opcode_nonincr(unsigned int offset, unsigned int count)
{}

static inline u32 host1x_uclass_incr_syncpt_cond_f(u32 v)
{}

static inline u32 host1x_uclass_incr_syncpt_indx_f(u32 v)
{}

static inline u32 host1x_uclass_wait_syncpt_r(void)
{}

static inline u32 host1x_uclass_incr_syncpt_r(void)
{}

#define se_host1x_opcode_incr_w(x)
#define se_host1x_opcode_nonincr_w(x)
#define se_host1x_opcode_incr(x, y)
#define se_host1x_opcode_nonincr(x, y)

#endif /*_TEGRA_SE_H*/