/* SPDX-License-Identifier: NONE */ #pragma once #include struct eip123_hw; typedef u8 eip123_digest[32]; struct eip123_result { int error; u8 fw_result_src : 5; u8 fw_result : 2; }; struct eip123_sysinfo { u32 identity; u16 memory_size; u16 nvm_anomaly_location : 12; u16 nvm_anomaly : 4; u8 fw_version_patch; u8 fw_version_minor; u8 fw_version_major; u8 hw_version_patch; u8 hw_version_minor; u8 hw_version_major; u8 host_id; }; enum eip123_hash_algo { EIP123_HASH_ALGO_MD5 = 0, EIP123_HASH_ALGO_SHA1 = 1, EIP123_HASH_ALGO_SHA224 = 2, EIP123_HASH_ALGO_SHA256 = 3, }; enum eip123_aes_mode { EIP123_AES_ECB = 0, EIP123_AES_CBC = 1, EIP123_AES_CTR = 2, EIP123_AES_ICM = 3, }; enum eip123_aes_keylen { EIP123_AES_128 = 1, EIP123_AES_192 = 2, EIP123_AES_256 = 3, }; struct eip123_asset { u32 id; u16 len; }; #define POLICY_CRYPTO_KEY_AES (1 << 0) #define POLICY_CRYPTO_KEY_CAMELLIA (1 << 1) #define POLICY_CRYPTO_KEY_3DES (1 << 2) #define POLICY_CRYPTO_KEY_MULTI2 (1 << 3) #define POLICY_CRYPTO_KEY_C2 (1 << 4) #define POLICY_CRYPTO_KEY_HMAC_SHA1_KEY (1 << 5) #define POLICY_CRYPTO_KEY_HMAC_SHA224_KEY (1 << 6) #define POLICY_CRYPTO_KEY_HMAC_SHA256_KEY (1 << 7) #define POLICY_CRYPTO_OP_ENCRYPT (1 << 12) #define POLICY_CRYPTO_OP_DECRYPT (1 << 13) #define POLICY_CRYPTO_OP_MAC (1 << 14) #define POLICY_C2_KEY_OBJECT (1 << 19) #define POLICY_SECURE_OP_KDK (1 << 21) #define POLICY_SECURE_OP_KEK_WRAP (1 << 22) #define POLICY_SECURE_OP_KEK_UNWRAP (1 << 23) #define POLICY_TRUSTED_DERIVE (1 << 24) struct eip123_hw *eip123_hw_init(struct device *dev, void __iomem *reg_base); void eip123_hw_exit(struct eip123_hw *eip); struct eip123_result eip123_hw_dma_copy(struct eip123_hw *eip, u8 *dst, u8 *src, u32 len); struct eip123_result eip123_hw_hash(struct eip123_hw *eip, u8 *msg, u32 len, eip123_digest *dst, enum eip123_hash_algo algo); struct eip123_result eip123_hw_rng(struct eip123_hw *eip, u8 *dst, u16 len); struct eip123_result eip123_hw_sysinfo(struct eip123_hw *eip, struct eip123_sysinfo *out); struct eip123_result eip123_hw_asset_search(struct eip123_hw *eip, u8 idx, struct eip123_asset *asset); struct eip123_result eip123_hw_asset_create(struct eip123_hw *eip, u32 policy, struct eip123_asset *asset); struct eip123_result eip123_hw_asset_delete(struct eip123_hw *eip, const struct eip123_asset *asset); struct eip123_result eip123_hw_asset_derive(struct eip123_hw *eip, const struct eip123_asset *load, const struct eip123_asset *key, const u8 *assoc, u16 assoc_len); struct eip123_result eip123_hw_read_pubdata(struct eip123_hw *eip, const struct eip123_asset *asset, u8 *dst); struct eip123_result eip123_hw_crypt_aes(struct eip123_hw *eip, enum eip123_aes_mode mode, const struct eip123_asset *key, const u8 *key_inline, enum eip123_aes_keylen keylen, u8 *src, u8 *dst, u32 len, bool encrypt, const u8 *iv);