106f751b6SCorentin Labbe /* SPDX-License-Identifier: GPL-2.0 */ 206f751b6SCorentin Labbe /* 306f751b6SCorentin Labbe * sun8i-ce.h - hardware cryptographic offloader for 406f751b6SCorentin Labbe * Allwinner H3/A64/H5/H2+/H6 SoC 506f751b6SCorentin Labbe * 606f751b6SCorentin Labbe * Copyright (C) 2016-2019 Corentin LABBE <clabbe.montjoie@gmail.com> 706f751b6SCorentin Labbe */ 806f751b6SCorentin Labbe #include <crypto/aes.h> 906f751b6SCorentin Labbe #include <crypto/des.h> 1006f751b6SCorentin Labbe #include <crypto/engine.h> 1106f751b6SCorentin Labbe #include <crypto/skcipher.h> 1206f751b6SCorentin Labbe #include <linux/atomic.h> 1306f751b6SCorentin Labbe #include <linux/debugfs.h> 1406f751b6SCorentin Labbe #include <linux/crypto.h> 154a07eab3SCorentin Labbe #include <linux/hw_random.h> 1656f6d5aeSCorentin Labbe #include <crypto/internal/hash.h> 1756f6d5aeSCorentin Labbe #include <crypto/md5.h> 185eb7e946SCorentin Labbe #include <crypto/rng.h> 19a24d22b2SEric Biggers #include <crypto/sha1.h> 20a24d22b2SEric Biggers #include <crypto/sha2.h> 2106f751b6SCorentin Labbe 2206f751b6SCorentin Labbe /* CE Registers */ 2306f751b6SCorentin Labbe #define CE_TDQ 0x00 2406f751b6SCorentin Labbe #define CE_CTR 0x04 2506f751b6SCorentin Labbe #define CE_ICR 0x08 2606f751b6SCorentin Labbe #define CE_ISR 0x0C 2706f751b6SCorentin Labbe #define CE_TLR 0x10 2806f751b6SCorentin Labbe #define CE_TSR 0x14 2906f751b6SCorentin Labbe #define CE_ESR 0x18 3006f751b6SCorentin Labbe #define CE_CSSGR 0x1C 3106f751b6SCorentin Labbe #define CE_CDSGR 0x20 3206f751b6SCorentin Labbe #define CE_CSAR 0x24 3306f751b6SCorentin Labbe #define CE_CDAR 0x28 3406f751b6SCorentin Labbe #define CE_TPR 0x2C 3506f751b6SCorentin Labbe 3606f751b6SCorentin Labbe /* Used in struct ce_task */ 3706f751b6SCorentin Labbe /* ce_task common */ 3806f751b6SCorentin Labbe #define CE_ENCRYPTION 0 3906f751b6SCorentin Labbe #define CE_DECRYPTION BIT(8) 4006f751b6SCorentin Labbe 4106f751b6SCorentin Labbe #define CE_COMM_INT BIT(31) 4206f751b6SCorentin Labbe 4306f751b6SCorentin Labbe /* ce_task symmetric */ 4406f751b6SCorentin Labbe #define CE_AES_128BITS 0 4506f751b6SCorentin Labbe #define CE_AES_192BITS 1 4606f751b6SCorentin Labbe #define CE_AES_256BITS 2 4706f751b6SCorentin Labbe 4806f751b6SCorentin Labbe #define CE_OP_ECB 0 4906f751b6SCorentin Labbe #define CE_OP_CBC (1 << 8) 5006f751b6SCorentin Labbe 5106f751b6SCorentin Labbe #define CE_ALG_AES 0 5206f751b6SCorentin Labbe #define CE_ALG_DES 1 5306f751b6SCorentin Labbe #define CE_ALG_3DES 2 5456f6d5aeSCorentin Labbe #define CE_ALG_MD5 16 5556f6d5aeSCorentin Labbe #define CE_ALG_SHA1 17 5656f6d5aeSCorentin Labbe #define CE_ALG_SHA224 18 5756f6d5aeSCorentin Labbe #define CE_ALG_SHA256 19 5856f6d5aeSCorentin Labbe #define CE_ALG_SHA384 20 5956f6d5aeSCorentin Labbe #define CE_ALG_SHA512 21 604a07eab3SCorentin Labbe #define CE_ALG_TRNG 48 615eb7e946SCorentin Labbe #define CE_ALG_PRNG 49 624a07eab3SCorentin Labbe #define CE_ALG_TRNG_V2 0x1c 635eb7e946SCorentin Labbe #define CE_ALG_PRNG_V2 0x1d 6406f751b6SCorentin Labbe 6506f751b6SCorentin Labbe /* Used in ce_variant */ 6606f751b6SCorentin Labbe #define CE_ID_NOTSUPP 0xFF 6706f751b6SCorentin Labbe 6806f751b6SCorentin Labbe #define CE_ID_CIPHER_AES 0 6906f751b6SCorentin Labbe #define CE_ID_CIPHER_DES 1 7006f751b6SCorentin Labbe #define CE_ID_CIPHER_DES3 2 7106f751b6SCorentin Labbe #define CE_ID_CIPHER_MAX 3 7206f751b6SCorentin Labbe 7356f6d5aeSCorentin Labbe #define CE_ID_HASH_MD5 0 7456f6d5aeSCorentin Labbe #define CE_ID_HASH_SHA1 1 7556f6d5aeSCorentin Labbe #define CE_ID_HASH_SHA224 2 7656f6d5aeSCorentin Labbe #define CE_ID_HASH_SHA256 3 7756f6d5aeSCorentin Labbe #define CE_ID_HASH_SHA384 4 7856f6d5aeSCorentin Labbe #define CE_ID_HASH_SHA512 5 7956f6d5aeSCorentin Labbe #define CE_ID_HASH_MAX 6 8056f6d5aeSCorentin Labbe 8106f751b6SCorentin Labbe #define CE_ID_OP_ECB 0 8206f751b6SCorentin Labbe #define CE_ID_OP_CBC 1 8306f751b6SCorentin Labbe #define CE_ID_OP_MAX 2 8406f751b6SCorentin Labbe 8506f751b6SCorentin Labbe /* Used in CE registers */ 8606f751b6SCorentin Labbe #define CE_ERR_ALGO_NOTSUP BIT(0) 8706f751b6SCorentin Labbe #define CE_ERR_DATALEN BIT(1) 8806f751b6SCorentin Labbe #define CE_ERR_KEYSRAM BIT(2) 8906f751b6SCorentin Labbe #define CE_ERR_ADDR_INVALID BIT(5) 9006f751b6SCorentin Labbe #define CE_ERR_KEYLADDER BIT(6) 9106f751b6SCorentin Labbe 92e66862e6SCorentin Labbe #define ESR_H3 0 93e66862e6SCorentin Labbe #define ESR_A64 1 94e66862e6SCorentin Labbe #define ESR_R40 2 95e66862e6SCorentin Labbe #define ESR_H5 3 96e66862e6SCorentin Labbe #define ESR_H6 4 9783f50f29SCorentin Labbe #define ESR_D1 5 98e66862e6SCorentin Labbe 995eb7e946SCorentin Labbe #define PRNG_DATA_SIZE (160 / 8) 1005eb7e946SCorentin Labbe #define PRNG_SEED_SIZE DIV_ROUND_UP(175, 8) 1015eb7e946SCorentin Labbe #define PRNG_LD BIT(17) 1025eb7e946SCorentin Labbe 10306f751b6SCorentin Labbe #define CE_DIE_ID_SHIFT 16 10406f751b6SCorentin Labbe #define CE_DIE_ID_MASK 0x07 10506f751b6SCorentin Labbe 10606f751b6SCorentin Labbe #define MAX_SG 8 10706f751b6SCorentin Labbe 108f81c1d4aSSamuel Holland #define CE_MAX_CLOCKS 4 10906f751b6SCorentin Labbe 11006f751b6SCorentin Labbe #define MAXFLOW 4 11106f751b6SCorentin Labbe 11206f751b6SCorentin Labbe /* 11306f751b6SCorentin Labbe * struct ce_clock - Describe clocks used by sun8i-ce 11406f751b6SCorentin Labbe * @name: Name of clock needed by this variant 11506f751b6SCorentin Labbe * @freq: Frequency to set for each clock 11606f751b6SCorentin Labbe * @max_freq: Maximum frequency for each clock (generally given by datasheet) 11706f751b6SCorentin Labbe */ 11806f751b6SCorentin Labbe struct ce_clock { 11906f751b6SCorentin Labbe const char *name; 12006f751b6SCorentin Labbe unsigned long freq; 12106f751b6SCorentin Labbe unsigned long max_freq; 12206f751b6SCorentin Labbe }; 12306f751b6SCorentin Labbe 12406f751b6SCorentin Labbe /* 12506f751b6SCorentin Labbe * struct ce_variant - Describe CE capability for each variant hardware 12606f751b6SCorentin Labbe * @alg_cipher: list of supported ciphers. for each CE_ID_ this will give the 12706f751b6SCorentin Labbe * coresponding CE_ALG_XXX value 12856f6d5aeSCorentin Labbe * @alg_hash: list of supported hashes. for each CE_ID_ this will give the 12956f6d5aeSCorentin Labbe * corresponding CE_ALG_XXX value 13006f751b6SCorentin Labbe * @op_mode: list of supported block modes 1316b4f76c2SCorentin Labbe * @cipher_t_dlen_in_bytes: Does the request size for cipher is in 13206f751b6SCorentin Labbe * bytes or words 13356f6d5aeSCorentin Labbe * @hash_t_dlen_in_bytes: Does the request size for hash is in 13456f6d5aeSCorentin Labbe * bits or words 1355eb7e946SCorentin Labbe * @prng_t_dlen_in_bytes: Does the request size for PRNG is in 1365eb7e946SCorentin Labbe * bytes or words 1374a07eab3SCorentin Labbe * @trng_t_dlen_in_bytes: Does the request size for TRNG is in 1384a07eab3SCorentin Labbe * bytes or words 13906f751b6SCorentin Labbe * @ce_clks: list of clocks needed by this variant 140e66862e6SCorentin Labbe * @esr: The type of error register 1415eb7e946SCorentin Labbe * @prng: The CE_ALG_XXX value for the PRNG 1424a07eab3SCorentin Labbe * @trng: The CE_ALG_XXX value for the TRNG 14306f751b6SCorentin Labbe */ 14406f751b6SCorentin Labbe struct ce_variant { 14506f751b6SCorentin Labbe char alg_cipher[CE_ID_CIPHER_MAX]; 14656f6d5aeSCorentin Labbe char alg_hash[CE_ID_HASH_MAX]; 14706f751b6SCorentin Labbe u32 op_mode[CE_ID_OP_MAX]; 1486b4f76c2SCorentin Labbe bool cipher_t_dlen_in_bytes; 14956f6d5aeSCorentin Labbe bool hash_t_dlen_in_bits; 1505eb7e946SCorentin Labbe bool prng_t_dlen_in_bytes; 1514a07eab3SCorentin Labbe bool trng_t_dlen_in_bytes; 15206f751b6SCorentin Labbe struct ce_clock ce_clks[CE_MAX_CLOCKS]; 153e66862e6SCorentin Labbe int esr; 1545eb7e946SCorentin Labbe unsigned char prng; 1554a07eab3SCorentin Labbe unsigned char trng; 15606f751b6SCorentin Labbe }; 15706f751b6SCorentin Labbe 15806f751b6SCorentin Labbe struct sginfo { 15993c7f4d3SCorentin Labbe __le32 addr; 16093c7f4d3SCorentin Labbe __le32 len; 16106f751b6SCorentin Labbe } __packed; 16206f751b6SCorentin Labbe 16306f751b6SCorentin Labbe /* 16406f751b6SCorentin Labbe * struct ce_task - CE Task descriptor 16506f751b6SCorentin Labbe * The structure of this descriptor could be found in the datasheet 16606f751b6SCorentin Labbe */ 16706f751b6SCorentin Labbe struct ce_task { 16893c7f4d3SCorentin Labbe __le32 t_id; 16993c7f4d3SCorentin Labbe __le32 t_common_ctl; 17093c7f4d3SCorentin Labbe __le32 t_sym_ctl; 17193c7f4d3SCorentin Labbe __le32 t_asym_ctl; 17293c7f4d3SCorentin Labbe __le32 t_key; 17393c7f4d3SCorentin Labbe __le32 t_iv; 17493c7f4d3SCorentin Labbe __le32 t_ctr; 17593c7f4d3SCorentin Labbe __le32 t_dlen; 17606f751b6SCorentin Labbe struct sginfo t_src[MAX_SG]; 17706f751b6SCorentin Labbe struct sginfo t_dst[MAX_SG]; 17893c7f4d3SCorentin Labbe __le32 next; 17993c7f4d3SCorentin Labbe __le32 reserved[3]; 18006f751b6SCorentin Labbe } __packed __aligned(8); 18106f751b6SCorentin Labbe 18206f751b6SCorentin Labbe /* 18306f751b6SCorentin Labbe * struct sun8i_ce_flow - Information used by each flow 18406f751b6SCorentin Labbe * @engine: ptr to the crypto_engine for this flow 18506f751b6SCorentin Labbe * @complete: completion for the current task on this flow 18606f751b6SCorentin Labbe * @status: set to 1 by interrupt if task is done 18706f751b6SCorentin Labbe * @t_phy: Physical address of task 18806f751b6SCorentin Labbe * @tl: pointer to the current ce_task for this flow 18922f7c2f8SCorentin Labbe * @backup_iv: buffer which contain the next IV to store 19022f7c2f8SCorentin Labbe * @bounce_iv: buffer which contain the IV 19106f751b6SCorentin Labbe * @stat_req: number of request done by this flow 19206f751b6SCorentin Labbe */ 19306f751b6SCorentin Labbe struct sun8i_ce_flow { 19406f751b6SCorentin Labbe struct crypto_engine *engine; 19506f751b6SCorentin Labbe struct completion complete; 19606f751b6SCorentin Labbe int status; 19706f751b6SCorentin Labbe dma_addr_t t_phy; 19806f751b6SCorentin Labbe int timeout; 19906f751b6SCorentin Labbe struct ce_task *tl; 20022f7c2f8SCorentin Labbe void *backup_iv; 20122f7c2f8SCorentin Labbe void *bounce_iv; 20206f751b6SCorentin Labbe #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG 20306f751b6SCorentin Labbe unsigned long stat_req; 20406f751b6SCorentin Labbe #endif 20506f751b6SCorentin Labbe }; 20606f751b6SCorentin Labbe 20706f751b6SCorentin Labbe /* 20806f751b6SCorentin Labbe * struct sun8i_ce_dev - main container for all this driver information 20906f751b6SCorentin Labbe * @base: base address of CE 21006f751b6SCorentin Labbe * @ceclks: clocks used by CE 21106f751b6SCorentin Labbe * @reset: pointer to reset controller 21206f751b6SCorentin Labbe * @dev: the platform device 21306f751b6SCorentin Labbe * @mlock: Control access to device registers 2145eb7e946SCorentin Labbe * @rnglock: Control access to the RNG (dedicated channel 3) 21506f751b6SCorentin Labbe * @chanlist: array of all flow 21606f751b6SCorentin Labbe * @flow: flow to use in next request 21706f751b6SCorentin Labbe * @variant: pointer to variant specific data 21806f751b6SCorentin Labbe * @dbgfs_dir: Debugfs dentry for statistic directory 21906f751b6SCorentin Labbe * @dbgfs_stats: Debugfs dentry for statistic counters 22006f751b6SCorentin Labbe */ 22106f751b6SCorentin Labbe struct sun8i_ce_dev { 22206f751b6SCorentin Labbe void __iomem *base; 22306f751b6SCorentin Labbe struct clk *ceclks[CE_MAX_CLOCKS]; 22406f751b6SCorentin Labbe struct reset_control *reset; 22506f751b6SCorentin Labbe struct device *dev; 22606f751b6SCorentin Labbe struct mutex mlock; 2275eb7e946SCorentin Labbe struct mutex rnglock; 22806f751b6SCorentin Labbe struct sun8i_ce_flow *chanlist; 22906f751b6SCorentin Labbe atomic_t flow; 23006f751b6SCorentin Labbe const struct ce_variant *variant; 23106f751b6SCorentin Labbe #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG 23206f751b6SCorentin Labbe struct dentry *dbgfs_dir; 23306f751b6SCorentin Labbe struct dentry *dbgfs_stats; 23406f751b6SCorentin Labbe #endif 2354a07eab3SCorentin Labbe #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG 2364a07eab3SCorentin Labbe struct hwrng trng; 2374a07eab3SCorentin Labbe #ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG 2384a07eab3SCorentin Labbe unsigned long hwrng_stat_req; 2394a07eab3SCorentin Labbe unsigned long hwrng_stat_bytes; 2404a07eab3SCorentin Labbe #endif 2414a07eab3SCorentin Labbe #endif 24206f751b6SCorentin Labbe }; 24306f751b6SCorentin Labbe 24406f751b6SCorentin Labbe /* 24506f751b6SCorentin Labbe * struct sun8i_cipher_req_ctx - context for a skcipher request 24606f751b6SCorentin Labbe * @op_dir: direction (encrypt vs decrypt) for this request 24706f751b6SCorentin Labbe * @flow: the flow to use for this request 248a216f8d5SCorentin Labbe * @ivlen: size of bounce_iv 2490605fa0fSCorentin Labbe * @nr_sgs: The number of source SG (as given by dma_map_sg()) 2500605fa0fSCorentin Labbe * @nr_sgd: The number of destination SG (as given by dma_map_sg()) 2510605fa0fSCorentin Labbe * @addr_iv: The IV addr returned by dma_map_single, need to unmap later 2520605fa0fSCorentin Labbe * @addr_key: The key addr returned by dma_map_single, need to unmap later 25331abd3ebSArd Biesheuvel * @fallback_req: request struct for invoking the fallback skcipher TFM 25406f751b6SCorentin Labbe */ 25506f751b6SCorentin Labbe struct sun8i_cipher_req_ctx { 25606f751b6SCorentin Labbe u32 op_dir; 25706f751b6SCorentin Labbe int flow; 258a216f8d5SCorentin Labbe unsigned int ivlen; 2590605fa0fSCorentin Labbe int nr_sgs; 2600605fa0fSCorentin Labbe int nr_sgd; 2610605fa0fSCorentin Labbe dma_addr_t addr_iv; 2620605fa0fSCorentin Labbe dma_addr_t addr_key; 26331abd3ebSArd Biesheuvel struct skcipher_request fallback_req; // keep at the end 26406f751b6SCorentin Labbe }; 26506f751b6SCorentin Labbe 26606f751b6SCorentin Labbe /* 26706f751b6SCorentin Labbe * struct sun8i_cipher_tfm_ctx - context for a skcipher TFM 26806f751b6SCorentin Labbe * @key: pointer to key data 26906f751b6SCorentin Labbe * @keylen: len of the key 27006f751b6SCorentin Labbe * @ce: pointer to the private data of driver handling this TFM 27106f751b6SCorentin Labbe * @fallback_tfm: pointer to the fallback TFM 27206f751b6SCorentin Labbe */ 27306f751b6SCorentin Labbe struct sun8i_cipher_tfm_ctx { 27406f751b6SCorentin Labbe u32 *key; 27506f751b6SCorentin Labbe u32 keylen; 27606f751b6SCorentin Labbe struct sun8i_ce_dev *ce; 27731abd3ebSArd Biesheuvel struct crypto_skcipher *fallback_tfm; 27806f751b6SCorentin Labbe }; 27906f751b6SCorentin Labbe 28006f751b6SCorentin Labbe /* 28156f6d5aeSCorentin Labbe * struct sun8i_ce_hash_tfm_ctx - context for an ahash TFM 28256f6d5aeSCorentin Labbe * @ce: pointer to the private data of driver handling this TFM 28356f6d5aeSCorentin Labbe * @fallback_tfm: pointer to the fallback TFM 28456f6d5aeSCorentin Labbe */ 28556f6d5aeSCorentin Labbe struct sun8i_ce_hash_tfm_ctx { 28656f6d5aeSCorentin Labbe struct sun8i_ce_dev *ce; 28756f6d5aeSCorentin Labbe struct crypto_ahash *fallback_tfm; 28856f6d5aeSCorentin Labbe }; 28956f6d5aeSCorentin Labbe 29056f6d5aeSCorentin Labbe /* 29156f6d5aeSCorentin Labbe * struct sun8i_ce_hash_reqctx - context for an ahash request 29256f6d5aeSCorentin Labbe * @fallback_req: pre-allocated fallback request 29356f6d5aeSCorentin Labbe * @flow: the flow to use for this request 29456f6d5aeSCorentin Labbe */ 29556f6d5aeSCorentin Labbe struct sun8i_ce_hash_reqctx { 29656f6d5aeSCorentin Labbe struct ahash_request fallback_req; 29756f6d5aeSCorentin Labbe int flow; 29856f6d5aeSCorentin Labbe }; 29956f6d5aeSCorentin Labbe 30056f6d5aeSCorentin Labbe /* 3015eb7e946SCorentin Labbe * struct sun8i_ce_prng_ctx - context for PRNG TFM 3025eb7e946SCorentin Labbe * @seed: The seed to use 3035eb7e946SCorentin Labbe * @slen: The size of the seed 3045eb7e946SCorentin Labbe */ 3055eb7e946SCorentin Labbe struct sun8i_ce_rng_tfm_ctx { 3065eb7e946SCorentin Labbe void *seed; 3075eb7e946SCorentin Labbe unsigned int slen; 3085eb7e946SCorentin Labbe }; 3095eb7e946SCorentin Labbe 3105eb7e946SCorentin Labbe /* 31106f751b6SCorentin Labbe * struct sun8i_ce_alg_template - crypto_alg template 31206f751b6SCorentin Labbe * @type: the CRYPTO_ALG_TYPE for this template 31306f751b6SCorentin Labbe * @ce_algo_id: the CE_ID for this template 31406f751b6SCorentin Labbe * @ce_blockmode: the type of block operation CE_ID 31506f751b6SCorentin Labbe * @ce: pointer to the sun8i_ce_dev structure associated with 31606f751b6SCorentin Labbe * this template 31706f751b6SCorentin Labbe * @alg: one of sub struct must be used 31806f751b6SCorentin Labbe * @stat_req: number of request done on this template 3195fbab10dSCorentin Labbe * @stat_fb: number of request which has fallbacked 3205c394170SCorentin Labbe * @stat_bytes: total data size done by this template 32106f751b6SCorentin Labbe */ 32206f751b6SCorentin Labbe struct sun8i_ce_alg_template { 32306f751b6SCorentin Labbe u32 type; 32406f751b6SCorentin Labbe u32 ce_algo_id; 32506f751b6SCorentin Labbe u32 ce_blockmode; 32606f751b6SCorentin Labbe struct sun8i_ce_dev *ce; 32706f751b6SCorentin Labbe union { 328*07e34cd3SHerbert Xu struct skcipher_engine_alg skcipher; 329*07e34cd3SHerbert Xu struct ahash_engine_alg hash; 3305eb7e946SCorentin Labbe struct rng_alg rng; 33106f751b6SCorentin Labbe } alg; 33206f751b6SCorentin Labbe unsigned long stat_req; 33306f751b6SCorentin Labbe unsigned long stat_fb; 3345c394170SCorentin Labbe unsigned long stat_bytes; 335aff388f7SCorentin Labbe unsigned long stat_fb_maxsg; 336aff388f7SCorentin Labbe unsigned long stat_fb_leniv; 337aff388f7SCorentin Labbe unsigned long stat_fb_len0; 338aff388f7SCorentin Labbe unsigned long stat_fb_mod16; 339aff388f7SCorentin Labbe unsigned long stat_fb_srcali; 340aff388f7SCorentin Labbe unsigned long stat_fb_srclen; 341aff388f7SCorentin Labbe unsigned long stat_fb_dstali; 342aff388f7SCorentin Labbe unsigned long stat_fb_dstlen; 343aff388f7SCorentin Labbe char fbname[CRYPTO_MAX_ALG_NAME]; 34406f751b6SCorentin Labbe }; 34506f751b6SCorentin Labbe 34606f751b6SCorentin Labbe int sun8i_ce_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, 34706f751b6SCorentin Labbe unsigned int keylen); 34806f751b6SCorentin Labbe int sun8i_ce_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, 34906f751b6SCorentin Labbe unsigned int keylen); 35006f751b6SCorentin Labbe int sun8i_ce_cipher_init(struct crypto_tfm *tfm); 35106f751b6SCorentin Labbe void sun8i_ce_cipher_exit(struct crypto_tfm *tfm); 352*07e34cd3SHerbert Xu int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq); 35306f751b6SCorentin Labbe int sun8i_ce_skdecrypt(struct skcipher_request *areq); 35406f751b6SCorentin Labbe int sun8i_ce_skencrypt(struct skcipher_request *areq); 35506f751b6SCorentin Labbe 35606f751b6SCorentin Labbe int sun8i_ce_get_engine_number(struct sun8i_ce_dev *ce); 35706f751b6SCorentin Labbe 35806f751b6SCorentin Labbe int sun8i_ce_run_task(struct sun8i_ce_dev *ce, int flow, const char *name); 35956f6d5aeSCorentin Labbe 360*07e34cd3SHerbert Xu int sun8i_ce_hash_init_tfm(struct crypto_ahash *tfm); 361*07e34cd3SHerbert Xu void sun8i_ce_hash_exit_tfm(struct crypto_ahash *tfm); 36256f6d5aeSCorentin Labbe int sun8i_ce_hash_init(struct ahash_request *areq); 36356f6d5aeSCorentin Labbe int sun8i_ce_hash_export(struct ahash_request *areq, void *out); 36456f6d5aeSCorentin Labbe int sun8i_ce_hash_import(struct ahash_request *areq, const void *in); 36556f6d5aeSCorentin Labbe int sun8i_ce_hash_final(struct ahash_request *areq); 36656f6d5aeSCorentin Labbe int sun8i_ce_hash_update(struct ahash_request *areq); 36756f6d5aeSCorentin Labbe int sun8i_ce_hash_finup(struct ahash_request *areq); 36856f6d5aeSCorentin Labbe int sun8i_ce_hash_digest(struct ahash_request *areq); 36956f6d5aeSCorentin Labbe int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq); 3705eb7e946SCorentin Labbe 3715eb7e946SCorentin Labbe int sun8i_ce_prng_generate(struct crypto_rng *tfm, const u8 *src, 3725eb7e946SCorentin Labbe unsigned int slen, u8 *dst, unsigned int dlen); 3735eb7e946SCorentin Labbe int sun8i_ce_prng_seed(struct crypto_rng *tfm, const u8 *seed, unsigned int slen); 3745eb7e946SCorentin Labbe void sun8i_ce_prng_exit(struct crypto_tfm *tfm); 3755eb7e946SCorentin Labbe int sun8i_ce_prng_init(struct crypto_tfm *tfm); 3764a07eab3SCorentin Labbe 3774a07eab3SCorentin Labbe int sun8i_ce_hwrng_register(struct sun8i_ce_dev *ce); 3784a07eab3SCorentin Labbe void sun8i_ce_hwrng_unregister(struct sun8i_ce_dev *ce); 379