mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-19 09:52:31 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -14,145 +14,145 @@
|
||||
#endif
|
||||
|
||||
/* API extensions for linux */
|
||||
#define CRYPTO_HMAC_MAX_KEY_LEN 512
|
||||
#define CRYPTO_CIPHER_MAX_KEY_LEN 64
|
||||
#define CRYPTO_HMAC_MAX_KEY_LEN 512
|
||||
#define CRYPTO_CIPHER_MAX_KEY_LEN 64
|
||||
|
||||
/* All the supported algorithms
|
||||
*/
|
||||
enum cryptodev_crypto_op_t {
|
||||
CRYPTO_DES_CBC = 1,
|
||||
CRYPTO_3DES_CBC = 2,
|
||||
CRYPTO_BLF_CBC = 3,
|
||||
CRYPTO_CAST_CBC = 4,
|
||||
CRYPTO_SKIPJACK_CBC = 5,
|
||||
CRYPTO_MD5_HMAC = 6,
|
||||
CRYPTO_SHA1_HMAC = 7,
|
||||
CRYPTO_RIPEMD160_HMAC = 8,
|
||||
CRYPTO_MD5_KPDK = 9,
|
||||
CRYPTO_SHA1_KPDK = 10,
|
||||
CRYPTO_RIJNDAEL128_CBC = 11,
|
||||
CRYPTO_AES_CBC = CRYPTO_RIJNDAEL128_CBC,
|
||||
CRYPTO_ARC4 = 12,
|
||||
CRYPTO_MD5 = 13,
|
||||
CRYPTO_SHA1 = 14,
|
||||
CRYPTO_DEFLATE_COMP = 15,
|
||||
CRYPTO_NULL = 16,
|
||||
CRYPTO_LZS_COMP = 17,
|
||||
CRYPTO_SHA2_256_HMAC = 18,
|
||||
CRYPTO_SHA2_384_HMAC = 19,
|
||||
CRYPTO_SHA2_512_HMAC = 20,
|
||||
CRYPTO_AES_CTR = 21,
|
||||
CRYPTO_AES_XTS = 22,
|
||||
CRYPTO_AES_ECB = 23,
|
||||
CRYPTO_AES_GCM = 50,
|
||||
CRYPTO_DES_CBC = 1,
|
||||
CRYPTO_3DES_CBC = 2,
|
||||
CRYPTO_BLF_CBC = 3,
|
||||
CRYPTO_CAST_CBC = 4,
|
||||
CRYPTO_SKIPJACK_CBC = 5,
|
||||
CRYPTO_MD5_HMAC = 6,
|
||||
CRYPTO_SHA1_HMAC = 7,
|
||||
CRYPTO_RIPEMD160_HMAC = 8,
|
||||
CRYPTO_MD5_KPDK = 9,
|
||||
CRYPTO_SHA1_KPDK = 10,
|
||||
CRYPTO_RIJNDAEL128_CBC = 11,
|
||||
CRYPTO_AES_CBC = CRYPTO_RIJNDAEL128_CBC,
|
||||
CRYPTO_ARC4 = 12,
|
||||
CRYPTO_MD5 = 13,
|
||||
CRYPTO_SHA1 = 14,
|
||||
CRYPTO_DEFLATE_COMP = 15,
|
||||
CRYPTO_NULL = 16,
|
||||
CRYPTO_LZS_COMP = 17,
|
||||
CRYPTO_SHA2_256_HMAC = 18,
|
||||
CRYPTO_SHA2_384_HMAC = 19,
|
||||
CRYPTO_SHA2_512_HMAC = 20,
|
||||
CRYPTO_AES_CTR = 21,
|
||||
CRYPTO_AES_XTS = 22,
|
||||
CRYPTO_AES_ECB = 23,
|
||||
CRYPTO_AES_GCM = 50,
|
||||
|
||||
CRYPTO_CAMELLIA_CBC = 101,
|
||||
CRYPTO_RIPEMD160,
|
||||
CRYPTO_SHA2_224,
|
||||
CRYPTO_SHA2_256,
|
||||
CRYPTO_SHA2_384,
|
||||
CRYPTO_SHA2_512,
|
||||
CRYPTO_SHA2_224_HMAC,
|
||||
CRYPTO_TLS11_AES_CBC_HMAC_SHA1,
|
||||
CRYPTO_TLS12_AES_CBC_HMAC_SHA256,
|
||||
CRYPTO_CAMELLIA_CBC = 101,
|
||||
CRYPTO_RIPEMD160,
|
||||
CRYPTO_SHA2_224,
|
||||
CRYPTO_SHA2_256,
|
||||
CRYPTO_SHA2_384,
|
||||
CRYPTO_SHA2_512,
|
||||
CRYPTO_SHA2_224_HMAC,
|
||||
CRYPTO_TLS11_AES_CBC_HMAC_SHA1,
|
||||
CRYPTO_TLS12_AES_CBC_HMAC_SHA256,
|
||||
|
||||
CRYPTO_RK_DES_ECB = 150,
|
||||
CRYPTO_RK_DES_CBC,
|
||||
CRYPTO_RK_DES_CFB,
|
||||
CRYPTO_RK_DES_OFB,
|
||||
CRYPTO_RK_3DES_ECB,
|
||||
CRYPTO_RK_3DES_CBC,
|
||||
CRYPTO_RK_3DES_CFB,
|
||||
CRYPTO_RK_3DES_OFB,
|
||||
CRYPTO_RK_SM4_ECB,
|
||||
CRYPTO_RK_SM4_CBC,
|
||||
CRYPTO_RK_SM4_CFB,
|
||||
CRYPTO_RK_SM4_OFB,
|
||||
CRYPTO_RK_SM4_CTS,
|
||||
CRYPTO_RK_SM4_CTR,
|
||||
CRYPTO_RK_SM4_XTS,
|
||||
CRYPTO_RK_SM4_CCM,
|
||||
CRYPTO_RK_SM4_GCM,
|
||||
CRYPTO_RK_SM4_CMAC,
|
||||
CRYPTO_RK_SM4_CBC_MAC,
|
||||
CRYPTO_RK_AES_ECB,
|
||||
CRYPTO_RK_AES_CBC,
|
||||
CRYPTO_RK_AES_CFB,
|
||||
CRYPTO_RK_AES_OFB,
|
||||
CRYPTO_RK_AES_CTS,
|
||||
CRYPTO_RK_AES_CTR,
|
||||
CRYPTO_RK_AES_XTS,
|
||||
CRYPTO_RK_AES_CCM,
|
||||
CRYPTO_RK_AES_GCM,
|
||||
CRYPTO_RK_AES_CMAC,
|
||||
CRYPTO_RK_AES_CBC_MAC,
|
||||
CRYPTO_RK_MD5,
|
||||
CRYPTO_RK_SHA1,
|
||||
CRYPTO_RK_SHA224,
|
||||
CRYPTO_RK_SHA256,
|
||||
CRYPTO_RK_SHA384,
|
||||
CRYPTO_RK_SHA512,
|
||||
CRYPTO_RK_SHA512_224,
|
||||
CRYPTO_RK_SHA512_256,
|
||||
CRYPTO_RK_MD5_HMAC,
|
||||
CRYPTO_RK_SHA1_HMAC,
|
||||
CRYPTO_RK_SHA256_HMAC,
|
||||
CRYPTO_RK_SHA512_HMAC,
|
||||
CRYPTO_RK_SM3,
|
||||
CRYPTO_RK_SM3_HMAC,
|
||||
CRYPTO_RK_DES_ECB = 150,
|
||||
CRYPTO_RK_DES_CBC,
|
||||
CRYPTO_RK_DES_CFB,
|
||||
CRYPTO_RK_DES_OFB,
|
||||
CRYPTO_RK_3DES_ECB,
|
||||
CRYPTO_RK_3DES_CBC,
|
||||
CRYPTO_RK_3DES_CFB,
|
||||
CRYPTO_RK_3DES_OFB,
|
||||
CRYPTO_RK_SM4_ECB,
|
||||
CRYPTO_RK_SM4_CBC,
|
||||
CRYPTO_RK_SM4_CFB,
|
||||
CRYPTO_RK_SM4_OFB,
|
||||
CRYPTO_RK_SM4_CTS,
|
||||
CRYPTO_RK_SM4_CTR,
|
||||
CRYPTO_RK_SM4_XTS,
|
||||
CRYPTO_RK_SM4_CCM,
|
||||
CRYPTO_RK_SM4_GCM,
|
||||
CRYPTO_RK_SM4_CMAC,
|
||||
CRYPTO_RK_SM4_CBC_MAC,
|
||||
CRYPTO_RK_AES_ECB,
|
||||
CRYPTO_RK_AES_CBC,
|
||||
CRYPTO_RK_AES_CFB,
|
||||
CRYPTO_RK_AES_OFB,
|
||||
CRYPTO_RK_AES_CTS,
|
||||
CRYPTO_RK_AES_CTR,
|
||||
CRYPTO_RK_AES_XTS,
|
||||
CRYPTO_RK_AES_CCM,
|
||||
CRYPTO_RK_AES_GCM,
|
||||
CRYPTO_RK_AES_CMAC,
|
||||
CRYPTO_RK_AES_CBC_MAC,
|
||||
CRYPTO_RK_MD5,
|
||||
CRYPTO_RK_SHA1,
|
||||
CRYPTO_RK_SHA224,
|
||||
CRYPTO_RK_SHA256,
|
||||
CRYPTO_RK_SHA384,
|
||||
CRYPTO_RK_SHA512,
|
||||
CRYPTO_RK_SHA512_224,
|
||||
CRYPTO_RK_SHA512_256,
|
||||
CRYPTO_RK_MD5_HMAC,
|
||||
CRYPTO_RK_SHA1_HMAC,
|
||||
CRYPTO_RK_SHA256_HMAC,
|
||||
CRYPTO_RK_SHA512_HMAC,
|
||||
CRYPTO_RK_SM3,
|
||||
CRYPTO_RK_SM3_HMAC,
|
||||
|
||||
CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
|
||||
CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
|
||||
};
|
||||
|
||||
#define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1)
|
||||
#define CRYPTO_ALGORITHM_MAX (CRYPTO_ALGORITHM_ALL - 1)
|
||||
|
||||
/* Values for ciphers */
|
||||
#define DES_BLOCK_LEN 8
|
||||
#define DES3_BLOCK_LEN 8
|
||||
#define RIJNDAEL128_BLOCK_LEN 16
|
||||
#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
|
||||
#define CAMELLIA_BLOCK_LEN 16
|
||||
#define BLOWFISH_BLOCK_LEN 8
|
||||
#define SKIPJACK_BLOCK_LEN 8
|
||||
#define CAST128_BLOCK_LEN 8
|
||||
#define DES_BLOCK_LEN 8
|
||||
#define DES3_BLOCK_LEN 8
|
||||
#define RIJNDAEL128_BLOCK_LEN 16
|
||||
#define AES_BLOCK_LEN RIJNDAEL128_BLOCK_LEN
|
||||
#define CAMELLIA_BLOCK_LEN 16
|
||||
#define BLOWFISH_BLOCK_LEN 8
|
||||
#define SKIPJACK_BLOCK_LEN 8
|
||||
#define CAST128_BLOCK_LEN 8
|
||||
|
||||
/* the maximum of the above */
|
||||
#define EALG_MAX_BLOCK_LEN 16
|
||||
#define EALG_MAX_BLOCK_LEN 16
|
||||
|
||||
/* Values for hashes/MAC */
|
||||
#define AALG_MAX_RESULT_LEN 64
|
||||
#define AALG_MAX_RESULT_LEN 64
|
||||
|
||||
/* maximum length of verbose alg names (depends on CRYPTO_MAX_ALG_NAME) */
|
||||
#define CRYPTODEV_MAX_ALG_NAME 64
|
||||
#define CRYPTODEV_MAX_ALG_NAME 64
|
||||
|
||||
#define HASH_MAX_LEN 64
|
||||
|
||||
/* input of CIOCGSESSION */
|
||||
struct session_op {
|
||||
/* Specify either cipher or mac
|
||||
*/
|
||||
__u32 cipher; /* cryptodev_crypto_op_t */
|
||||
__u32 mac; /* cryptodev_crypto_op_t */
|
||||
/* Specify either cipher or mac
|
||||
*/
|
||||
__u32 cipher; /* cryptodev_crypto_op_t */
|
||||
__u32 mac; /* cryptodev_crypto_op_t */
|
||||
|
||||
__u32 keylen;
|
||||
__u8 __user *key;
|
||||
__u32 mackeylen;
|
||||
__u8 __user *mackey;
|
||||
__u32 keylen;
|
||||
__u8 __user *key;
|
||||
__u32 mackeylen;
|
||||
__u8 __user *mackey;
|
||||
|
||||
__u32 ses; /* session identifier */
|
||||
__u32 ses; /* session identifier */
|
||||
};
|
||||
|
||||
struct session_info_op {
|
||||
__u32 ses; /* session identifier */
|
||||
__u32 ses; /* session identifier */
|
||||
|
||||
/* verbose names for the requested ciphers */
|
||||
struct alg_info {
|
||||
char cra_name[CRYPTODEV_MAX_ALG_NAME];
|
||||
char cra_driver_name[CRYPTODEV_MAX_ALG_NAME];
|
||||
} cipher_info, hash_info;
|
||||
/* verbose names for the requested ciphers */
|
||||
struct alg_info {
|
||||
char cra_name[CRYPTODEV_MAX_ALG_NAME];
|
||||
char cra_driver_name[CRYPTODEV_MAX_ALG_NAME];
|
||||
} cipher_info, hash_info;
|
||||
|
||||
__u16 alignmask; /* alignment constraints */
|
||||
__u32 flags; /* SIOP_FLAGS_* */
|
||||
__u16 alignmask; /* alignment constraints */
|
||||
__u32 flags; /* SIOP_FLAGS_* */
|
||||
};
|
||||
|
||||
/* If this flag is set then this algorithm uses
|
||||
@@ -164,48 +164,47 @@ struct session_info_op {
|
||||
*/
|
||||
#define SIOP_FLAG_KERNEL_DRIVER_ONLY 1
|
||||
|
||||
#define COP_ENCRYPT 0
|
||||
#define COP_DECRYPT 1
|
||||
#define COP_ENCRYPT 0
|
||||
#define COP_DECRYPT 1
|
||||
|
||||
/* input of CIOCCRYPT */
|
||||
struct crypt_op {
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u8 __user *src; /* source data */
|
||||
__u8 __user *dst; /* pointer to output data */
|
||||
/* pointer to output data for hash/MAC operations */
|
||||
__u8 __user *mac;
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u8 __user *src; /* source data */
|
||||
__u8 __user *dst; /* pointer to output data */
|
||||
/* pointer to output data for hash/MAC operations */
|
||||
__u8 __user *mac;
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
};
|
||||
|
||||
/* input of CIOCAUTHCRYPT */
|
||||
struct crypt_auth_op {
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_AEAD_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u32 auth_len; /* length of auth data */
|
||||
__u8 __user *auth_src; /* authenticated-only data */
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_AEAD_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u32 auth_len; /* length of auth data */
|
||||
__u8 __user *auth_src; /* authenticated-only data */
|
||||
|
||||
/* The current implementation is more efficient if data are
|
||||
* encrypted in-place (src==dst). */
|
||||
__u8 __user *src; /* data to be encrypted and authenticated */
|
||||
__u8 __user *dst; /* pointer to output data. Must have
|
||||
* space for tag. For TLS this should be at least
|
||||
* len + tag_size + block_size for padding */
|
||||
/* The current implementation is more efficient if data are
|
||||
* encrypted in-place (src==dst). */
|
||||
__u8 __user *src; /* data to be encrypted and authenticated */
|
||||
__u8 __user *dst; /* pointer to output data. Must have
|
||||
* space for tag. For TLS this should be at least
|
||||
* len + tag_size + block_size for padding */
|
||||
|
||||
__u8 __user *tag; /* where the tag will be copied to. TLS mode
|
||||
* doesn't use that as tag is copied to dst.
|
||||
* SRTP mode copies tag there. */
|
||||
__u32
|
||||
tag_len; /* the length of the tag. Use zero for digest size or max tag. */
|
||||
__u8 __user *tag; /* where the tag will be copied to. TLS mode
|
||||
* doesn't use that as tag is copied to dst.
|
||||
* SRTP mode copies tag there. */
|
||||
__u32 tag_len; /* the length of the tag. Use zero for digest size or max tag. */
|
||||
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
__u32 iv_len;
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
__u32 iv_len;
|
||||
};
|
||||
|
||||
/* In plain AEAD mode the following are required:
|
||||
@@ -244,71 +243,69 @@ struct crypt_auth_op {
|
||||
* flags : COP_FLAG_AEAD_SRTP_TYPE
|
||||
* iv : the initialization vector
|
||||
* auth_len: the length of the data to be authenticated. This must
|
||||
* include the SRTP header + SRTP payload (data to be encrypted) +
|
||||
* rest
|
||||
* include the SRTP header + SRTP payload (data to be encrypted) + rest
|
||||
*
|
||||
* len : length of data to be encrypted
|
||||
* auth_src: pointer the data to be authenticated. Should point at the same
|
||||
* buffer as src. src : pointer to the data to be encrypted. dst : This
|
||||
* is mandatory to be the same as src (in-place only). tag_size: the size of the
|
||||
* desired authentication tag or zero to use the default mac output. tag :
|
||||
* Pointer to an address where the authentication tag will be copied.
|
||||
* auth_src: pointer the data to be authenticated. Should point at the same buffer as src.
|
||||
* src : pointer to the data to be encrypted.
|
||||
* dst : This is mandatory to be the same as src (in-place only).
|
||||
* tag_size: the size of the desired authentication tag or zero to use
|
||||
* the default mac output.
|
||||
* tag : Pointer to an address where the authentication tag will be copied.
|
||||
*/
|
||||
|
||||
|
||||
/* struct crypt_op flags */
|
||||
|
||||
#define COP_FLAG_NONE (0 << 0) /* totally no flag */
|
||||
#define COP_FLAG_UPDATE (1 << 0) /* multi-update hash mode */
|
||||
#define COP_FLAG_FINAL (1 << 1) /* multi-update final hash mode */
|
||||
#define COP_FLAG_WRITE_IV (1 << 2) /* update the IV during operation */
|
||||
#define COP_FLAG_NO_ZC (1 << 3) /* do not zero-copy */
|
||||
#define COP_FLAG_AEAD_TLS_TYPE \
|
||||
(1 << 4) /* authenticate and encrypt using the \
|
||||
* TLS protocol rules */
|
||||
#define COP_FLAG_AEAD_SRTP_TYPE \
|
||||
(1 << 5) /* authenticate and encrypt using the \
|
||||
* SRTP protocol rules */
|
||||
#define COP_FLAG_RESET \
|
||||
(1 << 6) /* multi-update reset the state. \
|
||||
* should be used in combination \
|
||||
* with COP_FLAG_UPDATE */
|
||||
#define COP_FLAG_AEAD_RK_TYPE \
|
||||
(1 << 11) /* authenticate and encrypt using the \
|
||||
* rock-chips define rules */
|
||||
#define COP_FLAG_NONE (0 << 0) /* totally no flag */
|
||||
#define COP_FLAG_UPDATE (1 << 0) /* multi-update hash mode */
|
||||
#define COP_FLAG_FINAL (1 << 1) /* multi-update final hash mode */
|
||||
#define COP_FLAG_WRITE_IV (1 << 2) /* update the IV during operation */
|
||||
#define COP_FLAG_NO_ZC (1 << 3) /* do not zero-copy */
|
||||
#define COP_FLAG_AEAD_TLS_TYPE (1 << 4) /* authenticate and encrypt using the
|
||||
* TLS protocol rules */
|
||||
#define COP_FLAG_AEAD_SRTP_TYPE (1 << 5) /* authenticate and encrypt using the
|
||||
* SRTP protocol rules */
|
||||
#define COP_FLAG_RESET (1 << 6) /* multi-update reset the state.
|
||||
* should be used in combination
|
||||
* with COP_FLAG_UPDATE */
|
||||
#define COP_FLAG_AEAD_RK_TYPE (1 << 11) /* authenticate and encrypt using the
|
||||
* rock-chips define rules */
|
||||
|
||||
|
||||
/* Stuff for bignum arithmetic and public key
|
||||
* cryptography - not supported yet by linux
|
||||
* cryptodev.
|
||||
*/
|
||||
|
||||
#define CRYPTO_ALG_FLAG_SUPPORTED 1
|
||||
#define CRYPTO_ALG_FLAG_RNG_ENABLE 2
|
||||
#define CRYPTO_ALG_FLAG_DSA_SHA 4
|
||||
#define CRYPTO_ALG_FLAG_SUPPORTED 1
|
||||
#define CRYPTO_ALG_FLAG_RNG_ENABLE 2
|
||||
#define CRYPTO_ALG_FLAG_DSA_SHA 4
|
||||
|
||||
struct crparam {
|
||||
__u8 *crp_p;
|
||||
__u32 crp_nbits;
|
||||
__u8 *crp_p;
|
||||
__u32 crp_nbits;
|
||||
};
|
||||
|
||||
#define CRK_MAXPARAM 8
|
||||
#define CRK_MAXPARAM 8
|
||||
|
||||
/* input of CIOCKEY */
|
||||
struct crypt_kop {
|
||||
__u32 crk_op; /* cryptodev_crk_op_t */
|
||||
__u32 crk_status;
|
||||
__u16 crk_iparams;
|
||||
__u16 crk_oparams;
|
||||
__u32 crk_pad1;
|
||||
struct crparam crk_param[CRK_MAXPARAM];
|
||||
__u32 crk_op; /* cryptodev_crk_op_t */
|
||||
__u32 crk_status;
|
||||
__u16 crk_iparams;
|
||||
__u16 crk_oparams;
|
||||
__u32 crk_pad1;
|
||||
struct crparam crk_param[CRK_MAXPARAM];
|
||||
};
|
||||
|
||||
enum cryptodev_crk_op_t {
|
||||
CRK_MOD_EXP = 0,
|
||||
CRK_MOD_EXP_CRT = 1,
|
||||
CRK_DSA_SIGN = 2,
|
||||
CRK_DSA_VERIFY = 3,
|
||||
CRK_DH_COMPUTE_KEY = 4,
|
||||
CRK_ALGORITHM_ALL
|
||||
CRK_MOD_EXP = 0,
|
||||
CRK_MOD_EXP_CRT = 1,
|
||||
CRK_DSA_SIGN = 2,
|
||||
CRK_DSA_VERIFY = 3,
|
||||
CRK_DH_COMPUTE_KEY = 4,
|
||||
CRK_ALGORITHM_ALL
|
||||
};
|
||||
|
||||
/* input of CIOCCPHASH
|
||||
@@ -318,43 +315,44 @@ enum cryptodev_crk_op_t {
|
||||
*/
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29))
|
||||
struct cphash_op {
|
||||
__u32 dst_ses;
|
||||
__u32 src_ses;
|
||||
__u32 dst_ses;
|
||||
__u32 src_ses;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define CRK_ALGORITHM_MAX (CRK_ALGORITHM_ALL - 1)
|
||||
#define CRK_ALGORITHM_MAX (CRK_ALGORITHM_ALL-1)
|
||||
|
||||
/* features to be queried with CIOCASYMFEAT ioctl
|
||||
*/
|
||||
#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
|
||||
#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
|
||||
#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
|
||||
#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
|
||||
#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
|
||||
#define CRF_MOD_EXP (1 << CRK_MOD_EXP)
|
||||
#define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT)
|
||||
#define CRF_DSA_SIGN (1 << CRK_DSA_SIGN)
|
||||
#define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY)
|
||||
#define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY)
|
||||
|
||||
|
||||
/* ioctl's. Compatible with old linux cryptodev.h
|
||||
*/
|
||||
#define CRIOGET _IOWR('c', 101, __u32)
|
||||
#define CIOCGSESSION _IOWR('c', 102, struct session_op)
|
||||
#define CIOCFSESSION _IOW('c', 103, __u32)
|
||||
#define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
|
||||
#define CIOCKEY _IOWR('c', 105, struct crypt_kop)
|
||||
#define CIOCASYMFEAT _IOR('c', 106, __u32)
|
||||
#define CIOCGSESSINFO _IOWR('c', 107, struct session_info_op)
|
||||
#define CRIOGET _IOWR('c', 101, __u32)
|
||||
#define CIOCGSESSION _IOWR('c', 102, struct session_op)
|
||||
#define CIOCFSESSION _IOW('c', 103, __u32)
|
||||
#define CIOCCRYPT _IOWR('c', 104, struct crypt_op)
|
||||
#define CIOCKEY _IOWR('c', 105, struct crypt_kop)
|
||||
#define CIOCASYMFEAT _IOR('c', 106, __u32)
|
||||
#define CIOCGSESSINFO _IOWR('c', 107, struct session_info_op)
|
||||
|
||||
/* to indicate that CRIOGET is not required in linux
|
||||
*/
|
||||
#define CRIOGET_NOT_NEEDED 1
|
||||
|
||||
/* additional ioctls for AEAD */
|
||||
#define CIOCAUTHCRYPT _IOWR('c', 109, struct crypt_auth_op)
|
||||
#define CIOCAUTHCRYPT _IOWR('c', 109, struct crypt_auth_op)
|
||||
|
||||
/* additional ioctls for asynchronous operation.
|
||||
* These are conditionally enabled since version 1.6.
|
||||
*/
|
||||
#define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op)
|
||||
#define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op)
|
||||
#define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op)
|
||||
#define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op)
|
||||
|
||||
/* additional ioctl for copying of hash/mac session state data
|
||||
* between sessions.
|
||||
@@ -363,7 +361,7 @@ struct cphash_op {
|
||||
* must have been created with CIOGSESSION.
|
||||
*/
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29))
|
||||
#define CIOCCPHASH _IOW('c', 112, struct cphash_op)
|
||||
#define CIOCCPHASH _IOW('c', 112, struct cphash_op)
|
||||
#endif
|
||||
|
||||
#endif /* L_CRYPTODEV_H */
|
||||
|
||||
@@ -33,13 +33,13 @@
|
||||
* Provided by userspace as an argument to the ioctl
|
||||
*/
|
||||
struct dma_heap_allocation_data {
|
||||
__u64 len;
|
||||
__u32 fd;
|
||||
__u32 fd_flags;
|
||||
__u64 heap_flags;
|
||||
__u64 len;
|
||||
__u32 fd;
|
||||
__u32 fd_flags;
|
||||
__u64 heap_flags;
|
||||
};
|
||||
|
||||
#define DMA_HEAP_IOC_MAGIC 'H'
|
||||
#define DMA_HEAP_IOC_MAGIC 'H'
|
||||
|
||||
/**
|
||||
* DOC: DMA_HEAP_IOCTL_ALLOC - allocate memory from pool
|
||||
@@ -47,7 +47,7 @@ struct dma_heap_allocation_data {
|
||||
* Takes a dma_heap_allocation_data struct and returns it with the fd field
|
||||
* populated with the dmabuf handle of the allocation.
|
||||
*/
|
||||
#define DMA_HEAP_IOCTL_ALLOC \
|
||||
_IOWR(DMA_HEAP_IOC_MAGIC, 0x0, struct dma_heap_allocation_data)
|
||||
#define DMA_HEAP_IOCTL_ALLOC _IOWR(DMA_HEAP_IOC_MAGIC, 0x0,\
|
||||
struct dma_heap_allocation_data)
|
||||
|
||||
#endif /* _UAPI_LINUX_DMABUF_POOL_H */
|
||||
|
||||
@@ -15,71 +15,69 @@
|
||||
|
||||
/* input of RIOCCRYPT_FD */
|
||||
struct crypt_fd_op {
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u32 len; /* length of source data */
|
||||
int src_fd; /* source data */
|
||||
int dst_fd; /* pointer to output data */
|
||||
/* pointer to output data for hash/MAC operations */
|
||||
__u8 __user *mac;
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u32 len; /* length of source data */
|
||||
int src_fd; /* source data */
|
||||
int dst_fd; /* pointer to output data */
|
||||
/* pointer to output data for hash/MAC operations */
|
||||
__u8 __user *mac;
|
||||
/* initialization vector for encryption operations */
|
||||
__u8 __user *iv;
|
||||
};
|
||||
|
||||
/* input of RIOCAUTHCRYPT_FD */
|
||||
struct crypt_auth_fd_op {
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_AEAD_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u32 auth_len; /* length of auth data */
|
||||
int auth_fd; /* authenticated-only data */
|
||||
int src_fd; /* source data */
|
||||
int dst_fd; /* pointer to output data */
|
||||
__u64 tag;
|
||||
__u32
|
||||
tag_len; /* the length of the tag. Use zero for digest size or max tag. */
|
||||
__u64 iv; /* initialization vector for encryption operations */
|
||||
__u32 iv_len;
|
||||
__u32 ses; /* session identifier */
|
||||
__u16 op; /* COP_ENCRYPT or COP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_AEAD_* */
|
||||
__u32 len; /* length of source data */
|
||||
__u32 auth_len; /* length of auth data */
|
||||
int auth_fd; /* authenticated-only data */
|
||||
int src_fd; /* source data */
|
||||
int dst_fd; /* pointer to output data */
|
||||
__u64 tag;
|
||||
__u32 tag_len; /* the length of the tag. Use zero for digest size or max tag. */
|
||||
__u64 iv; /* initialization vector for encryption operations */
|
||||
__u32 iv_len;
|
||||
};
|
||||
|
||||
/* input of RIOCCRYPT_FD_MAP/RIOCCRYPT_FD_UNMAP */
|
||||
struct crypt_fd_map_op {
|
||||
int dma_fd; /* session identifier */
|
||||
__u32 phys_addr; /* physics addr */
|
||||
int dma_fd; /* session identifier */
|
||||
__u32 phys_addr; /* physics addr */
|
||||
};
|
||||
|
||||
#define AOP_ENCRYPT 0
|
||||
#define AOP_DECRYPT 1
|
||||
#define AOP_ENCRYPT 0
|
||||
#define AOP_DECRYPT 1
|
||||
|
||||
#define COP_FLAG_RSA_PUB (0 << 8) /* decode as rsa pub key */
|
||||
#define COP_FLAG_RSA_PRIV (1 << 8) /* decode as rsa priv key */
|
||||
#define COP_FLAG_RSA_PUB (0 << 8) /* decode as rsa pub key */
|
||||
#define COP_FLAG_RSA_PRIV (1 << 8) /* decode as rsa priv key */
|
||||
|
||||
#define RK_RSA_BER_KEY_MAX \
|
||||
8192 /* The key encoded by ber does not exceed 8K Byte */
|
||||
#define RK_RSA_KEY_MAX_BITS 4096
|
||||
#define RK_RSA_KEY_MAX_BYTES (RK_RSA_KEY_MAX_BITS / 8)
|
||||
#define RK_RSA_BER_KEY_MAX 8192 /* The key encoded by ber does not exceed 8K Byte */
|
||||
#define RK_RSA_KEY_MAX_BITS 4096
|
||||
#define RK_RSA_KEY_MAX_BYTES (RK_RSA_KEY_MAX_BITS / 8)
|
||||
|
||||
/* input of RIOCCRYPT_RSA_CRYPT */
|
||||
struct crypt_rsa_op {
|
||||
__u16 op; /* AOP_ENCRYPT/AOP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u8 reserve[4];
|
||||
__u64 key; /* BER coding RSA key */
|
||||
__u64 in; /* pointer to input data */
|
||||
__u64 out; /* pointer to output data */
|
||||
__u32 key_len; /* length of key data */
|
||||
__u32 in_len; /* length of input data */
|
||||
__u32 out_len; /* length of output data */
|
||||
__u16 op; /* AOP_ENCRYPT/AOP_DECRYPT */
|
||||
__u16 flags; /* see COP_FLAG_* */
|
||||
__u8 reserve[4];
|
||||
__u64 key; /* BER coding RSA key */
|
||||
__u64 in; /* pointer to input data */
|
||||
__u64 out; /* pointer to output data */
|
||||
__u32 key_len; /* length of key data */
|
||||
__u32 in_len; /* length of input data */
|
||||
__u32 out_len; /* length of output data */
|
||||
};
|
||||
|
||||
#define RIOCCRYPT_FD _IOWR('r', 104, struct crypt_fd_op)
|
||||
#define RIOCCRYPT_FD_MAP _IOWR('r', 105, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_FD_UNMAP _IOW('r', 106, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_CPU_ACCESS _IOW('r', 107, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_DEV_ACCESS _IOW('r', 108, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_RSA_CRYPT _IOWR('r', 109, struct crypt_rsa_op)
|
||||
#define RIOCAUTHCRYPT_FD _IOWR('r', 110, struct crypt_auth_fd_op)
|
||||
#define RIOCCRYPT_FD _IOWR('r', 104, struct crypt_fd_op)
|
||||
#define RIOCCRYPT_FD_MAP _IOWR('r', 105, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_FD_UNMAP _IOW('r', 106, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_CPU_ACCESS _IOW('r', 107, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_DEV_ACCESS _IOW('r', 108, struct crypt_fd_map_op)
|
||||
#define RIOCCRYPT_RSA_CRYPT _IOWR('r', 109, struct crypt_rsa_op)
|
||||
#define RIOCAUTHCRYPT_FD _IOWR('r', 110, struct crypt_auth_fd_op)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
// import from include/linux/types.h
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
struct hlist_head {
|
||||
struct hlist_node *first;
|
||||
struct hlist_node *first;
|
||||
};
|
||||
|
||||
struct hlist_node {
|
||||
struct hlist_node *next, **pprev;
|
||||
struct hlist_node *next, **pprev;
|
||||
};
|
||||
|
||||
// import from include/linux/poison.h
|
||||
@@ -26,9 +26,9 @@ struct hlist_node {
|
||||
* that is also not mappable by user-space exploits:
|
||||
*/
|
||||
#ifdef CONFIG_ILLEGAL_POINTER_VALUE
|
||||
#define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL)
|
||||
# define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL)
|
||||
#else
|
||||
#define POISON_POINTER_DELTA (0)
|
||||
# define POISON_POINTER_DELTA (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -36,15 +36,15 @@ struct hlist_node {
|
||||
* under normal circumstances, used to verify that nobody uses
|
||||
* non-initialized list entries.
|
||||
*/
|
||||
#define LIST_POISON1 ((void *)((uint8_t *)0x00100100 + POISON_POINTER_DELTA))
|
||||
#define LIST_POISON2 ((void *)((uint8_t *)0x00200200 + POISON_POINTER_DELTA))
|
||||
#define LIST_POISON1 ((void *)((uint8_t *) 0x00100100 + POISON_POINTER_DELTA))
|
||||
#define LIST_POISON2 ((void *)((uint8_t *) 0x00200200 + POISON_POINTER_DELTA))
|
||||
|
||||
// import from include/linux/stddef.h
|
||||
#undef offsetof
|
||||
#ifdef __compiler_offsetof
|
||||
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
|
||||
#else
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER)
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
// import from include/linux/kernel.h
|
||||
@@ -55,11 +55,9 @@ struct hlist_node {
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) \
|
||||
({ \
|
||||
const typeof(((type *)0)->member) *__mptr = (ptr); \
|
||||
(type *)((char *)__mptr - offsetof(type, member)); \
|
||||
})
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof(((type *)0)->member) *__mptr = (ptr); \
|
||||
(type *)((char *)__mptr - offsetof(type, member)); })
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
@@ -71,10 +69,10 @@ struct hlist_node {
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
#define LIST_HEAD_INIT(name) \
|
||||
{ &(name), &(name) }
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
/**
|
||||
* INIT_LIST_HEAD - Initialize a list_head structure
|
||||
@@ -83,9 +81,10 @@ struct hlist_node {
|
||||
* Initializes the list_head to point to itself. If it is a list header,
|
||||
* the result is an empty list.
|
||||
*/
|
||||
static inline void INIT_LIST_HEAD(struct list_head *list) {
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
static inline void INIT_LIST_HEAD(struct list_head *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -95,16 +94,18 @@ static inline void INIT_LIST_HEAD(struct list_head *list) {
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
#ifndef CONFIG_DEBUG_LIST
|
||||
static inline void __list_add(struct list_head *new, struct list_head *prev,
|
||||
struct list_head *next) {
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
static inline void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next) {
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
#else
|
||||
extern void __list_add(struct list_head *new, struct list_head *prev,
|
||||
struct list_head *next);
|
||||
extern void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -115,10 +116,12 @@ extern void __list_add(struct list_head *new, struct list_head *prev,
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *new, struct list_head *head) {
|
||||
__list_add(new, head, head->next);
|
||||
static inline void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
@@ -127,9 +130,9 @@ static inline void list_add(struct list_head *new, struct list_head *head) {
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *new,
|
||||
struct list_head *head) {
|
||||
__list_add(new, head->prev, head);
|
||||
static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -139,9 +142,10 @@ static inline void list_add_tail(struct list_head *new,
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next) {
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,14 +156,16 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) {
|
||||
*/
|
||||
#ifndef CONFIG_DEBUG_LIST
|
||||
|
||||
static inline void __list_del_entry(struct list_head *entry) {
|
||||
__list_del(entry->prev, entry->next);
|
||||
static inline void __list_del_entry(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
}
|
||||
|
||||
static inline void list_del(struct list_head *entry) {
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = LIST_POISON1;
|
||||
entry->prev = LIST_POISON2;
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = LIST_POISON1;
|
||||
entry->prev = LIST_POISON2;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -174,11 +180,13 @@ extern void list_del(struct list_head *entry);
|
||||
*
|
||||
* If @old was empty, it will be overwritten.
|
||||
*/
|
||||
static inline void list_replace(struct list_head *old, struct list_head *new) {
|
||||
new->next = old->next;
|
||||
new->next->prev = new;
|
||||
new->prev = old->prev;
|
||||
new->prev->next = new;
|
||||
static inline void list_replace(struct list_head *old,
|
||||
struct list_head *new)
|
||||
{
|
||||
new->next = old->next;
|
||||
new->next->prev = new;
|
||||
new->prev = old->prev;
|
||||
new->prev->next = new;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,18 +197,20 @@ static inline void list_replace(struct list_head *old, struct list_head *new) {
|
||||
* If @old was empty, it will be overwritten.
|
||||
*/
|
||||
static inline void list_replace_init(struct list_head *old,
|
||||
struct list_head *new) {
|
||||
list_replace(old, new);
|
||||
INIT_LIST_HEAD(old);
|
||||
struct list_head *new)
|
||||
{
|
||||
list_replace(old, new);
|
||||
INIT_LIST_HEAD(old);
|
||||
}
|
||||
|
||||
/*
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry) {
|
||||
__list_del_entry(entry);
|
||||
INIT_LIST_HEAD(entry);
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del_entry(entry);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -208,9 +218,10 @@ static inline void list_del_init(struct list_head *entry) {
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head) {
|
||||
__list_del_entry(list);
|
||||
list_add(list, head);
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del_entry(list);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -219,9 +230,10 @@ static inline void list_move(struct list_head *list, struct list_head *head) {
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head) {
|
||||
__list_del_entry(list);
|
||||
list_add_tail(list, head);
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del_entry(list);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -230,16 +242,18 @@ static inline void list_move_tail(struct list_head *list,
|
||||
* @head: the head of the list
|
||||
*/
|
||||
static inline int list_is_last(const struct list_head *list,
|
||||
const struct list_head *head) {
|
||||
return list->next == head;
|
||||
const struct list_head *head)
|
||||
{
|
||||
return list->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(const struct list_head *head) {
|
||||
return head->next == head;
|
||||
static inline int list_empty(const struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -255,44 +269,48 @@ static inline int list_empty(const struct list_head *head) {
|
||||
* to the list entry is list_del_init(). Eg. it cannot be used
|
||||
* if another CPU could re-list_add() it.
|
||||
*/
|
||||
static inline int list_empty_careful(const struct list_head *head) {
|
||||
struct list_head *next = head->next;
|
||||
static inline int list_empty_careful(const struct list_head *head)
|
||||
{
|
||||
struct list_head *next = head->next;
|
||||
|
||||
return (next == head) && (next == head->prev);
|
||||
return (next == head) && (next == head->prev);
|
||||
}
|
||||
|
||||
/*
|
||||
* list_rotate_left - rotate the list to the left
|
||||
* @head: the head of the list
|
||||
*/
|
||||
static inline void list_rotate_left(struct list_head *head) {
|
||||
struct list_head *first;
|
||||
static inline void list_rotate_left(struct list_head *head)
|
||||
{
|
||||
struct list_head *first;
|
||||
|
||||
if (!list_empty(head)) {
|
||||
first = head->next;
|
||||
list_move_tail(first, head);
|
||||
}
|
||||
if (!list_empty(head)) {
|
||||
first = head->next;
|
||||
list_move_tail(first, head);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* list_is_singular - tests whether a list has just one entry.
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_is_singular(const struct list_head *head) {
|
||||
return !list_empty(head) && (head->next == head->prev);
|
||||
static inline int list_is_singular(const struct list_head *head)
|
||||
{
|
||||
return !list_empty(head) && (head->next == head->prev);
|
||||
}
|
||||
|
||||
static inline void __list_cut_position(struct list_head *list,
|
||||
struct list_head *head,
|
||||
struct list_head *entry) {
|
||||
struct list_head *new_first = entry->next;
|
||||
struct list_head *head,
|
||||
struct list_head *entry)
|
||||
{
|
||||
struct list_head *new_first = entry->next;
|
||||
|
||||
list->next = head->next;
|
||||
list->next->prev = list;
|
||||
list->prev = entry;
|
||||
entry->next = list;
|
||||
head->next = new_first;
|
||||
new_first->prev = head;
|
||||
list->next = head->next;
|
||||
list->next->prev = list;
|
||||
list->prev = entry;
|
||||
entry->next = list;
|
||||
head->next = new_first;
|
||||
new_first->prev = head;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -310,29 +328,32 @@ static inline void __list_cut_position(struct list_head *list,
|
||||
*
|
||||
*/
|
||||
static inline void list_cut_position(struct list_head *list,
|
||||
struct list_head *head,
|
||||
struct list_head *entry) {
|
||||
if (list_empty(head))
|
||||
return;
|
||||
if (list_is_singular(head) && (head->next != entry && head != entry))
|
||||
return;
|
||||
if (entry == head)
|
||||
INIT_LIST_HEAD(list);
|
||||
else
|
||||
__list_cut_position(list, head, entry);
|
||||
struct list_head *head, struct list_head *entry)
|
||||
{
|
||||
if (list_empty(head))
|
||||
return;
|
||||
if (list_is_singular(head) &&
|
||||
(head->next != entry && head != entry))
|
||||
return;
|
||||
if (entry == head)
|
||||
INIT_LIST_HEAD(list);
|
||||
else
|
||||
__list_cut_position(list, head, entry);
|
||||
}
|
||||
|
||||
|
||||
static inline void __list_splice(const struct list_head *list,
|
||||
struct list_head *prev,
|
||||
struct list_head *next) {
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
|
||||
first->prev = prev;
|
||||
prev->next = first;
|
||||
first->prev = prev;
|
||||
prev->next = first;
|
||||
|
||||
last->next = next;
|
||||
next->prev = last;
|
||||
last->next = next;
|
||||
next->prev = last;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -341,9 +362,10 @@ static inline void __list_splice(const struct list_head *list,
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(const struct list_head *list,
|
||||
struct list_head *head) {
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head, head->next);
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head, head->next);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -352,9 +374,10 @@ static inline void list_splice(const struct list_head *list,
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice_tail(struct list_head *list,
|
||||
struct list_head *head) {
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head->prev, head);
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -365,11 +388,12 @@ static inline void list_splice_tail(struct list_head *list,
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head) {
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head, head->next);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head, head->next);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -381,11 +405,12 @@ static inline void list_splice_init(struct list_head *list,
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_tail_init(struct list_head *list,
|
||||
struct list_head *head) {
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head->prev, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head->prev, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -394,7 +419,8 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
/*
|
||||
* list_first_entry - get the first element from a list
|
||||
@@ -404,8 +430,8 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
/*
|
||||
* list_last_entry - get the last element from a list
|
||||
@@ -415,7 +441,8 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
#define list_last_entry(ptr, type, member) list_entry((ptr)->prev, type, member)
|
||||
#define list_last_entry(ptr, type, member) \
|
||||
list_entry((ptr)->prev, type, member)
|
||||
|
||||
/**
|
||||
* list_first_entry_or_null - get the first element from a list
|
||||
@@ -425,40 +452,40 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
*
|
||||
* Note that if the list is empty, it returns NULL.
|
||||
*/
|
||||
#define list_first_entry_or_null(ptr, type, member) \
|
||||
(!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
|
||||
#define list_first_entry_or_null(ptr, type, member) \
|
||||
(!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
|
||||
|
||||
/*
|
||||
* list_next_entry - get the next element in list
|
||||
* @pos: the type * to cursor
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_next_entry(pos, member) \
|
||||
list_entry((pos)->member.next, typeof(*(pos)), member)
|
||||
#define list_next_entry(pos, member) \
|
||||
list_entry((pos)->member.next, typeof(*(pos)), member)
|
||||
|
||||
/*
|
||||
* list_prev_entry - get the prev element in list
|
||||
* @pos: the type * to cursor
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_prev_entry(pos, member) \
|
||||
list_entry((pos)->member.prev, typeof(*(pos)), member)
|
||||
#define list_prev_entry(pos, member) \
|
||||
list_entry((pos)->member.prev, typeof(*(pos)), member)
|
||||
|
||||
/*
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
/*
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); pos = pos->prev)
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); pos = pos->prev)
|
||||
|
||||
/*
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
@@ -466,18 +493,20 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/*
|
||||
* list_for_each_prev_safe - iterate over a list backwards safe against removal
|
||||
* of list entry
|
||||
* list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev_safe(pos, n, head) \
|
||||
for (pos = (head)->prev, n = pos->prev; pos != (head); pos = n, n = pos->prev)
|
||||
#define list_for_each_prev_safe(pos, n, head) \
|
||||
for (pos = (head)->prev, n = pos->prev; \
|
||||
pos != (head); \
|
||||
pos = n, n = pos->prev)
|
||||
|
||||
/*
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
@@ -485,9 +514,10 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_first_entry(head, typeof(*pos), member); \
|
||||
&pos->member != (head); pos = list_next_entry(pos, member))
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_first_entry(head, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_next_entry(pos, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_reverse - iterate backwards over list of given type.
|
||||
@@ -495,22 +525,21 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_last_entry(head, typeof(*pos), member); \
|
||||
&pos->member != (head); pos = list_prev_entry(pos, member))
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_last_entry(head, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_prev_entry(pos, member))
|
||||
|
||||
/*
|
||||
* list_prepare_entry - prepare a pos entry for use in
|
||||
* list_for_each_entry_continue()
|
||||
* list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
|
||||
* @pos: the type * to use as a start point
|
||||
* @head: the head of the list
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Prepares a pos entry for use as a start point in
|
||||
* list_for_each_entry_continue().
|
||||
* Prepares a pos entry for use as a start point in list_for_each_entry_continue().
|
||||
*/
|
||||
#define list_prepare_entry(pos, head, member) \
|
||||
((pos) ?: list_entry(head, typeof(*pos), member))
|
||||
#define list_prepare_entry(pos, head, member) \
|
||||
((pos) ? : list_entry(head, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_continue - continue iteration over list of given type
|
||||
@@ -521,9 +550,10 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* Continue to iterate over list of given type, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue(pos, head, member) \
|
||||
for (pos = list_next_entry(pos, member); &pos->member != (head); \
|
||||
pos = list_next_entry(pos, member))
|
||||
#define list_for_each_entry_continue(pos, head, member) \
|
||||
for (pos = list_next_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_next_entry(pos, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_continue_reverse - iterate backwards from the given point
|
||||
@@ -534,38 +564,38 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* Start to iterate over list of given type backwards, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue_reverse(pos, head, member) \
|
||||
for (pos = list_prev_entry(pos, member); &pos->member != (head); \
|
||||
pos = list_prev_entry(pos, member))
|
||||
#define list_for_each_entry_continue_reverse(pos, head, member) \
|
||||
for (pos = list_prev_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_prev_entry(pos, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_from - iterate over list of given type from the current
|
||||
* point
|
||||
* list_for_each_entry_from - iterate over list of given type from the current point
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*
|
||||
* Iterate over list of given type, continuing from current position.
|
||||
*/
|
||||
#define list_for_each_entry_from(pos, head, member) \
|
||||
for (; &pos->member != (head); pos = list_next_entry(pos, member))
|
||||
#define list_for_each_entry_from(pos, head, member) \
|
||||
for (; &pos->member != (head); \
|
||||
pos = list_next_entry(pos, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against
|
||||
* removal of list entry
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_first_entry(head, typeof(*pos), member), \
|
||||
n = list_next_entry(pos, member); \
|
||||
&pos->member != (head); pos = n, n = list_next_entry(n, member))
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_first_entry(head, typeof(*pos), member), \
|
||||
n = list_next_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_next_entry(n, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_safe_continue - continue list iteration safe against
|
||||
* removal
|
||||
* list_for_each_entry_safe_continue - continue list iteration safe against removal
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
@@ -574,13 +604,14 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate over list of given type, continuing after current point,
|
||||
* safe against removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_continue(pos, n, head, member) \
|
||||
for (pos = list_next_entry(pos, member), n = list_next_entry(pos, member); \
|
||||
&pos->member != (head); pos = n, n = list_next_entry(n, member))
|
||||
#define list_for_each_entry_safe_continue(pos, n, head, member) \
|
||||
for (pos = list_next_entry(pos, member), \
|
||||
n = list_next_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_next_entry(n, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_safe_from - iterate over list from current point safe
|
||||
* against removal
|
||||
* list_for_each_entry_safe_from - iterate over list from current point safe against removal
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
@@ -589,13 +620,13 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate over list of given type from current point, safe against
|
||||
* removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_from(pos, n, head, member) \
|
||||
for (n = list_next_entry(pos, member); &pos->member != (head); \
|
||||
pos = n, n = list_next_entry(n, member))
|
||||
#define list_for_each_entry_safe_from(pos, n, head, member) \
|
||||
for (n = list_next_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_next_entry(n, member))
|
||||
|
||||
/*
|
||||
* list_for_each_entry_safe_reverse - iterate backwards over list safe against
|
||||
* removal
|
||||
* list_for_each_entry_safe_reverse - iterate backwards over list safe against removal
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
@@ -604,10 +635,11 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate backwards over list of given type, safe against removal
|
||||
* of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||
for (pos = list_last_entry(head, typeof(*pos), member), \
|
||||
n = list_prev_entry(pos, member); \
|
||||
&pos->member != (head); pos = n, n = list_prev_entry(n, member))
|
||||
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||
for (pos = list_last_entry(head, typeof(*pos), member), \
|
||||
n = list_prev_entry(pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_prev_entry(n, member))
|
||||
|
||||
/*
|
||||
* list_safe_reset_next - reset a stale list_for_each_entry_safe loop
|
||||
@@ -621,8 +653,8 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* and list_safe_reset_next is called after re-taking the lock and before
|
||||
* completing the current iteration of the loop body.
|
||||
*/
|
||||
#define list_safe_reset_next(pos, n, member) \
|
||||
(n) = list_next_entry((pos), (member))
|
||||
#define list_safe_reset_next(pos, n, member) \
|
||||
(n) = list_next_entry((pos), (member))
|
||||
|
||||
/*
|
||||
* Double linked lists with a single pointer list head.
|
||||
@@ -631,13 +663,13 @@ static inline void list_splice_tail_init(struct list_head *list,
|
||||
* You lose the ability to access the tail in O(1).
|
||||
*/
|
||||
|
||||
#define HLIST_HEAD_INIT \
|
||||
{ .first = NULL }
|
||||
#define HLIST_HEAD(name) struct hlist_head name = {.first = NULL}
|
||||
#define HLIST_HEAD_INIT { .first = NULL }
|
||||
#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
|
||||
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
|
||||
static inline void INIT_HLIST_NODE(struct hlist_node *h) {
|
||||
h->next = NULL;
|
||||
h->pprev = NULL;
|
||||
static inline void INIT_HLIST_NODE(struct hlist_node *h)
|
||||
{
|
||||
h->next = NULL;
|
||||
h->pprev = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -648,18 +680,23 @@ static inline void INIT_HLIST_NODE(struct hlist_node *h) {
|
||||
* state. For example, hlist_nulls_del_init_rcu() does leave the
|
||||
* node in unhashed state, but hlist_nulls_del() does not.
|
||||
*/
|
||||
static inline int hlist_unhashed(const struct hlist_node *h) {
|
||||
return !h->pprev;
|
||||
static inline int hlist_unhashed(const struct hlist_node *h)
|
||||
{
|
||||
return !h->pprev;
|
||||
}
|
||||
|
||||
static inline int hlist_empty(const struct hlist_head *h) { return !h->first; }
|
||||
static inline int hlist_empty(const struct hlist_head *h)
|
||||
{
|
||||
return !h->first;
|
||||
}
|
||||
|
||||
static inline void __hlist_del(struct hlist_node *n) {
|
||||
struct hlist_node *next = n->next;
|
||||
struct hlist_node **pprev = n->pprev;
|
||||
*pprev = next;
|
||||
if (next)
|
||||
next->pprev = pprev;
|
||||
static inline void __hlist_del(struct hlist_node *n)
|
||||
{
|
||||
struct hlist_node *next = n->next;
|
||||
struct hlist_node **pprev = n->pprev;
|
||||
*pprev = next;
|
||||
if (next)
|
||||
next->pprev = pprev;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -669,10 +706,11 @@ static inline void __hlist_del(struct hlist_node *n) {
|
||||
* Note that this function leaves the node in hashed state. Use
|
||||
* hlist_del_init() or similar instead to unhash @n.
|
||||
*/
|
||||
static inline void hlist_del(struct hlist_node *n) {
|
||||
__hlist_del(n);
|
||||
n->next = LIST_POISON1;
|
||||
n->pprev = LIST_POISON2;
|
||||
static inline void hlist_del(struct hlist_node *n)
|
||||
{
|
||||
__hlist_del(n);
|
||||
n->next = LIST_POISON1;
|
||||
n->pprev = LIST_POISON2;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -681,11 +719,12 @@ static inline void hlist_del(struct hlist_node *n) {
|
||||
*
|
||||
* Note that this function leaves the node in unhashed state.
|
||||
*/
|
||||
static inline void hlist_del_init(struct hlist_node *n) {
|
||||
if (!hlist_unhashed(n)) {
|
||||
__hlist_del(n);
|
||||
INIT_HLIST_NODE(n);
|
||||
}
|
||||
static inline void hlist_del_init(struct hlist_node *n)
|
||||
{
|
||||
if (!hlist_unhashed(n)) {
|
||||
__hlist_del(n);
|
||||
INIT_HLIST_NODE(n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -696,68 +735,71 @@ static inline void hlist_del_init(struct hlist_node *n) {
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) {
|
||||
struct hlist_node *first = h->first;
|
||||
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
|
||||
{
|
||||
struct hlist_node *first = h->first;
|
||||
|
||||
n->next = first;
|
||||
if (first)
|
||||
first->pprev = &n->next;
|
||||
n->next = first;
|
||||
if (first)
|
||||
first->pprev = &n->next;
|
||||
|
||||
h->first = n;
|
||||
n->pprev = &h->first;
|
||||
h->first = n;
|
||||
n->pprev = &h->first;
|
||||
}
|
||||
|
||||
/* next must be != NULL */
|
||||
static inline void hlist_add_before(struct hlist_node *n,
|
||||
struct hlist_node *next) {
|
||||
n->pprev = next->pprev;
|
||||
n->next = next;
|
||||
next->pprev = &n->next;
|
||||
*(n->pprev) = n;
|
||||
struct hlist_node *next)
|
||||
{
|
||||
n->pprev = next->pprev;
|
||||
n->next = next;
|
||||
next->pprev = &n->next;
|
||||
*(n->pprev) = n;
|
||||
}
|
||||
|
||||
static inline void hlist_add_behind(struct hlist_node *n,
|
||||
struct hlist_node *prev) {
|
||||
n->next = prev->next;
|
||||
prev->next = n;
|
||||
n->pprev = &prev->next;
|
||||
struct hlist_node *prev)
|
||||
{
|
||||
n->next = prev->next;
|
||||
prev->next = n;
|
||||
n->pprev = &prev->next;
|
||||
|
||||
if (n->next)
|
||||
n->next->pprev = &n->next;
|
||||
if (n->next)
|
||||
n->next->pprev = &n->next;
|
||||
}
|
||||
|
||||
/* after that we'll appear to be on some hlist and hlist_del will work */
|
||||
static inline void hlist_add_fake(struct hlist_node *n) { n->pprev = &n->next; }
|
||||
static inline void hlist_add_fake(struct hlist_node *n)
|
||||
{
|
||||
n->pprev = &n->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move a list from one list head to another. Fixup the pprev
|
||||
* reference of the first entry if it exists.
|
||||
*/
|
||||
static inline void hlist_move_list(struct hlist_head *old,
|
||||
struct hlist_head *new) {
|
||||
new->first = old->first;
|
||||
if (new->first)
|
||||
new->first->pprev = &new->first;
|
||||
old->first = NULL;
|
||||
struct hlist_head *new)
|
||||
{
|
||||
new->first = old->first;
|
||||
if (new->first)
|
||||
new->first->pprev = &new->first;
|
||||
old->first = NULL;
|
||||
}
|
||||
|
||||
#define hlist_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
|
||||
#define hlist_for_each(pos, head) \
|
||||
for (pos = (head)->first; pos; pos = pos->next)
|
||||
#define hlist_for_each(pos, head) \
|
||||
for (pos = (head)->first; pos ; pos = pos->next)
|
||||
|
||||
#define hlist_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->first; pos && ({ \
|
||||
n = pos->next; \
|
||||
1; \
|
||||
}); \
|
||||
pos = n)
|
||||
#define hlist_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
|
||||
pos = n)
|
||||
|
||||
#define hlist_entry_safe(ptr, type, member) \
|
||||
({ \
|
||||
typeof(ptr) ____ptr = (ptr); \
|
||||
____ptr ? hlist_entry(____ptr, type, member) : NULL; \
|
||||
})
|
||||
#define hlist_entry_safe(ptr, type, member) \
|
||||
({ typeof(ptr) ____ptr = (ptr); \
|
||||
____ptr ? hlist_entry(____ptr, type, member) : NULL; \
|
||||
})
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry - iterate over list of given type
|
||||
@@ -765,45 +807,40 @@ static inline void hlist_move_list(struct hlist_head *old,
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry(pos, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
#define hlist_for_each_entry(pos, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
|
||||
pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_continue - iterate over a hlist continuing after current
|
||||
* point
|
||||
* hlist_for_each_entry_continue - iterate over a hlist continuing after current point
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_continue(pos, member) \
|
||||
for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member); \
|
||||
pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
#define hlist_for_each_entry_continue(pos, member) \
|
||||
for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\
|
||||
pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_from - iterate over a hlist continuing from current
|
||||
* point
|
||||
* hlist_for_each_entry_from - iterate over a hlist continuing from current point
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_from(pos, member) \
|
||||
for (; pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
#define hlist_for_each_entry_from(pos, member) \
|
||||
for (; pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_safe - iterate over list of given type safe against
|
||||
* removal of list entry
|
||||
* hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: a &struct hlist_node to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
|
||||
pos && ({ \
|
||||
n = pos->member.next; \
|
||||
1; \
|
||||
}); \
|
||||
pos = hlist_entry_safe(n, typeof(*pos), member))
|
||||
#define hlist_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\
|
||||
pos && ({ n = pos->member.next; 1; }); \
|
||||
pos = hlist_entry_safe(n, typeof(*pos), member))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,253 +4,243 @@
|
||||
#ifndef _RKCRYPTO_COMMON_H_
|
||||
#define _RKCRYPTO_COMMON_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef uint32_t RK_RES;
|
||||
typedef uint32_t rk_handle;
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
||||
/* RK_CRYPTO api verison */
|
||||
#define RK_CRYPTO_API_MAJOR_VERSION 1
|
||||
#define RK_CRYPTO_API_MINOR_VERSION 2
|
||||
#define RK_CRYPTO_API_REVISION_VERSION 0
|
||||
#define RK_CRYPTO_API_MAJOR_VERSION 1
|
||||
#define RK_CRYPTO_API_MINOR_VERSION 2
|
||||
#define RK_CRYPTO_API_REVISION_VERSION 3
|
||||
|
||||
#define RK_CRYPTO_API_VERSION \
|
||||
STR(RK_CRYPTO_API_MAJOR_VERSION) \
|
||||
"." STR(RK_CRYPTO_API_MINOR_VERSION) "." STR(RK_CRYPTO_API_REVISION_VERSION)
|
||||
#define RK_CRYPTO_API_VERSION STR(RK_CRYPTO_API_MAJOR_VERSION) "." \
|
||||
STR(RK_CRYPTO_API_MINOR_VERSION) "." \
|
||||
STR(RK_CRYPTO_API_REVISION_VERSION)
|
||||
|
||||
#define RK_CRYPTO_API_FULL_VERSION "rkcrypto api version " RK_CRYPTO_API_VERSION
|
||||
|
||||
/* API return codes */
|
||||
#define RK_CRYPTO_SUCCESS 0x00000000
|
||||
#define RK_CRYPTO_ERR_GENERIC 0xF0000000
|
||||
#define RK_CRYPTO_ERR_PARAMETER 0xF0000001
|
||||
#define RK_CRYPTO_ERR_STATE 0xF0000002
|
||||
#define RK_CRYPTO_ERR_NOT_SUPPORTED 0xF0000003
|
||||
#define RK_CRYPTO_ERR_OUT_OF_MEMORY 0xF0000004
|
||||
#define RK_CRYPTO_ERR_ACCESS_DENIED 0xF0000005
|
||||
#define RK_CRYPTO_ERR_BUSY 0xF0000006
|
||||
#define RK_CRYPTO_ERR_TIMEOUT 0xF0000007
|
||||
#define RK_CRYPTO_ERR_UNINITED 0xF0000008
|
||||
#define RK_CRYPTO_ERR_KEY 0xF0000009
|
||||
#define RK_CRYPTO_ERR_VERIFY 0xF000000A
|
||||
#define RK_CRYPTO_ERR_PADDING 0xF000000B
|
||||
#define RK_CRYPTO_ERR_PADDING_OVERFLOW 0xF000000C
|
||||
#define RK_CRYPTO_ERR_MAC_INVALID 0xF000000D
|
||||
#define RK_CRYPTO_SUCCESS 0x00000000
|
||||
#define RK_CRYPTO_ERR_GENERIC 0xF0000000
|
||||
#define RK_CRYPTO_ERR_PARAMETER 0xF0000001
|
||||
#define RK_CRYPTO_ERR_STATE 0xF0000002
|
||||
#define RK_CRYPTO_ERR_NOT_SUPPORTED 0xF0000003
|
||||
#define RK_CRYPTO_ERR_OUT_OF_MEMORY 0xF0000004
|
||||
#define RK_CRYPTO_ERR_ACCESS_DENIED 0xF0000005
|
||||
#define RK_CRYPTO_ERR_BUSY 0xF0000006
|
||||
#define RK_CRYPTO_ERR_TIMEOUT 0xF0000007
|
||||
#define RK_CRYPTO_ERR_UNINITED 0xF0000008
|
||||
#define RK_CRYPTO_ERR_KEY 0xF0000009
|
||||
#define RK_CRYPTO_ERR_VERIFY 0xF000000A
|
||||
#define RK_CRYPTO_ERR_PADDING 0xF000000B
|
||||
#define RK_CRYPTO_ERR_PADDING_OVERFLOW 0xF000000C
|
||||
#define RK_CRYPTO_ERR_MAC_INVALID 0xF000000D
|
||||
|
||||
/* Algorithm operation */
|
||||
#define RK_OP_CIPHER_ENC 1
|
||||
#define RK_OP_CIPHER_DEC 0
|
||||
#define RK_OP_CIPHER_ENC 1
|
||||
#define RK_OP_CIPHER_DEC 0
|
||||
|
||||
/* Algorithm block length */
|
||||
#define DES_BLOCK_SIZE 8
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define SM4_BLOCK_SIZE 16
|
||||
#define SHA1_HASH_SIZE 20
|
||||
#define SHA224_HASH_SIZE 28
|
||||
#define SHA256_HASH_SIZE 32
|
||||
#define SHA384_HASH_SIZE 48
|
||||
#define SHA512_HASH_SIZE 64
|
||||
#define SHA512_224_HASH_SIZE 28
|
||||
#define SHA512_256_HASH_SIZE 32
|
||||
#define MD5_HASH_SIZE 16
|
||||
#define SM3_HASH_SIZE 32
|
||||
#define DES_BLOCK_SIZE 8
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define SM4_BLOCK_SIZE 16
|
||||
#define SHA1_HASH_SIZE 20
|
||||
#define SHA224_HASH_SIZE 28
|
||||
#define SHA256_HASH_SIZE 32
|
||||
#define SHA384_HASH_SIZE 48
|
||||
#define SHA512_HASH_SIZE 64
|
||||
#define SHA512_224_HASH_SIZE 28
|
||||
#define SHA512_256_HASH_SIZE 32
|
||||
#define MD5_HASH_SIZE 16
|
||||
#define SM3_HASH_SIZE 32
|
||||
|
||||
#define SM3_BLOCK_SIZE 64
|
||||
#define SHA1_BLOCK_SIZE 64
|
||||
#define MD5_BLOCK_SIZE 64
|
||||
#define SHA224_BLOCK_SIZE 64
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
#define SHA384_BLOCK_SIZE 128
|
||||
#define SHA512_BLOCK_SIZE 128
|
||||
#define SHA512_224_BLOCK_SIZE 128
|
||||
#define SHA512_256_BLOCK_SIZE 128
|
||||
#define SM3_BLOCK_SIZE 64
|
||||
#define SHA1_BLOCK_SIZE 64
|
||||
#define MD5_BLOCK_SIZE 64
|
||||
#define SHA224_BLOCK_SIZE 64
|
||||
#define SHA256_BLOCK_SIZE 64
|
||||
#define SHA384_BLOCK_SIZE 128
|
||||
#define SHA512_BLOCK_SIZE 128
|
||||
#define SHA512_224_BLOCK_SIZE 128
|
||||
#define SHA512_256_BLOCK_SIZE 128
|
||||
|
||||
#define AES_AE_DATA_BLOCK 128
|
||||
#define MAX_HASH_BLOCK_SIZE 128
|
||||
#define MAX_TDES_KEY_SIZE 24
|
||||
#define MAX_AES_KEY_SIZE 32
|
||||
#define MAX_AE_TAG_SIZE 16
|
||||
#define AES_AE_DATA_BLOCK 128
|
||||
#define MAX_HASH_BLOCK_SIZE 128
|
||||
#define MAX_TDES_KEY_SIZE 24
|
||||
#define MAX_AES_KEY_SIZE 32
|
||||
#define MAX_AE_TAG_SIZE 16
|
||||
|
||||
#define RSA_BITS_1024 1024
|
||||
#define RSA_BITS_2048 2048
|
||||
#define RSA_BITS_3072 3072
|
||||
#define RSA_BITS_4096 4096
|
||||
#define MAX_RSA_KEY_BITS RSA_BITS_4096
|
||||
#define RSA_BITS_1024 1024
|
||||
#define RSA_BITS_2048 2048
|
||||
#define RSA_BITS_3072 3072
|
||||
#define RSA_BITS_4096 4096
|
||||
#define MAX_RSA_KEY_BITS RSA_BITS_4096
|
||||
|
||||
#define RK_CRYPTO_MAX_DATA_LEN (1 * 1024 * 1024)
|
||||
#define RK_CRYPTO_MAX_DATA_LEN (1 * 1024 * 1024)
|
||||
|
||||
/* Crypto algorithm */
|
||||
enum RK_CRYPTO_ALGO {
|
||||
RK_ALGO_CIPHER_TOP = 0x00,
|
||||
RK_ALGO_AES,
|
||||
RK_ALGO_DES,
|
||||
RK_ALGO_TDES,
|
||||
RK_ALGO_SM4,
|
||||
RK_ALGO_CIPHER_BUTT,
|
||||
RK_ALGO_CIPHER_TOP = 0x00,
|
||||
RK_ALGO_AES,
|
||||
RK_ALGO_DES,
|
||||
RK_ALGO_TDES,
|
||||
RK_ALGO_SM4,
|
||||
RK_ALGO_CIPHER_BUTT,
|
||||
|
||||
RK_ALGO_HASH_TOP = 0x10,
|
||||
RK_ALGO_MD5,
|
||||
RK_ALGO_SHA1,
|
||||
RK_ALGO_SHA256,
|
||||
RK_ALGO_SHA224,
|
||||
RK_ALGO_SHA512,
|
||||
RK_ALGO_SHA384,
|
||||
RK_ALGO_SHA512_224,
|
||||
RK_ALGO_SHA512_256,
|
||||
RK_ALGO_SM3,
|
||||
RK_ALGO_HASH_BUTT,
|
||||
RK_ALGO_HASH_TOP = 0x10,
|
||||
RK_ALGO_MD5,
|
||||
RK_ALGO_SHA1,
|
||||
RK_ALGO_SHA256,
|
||||
RK_ALGO_SHA224,
|
||||
RK_ALGO_SHA512,
|
||||
RK_ALGO_SHA384,
|
||||
RK_ALGO_SHA512_224,
|
||||
RK_ALGO_SHA512_256,
|
||||
RK_ALGO_SM3,
|
||||
RK_ALGO_HASH_BUTT,
|
||||
|
||||
RK_ALGO_HMAC_TOP = 0x20,
|
||||
RK_ALGO_HMAC_MD5,
|
||||
RK_ALGO_HMAC_SHA1,
|
||||
RK_ALGO_HMAC_SHA256,
|
||||
RK_ALGO_HMAC_SHA512,
|
||||
RK_ALGO_HMAC_SM3,
|
||||
RK_ALGO_CMAC_AES,
|
||||
RK_ALGO_CBCMAC_AES,
|
||||
RK_ALGO_CMAC_SM4,
|
||||
RK_ALGO_CBCMAC_SM4,
|
||||
RK_ALGO_HMAC_BUTT,
|
||||
RK_ALGO_HMAC_TOP = 0x20,
|
||||
RK_ALGO_HMAC_MD5,
|
||||
RK_ALGO_HMAC_SHA1,
|
||||
RK_ALGO_HMAC_SHA256,
|
||||
RK_ALGO_HMAC_SHA512,
|
||||
RK_ALGO_HMAC_SM3,
|
||||
RK_ALGO_CMAC_AES,
|
||||
RK_ALGO_CBCMAC_AES,
|
||||
RK_ALGO_CMAC_SM4,
|
||||
RK_ALGO_CBCMAC_SM4,
|
||||
RK_ALGO_HMAC_BUTT,
|
||||
};
|
||||
|
||||
/* Crypto mode */
|
||||
enum RK_CIPIHER_MODE {
|
||||
RK_CIPHER_MODE_ECB = 0,
|
||||
RK_CIPHER_MODE_CBC,
|
||||
RK_CIPHER_MODE_CTS,
|
||||
RK_CIPHER_MODE_CTR,
|
||||
RK_CIPHER_MODE_CFB,
|
||||
RK_CIPHER_MODE_OFB,
|
||||
RK_CIPHER_MODE_XTS,
|
||||
RK_CIPHER_MODE_CCM,
|
||||
RK_CIPHER_MODE_GCM,
|
||||
RK_CIPHER_MODE_MAX
|
||||
RK_CIPHER_MODE_ECB = 0,
|
||||
RK_CIPHER_MODE_CBC,
|
||||
RK_CIPHER_MODE_CTS,
|
||||
RK_CIPHER_MODE_CTR,
|
||||
RK_CIPHER_MODE_CFB,
|
||||
RK_CIPHER_MODE_OFB,
|
||||
RK_CIPHER_MODE_XTS,
|
||||
RK_CIPHER_MODE_CCM,
|
||||
RK_CIPHER_MODE_GCM,
|
||||
RK_CIPHER_MODE_MAX
|
||||
};
|
||||
|
||||
enum RK_OEM_OTP_KEYID {
|
||||
RK_OEM_OTP_KEY0 = 0,
|
||||
RK_OEM_OTP_KEY1 = 1,
|
||||
RK_OEM_OTP_KEY2 = 2,
|
||||
RK_OEM_OTP_KEY3 = 3,
|
||||
RK_OEM_OTP_KEY_FW = 10, // keyid of fw_encryption_key
|
||||
RK_OEM_OTP_KEYMAX
|
||||
RK_OEM_OTP_KEY0 = 0,
|
||||
RK_OEM_OTP_KEY1 = 1,
|
||||
RK_OEM_OTP_KEY2 = 2,
|
||||
RK_OEM_OTP_KEY3 = 3,
|
||||
RK_OEM_OTP_KEY_FW = 10, // keyid of fw_encryption_key
|
||||
RK_OEM_OTP_KEYMAX
|
||||
};
|
||||
|
||||
enum RK_RSA_KEY_TYPE {
|
||||
RK_RSA_KEY_TYPE_PLAIN = 0,
|
||||
RK_RSA_KEY_TYPE_KEY0_ENC = RK_OEM_OTP_KEY0 + 1,
|
||||
RK_RSA_KEY_TYPE_KEY1_ENC,
|
||||
RK_RSA_KEY_TYPE_KEY2_ENC,
|
||||
RK_RSA_KEY_TYPE_KEY3_ENC,
|
||||
RK_RSA_KEY_TYPE_MAX,
|
||||
RK_RSA_KEY_TYPE_PLAIN = 0,
|
||||
RK_RSA_KEY_TYPE_KEY0_ENC = RK_OEM_OTP_KEY0 +1,
|
||||
RK_RSA_KEY_TYPE_KEY1_ENC,
|
||||
RK_RSA_KEY_TYPE_KEY2_ENC,
|
||||
RK_RSA_KEY_TYPE_KEY3_ENC,
|
||||
RK_RSA_KEY_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum RK_RSA_CRYPT_PADDING {
|
||||
RK_RSA_CRYPT_PADDING_NONE = 0x00, /* without padding */
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_0, /* PKCS#1 block type 0 padding*/
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_1, /* PKCS#1 block type 1padding*/
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_2, /* PKCS#1 block type 2 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA1, /* PKCS#1 RSAES-OAEP-SHA1 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA224, /* PKCS#1 RSAES-OAEP-SHA224 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA256, /* PKCS#1 RSAES-OAEP-SHA256 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA384, /* PKCS#1 RSAES-OAEP-SHA384 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA512, /* PKCS#1 RSAES-OAEP-SHA512 padding*/
|
||||
RK_RSA_CRYPT_PADDING_PKCS1_V1_5, /* PKCS#1 RSAES-PKCS1_V1_5 padding*/
|
||||
RK_RSA_CRYPT_PADDING_NONE = 0x00, /* without padding */
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_0, /* PKCS#1 block type 0 padding*/
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_1, /* PKCS#1 block type 1padding*/
|
||||
RK_RSA_CRYPT_PADDING_BLOCK_TYPE_2, /* PKCS#1 block type 2 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA1, /* PKCS#1 RSAES-OAEP-SHA1 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA224, /* PKCS#1 RSAES-OAEP-SHA224 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA256, /* PKCS#1 RSAES-OAEP-SHA256 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA384, /* PKCS#1 RSAES-OAEP-SHA384 padding*/
|
||||
RK_RSA_CRYPT_PADDING_OAEP_SHA512, /* PKCS#1 RSAES-OAEP-SHA512 padding*/
|
||||
RK_RSA_CRYPT_PADDING_PKCS1_V1_5, /* PKCS#1 RSAES-PKCS1_V1_5 padding*/
|
||||
};
|
||||
|
||||
enum RK_RSA_SIGN_PADDING {
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA1 =
|
||||
0x100, /* PKCS#1 RSASSA_PKCS1_V15_SHA1 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA224, /* PKCS#1 RSASSA_PKCS1_V15_SHA224
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA256, /* PKCS#1 RSASSA_PKCS1_V15_SHA256
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA384, /* PKCS#1 RSASSA_PKCS1_V15_SHA384
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA512, /* PKCS#1 RSASSA_PKCS1_V15_SHA512
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA1, /* PKCS#1 RSASSA_PKCS1_PSS_SHA1
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA224, /* PKCS#1 RSASSA_PKCS1_PSS_SHA224
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA256, /* PKCS#1 RSASSA_PKCS1_PSS_SHA256
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA384, /* PKCS#1 RSASSA_PKCS1_PSS_SHA1
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA512, /* PKCS#1 RSASSA_PKCS1_PSS_SHA256
|
||||
signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA1 = 0x100,/* PKCS#1 RSASSA_PKCS1_V15_SHA1 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA224, /* PKCS#1 RSASSA_PKCS1_V15_SHA224 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA256, /* PKCS#1 RSASSA_PKCS1_V15_SHA256 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA384, /* PKCS#1 RSASSA_PKCS1_V15_SHA384 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_V15_SHA512, /* PKCS#1 RSASSA_PKCS1_V15_SHA512 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA1, /* PKCS#1 RSASSA_PKCS1_PSS_SHA1 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA224, /* PKCS#1 RSASSA_PKCS1_PSS_SHA224 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA256, /* PKCS#1 RSASSA_PKCS1_PSS_SHA256 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA384, /* PKCS#1 RSASSA_PKCS1_PSS_SHA1 signature*/
|
||||
RK_RSA_SIGN_PADDING_PKCS1_PSS_SHA512, /* PKCS#1 RSASSA_PKCS1_PSS_SHA256 signature*/
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t algo;
|
||||
uint32_t mode;
|
||||
uint32_t operation;
|
||||
uint8_t key[64];
|
||||
uint32_t key_len;
|
||||
uint8_t iv[16];
|
||||
void *reserved;
|
||||
uint32_t algo;
|
||||
uint32_t mode;
|
||||
uint32_t operation;
|
||||
uint8_t key[64];
|
||||
uint32_t key_len;
|
||||
uint8_t iv[16];
|
||||
void *reserved;
|
||||
} rk_cipher_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t algo;
|
||||
uint32_t mode;
|
||||
uint32_t operation;
|
||||
uint8_t key[32];
|
||||
uint32_t key_len;
|
||||
uint8_t iv[16];
|
||||
uint32_t iv_len;
|
||||
uint32_t tag_len;
|
||||
uint32_t aad_len;
|
||||
uint32_t payload_len;
|
||||
void *reserved;
|
||||
uint32_t algo;
|
||||
uint32_t mode;
|
||||
uint32_t operation;
|
||||
uint8_t key[32];
|
||||
uint32_t key_len;
|
||||
uint8_t iv[16];
|
||||
uint32_t iv_len;
|
||||
uint32_t tag_len;
|
||||
uint32_t aad_len;
|
||||
uint32_t payload_len;
|
||||
void *reserved;
|
||||
} rk_ae_config;
|
||||
|
||||
typedef struct {
|
||||
uint32_t algo;
|
||||
uint8_t *key;
|
||||
uint32_t key_len;
|
||||
uint32_t algo;
|
||||
uint8_t *key;
|
||||
uint32_t key_len;
|
||||
} rk_hash_config;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *n;
|
||||
const uint8_t *e;
|
||||
const uint8_t *n;
|
||||
const uint8_t *e;
|
||||
|
||||
uint16_t n_len;
|
||||
uint16_t e_len;
|
||||
uint16_t n_len;
|
||||
uint16_t e_len;
|
||||
} rk_rsa_pub_key;
|
||||
|
||||
typedef struct {
|
||||
enum RK_RSA_KEY_TYPE key_type;
|
||||
rk_rsa_pub_key key;
|
||||
enum RK_RSA_KEY_TYPE key_type;
|
||||
rk_rsa_pub_key key;
|
||||
} rk_rsa_pub_key_pack;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *n;
|
||||
const uint8_t *e;
|
||||
const uint8_t *d;
|
||||
const uint8_t *p;
|
||||
const uint8_t *q;
|
||||
const uint8_t *dp;
|
||||
const uint8_t *dq;
|
||||
const uint8_t *qp;
|
||||
const uint8_t *n;
|
||||
const uint8_t *e;
|
||||
const uint8_t *d;
|
||||
const uint8_t *p;
|
||||
const uint8_t *q;
|
||||
const uint8_t *dp;
|
||||
const uint8_t *dq;
|
||||
const uint8_t *qp;
|
||||
|
||||
uint16_t n_len;
|
||||
uint16_t e_len;
|
||||
uint16_t d_len;
|
||||
uint16_t p_len;
|
||||
uint16_t q_len;
|
||||
uint16_t dp_len;
|
||||
uint16_t dq_len;
|
||||
uint16_t qp_len;
|
||||
uint16_t n_len;
|
||||
uint16_t e_len;
|
||||
uint16_t d_len;
|
||||
uint16_t p_len;
|
||||
uint16_t q_len;
|
||||
uint16_t dp_len;
|
||||
uint16_t dq_len;
|
||||
uint16_t qp_len;
|
||||
} rk_rsa_priv_key;
|
||||
|
||||
typedef struct {
|
||||
enum RK_RSA_KEY_TYPE key_type;
|
||||
rk_rsa_priv_key key;
|
||||
enum RK_RSA_KEY_TYPE key_type;
|
||||
rk_rsa_priv_key key;
|
||||
} rk_rsa_priv_key_pack;
|
||||
|
||||
#endif /* _RKCRYPTO_COMMON_H_ */
|
||||
|
||||
@@ -5,51 +5,42 @@
|
||||
#ifndef __RKCRYPTO_CORE_H__
|
||||
#define __RKCRYPTO_CORE_H__
|
||||
|
||||
#include "rkcrypto_common.h"
|
||||
#include <stdint.h>
|
||||
#include "rkcrypto_common.h"
|
||||
|
||||
RK_RES rk_crypto_init(void);
|
||||
void rk_crypto_deinit(void);
|
||||
RK_RES rk_cipher_init(const rk_cipher_config *config, rk_handle *handle);
|
||||
RK_RES rk_cipher_crypt(rk_handle handle, int in_fd, int out_fd, uint32_t len);
|
||||
RK_RES rk_cipher_crypt_virt(rk_handle handle, const uint8_t *in, uint8_t *out,
|
||||
uint32_t len);
|
||||
RK_RES rk_cipher_crypt_virt(rk_handle handle, const uint8_t *in, uint8_t *out, uint32_t len);
|
||||
RK_RES rk_cipher_final(rk_handle handle);
|
||||
|
||||
RK_RES rk_ae_init(const rk_ae_config *config, rk_handle *handle);
|
||||
RK_RES rk_ae_set_aad(rk_handle handle, int aad_fd);
|
||||
RK_RES rk_ae_set_aad_virt(rk_handle handle, uint8_t *aad_virt);
|
||||
RK_RES rk_ae_crypt(rk_handle handle, int in_fd, int out_fd, uint32_t len,
|
||||
uint8_t *tag);
|
||||
RK_RES rk_ae_crypt_virt(rk_handle handle, const uint8_t *in, uint8_t *out,
|
||||
uint32_t len, uint8_t *tag);
|
||||
RK_RES rk_ae_crypt(rk_handle handle, int in_fd, int out_fd, uint32_t len, uint8_t *tag);
|
||||
RK_RES rk_ae_crypt_virt(rk_handle handle, const uint8_t *in, uint8_t *out, uint32_t len,
|
||||
uint8_t *tag);
|
||||
RK_RES rk_ae_final(rk_handle handle);
|
||||
|
||||
RK_RES rk_hash_init(const rk_hash_config *config, rk_handle *handle);
|
||||
RK_RES rk_hash_update(rk_handle handle, int data_fd, uint32_t data_len);
|
||||
RK_RES rk_hash_update_virt(rk_handle handle, const uint8_t *data,
|
||||
uint32_t data_len);
|
||||
RK_RES rk_hash_update_virt(rk_handle handle, const uint8_t *data, uint32_t data_len);
|
||||
RK_RES rk_hash_final(rk_handle handle, uint8_t *hash);
|
||||
|
||||
RK_RES rk_rsa_pub_encrypt(const rk_rsa_pub_key_pack *pub,
|
||||
enum RK_RSA_CRYPT_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_priv_decrypt(const rk_rsa_priv_key_pack *priv,
|
||||
enum RK_RSA_CRYPT_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_priv_encrypt(const rk_rsa_priv_key_pack *priv,
|
||||
enum RK_RSA_CRYPT_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_pub_decrypt(const rk_rsa_pub_key_pack *pub,
|
||||
enum RK_RSA_CRYPT_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_sign(const rk_rsa_priv_key_pack *priv,
|
||||
enum RK_RSA_SIGN_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, const uint8_t *hash, uint8_t *out,
|
||||
uint32_t *out_len);
|
||||
RK_RES rk_rsa_verify(const rk_rsa_pub_key_pack *pub,
|
||||
enum RK_RSA_SIGN_PADDING padding, const uint8_t *in,
|
||||
uint32_t in_len, const uint8_t *hash, uint8_t *sign,
|
||||
uint32_t sign_len);
|
||||
RK_RES rk_rsa_pub_encrypt(const rk_rsa_pub_key_pack *pub, enum RK_RSA_CRYPT_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_priv_decrypt(const rk_rsa_priv_key_pack *priv, enum RK_RSA_CRYPT_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_priv_encrypt(const rk_rsa_priv_key_pack *priv, enum RK_RSA_CRYPT_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_pub_decrypt(const rk_rsa_pub_key_pack *pub, enum RK_RSA_CRYPT_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_sign(const rk_rsa_priv_key_pack *priv, enum RK_RSA_SIGN_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, const uint8_t *hash,
|
||||
uint8_t *out, uint32_t *out_len);
|
||||
RK_RES rk_rsa_verify(const rk_rsa_pub_key_pack *pub, enum RK_RSA_SIGN_PADDING padding,
|
||||
const uint8_t *in, uint32_t in_len, const uint8_t *hash,
|
||||
uint8_t *sign, uint32_t sign_len);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#ifndef _RKCRYPTO_CORE_INT_H_
|
||||
#define _RKCRYPTO_CORE_INT_H_
|
||||
|
||||
#include "rk_cryptodev.h"
|
||||
#include "rkcrypto_common.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include "rkcrypto_common.h"
|
||||
#include "rk_cryptodev.h"
|
||||
|
||||
#ifndef ROUNDUP
|
||||
#define ROUNDUP(x, y) (((x) + ((y)-1)) & ~((y)-1))
|
||||
#define ROUNDUP(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
|
||||
#endif
|
||||
|
||||
RK_RES rk_crypto_fd_ioctl(uint32_t request, struct crypt_fd_map_op *mop);
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#define __RKCRYPTO_MEM_H__
|
||||
|
||||
typedef struct {
|
||||
void *vaddr;
|
||||
int dma_fd;
|
||||
size_t size;
|
||||
void *vaddr;
|
||||
int dma_fd;
|
||||
size_t size;
|
||||
} rk_crypto_mem;
|
||||
|
||||
int rk_crypto_mem_init(void);
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
|
||||
#include "rkcrypto_common.h"
|
||||
|
||||
RK_RES rk_write_oem_otp_key(enum RK_OEM_OTP_KEYID key_id, uint8_t *key,
|
||||
uint32_t key_len);
|
||||
RK_RES rk_oem_otp_key_is_written(enum RK_OEM_OTP_KEYID key_id,
|
||||
uint8_t *is_written);
|
||||
RK_RES rk_write_oem_otp_key(enum RK_OEM_OTP_KEYID key_id, uint8_t *key, uint32_t key_len);
|
||||
RK_RES rk_oem_otp_key_is_written(enum RK_OEM_OTP_KEYID key_id, uint8_t *is_written);
|
||||
RK_RES rk_set_oem_hr_otp_read_lock(enum RK_OEM_OTP_KEYID key_id);
|
||||
RK_RES rk_oem_otp_key_cipher_virt(enum RK_OEM_OTP_KEYID key_id,
|
||||
rk_cipher_config *config, uint8_t *src,
|
||||
uint8_t *dst, uint32_t len);
|
||||
RK_RES rk_oem_otp_key_cipher(enum RK_OEM_OTP_KEYID key_id,
|
||||
rk_cipher_config *config, int32_t in_fd,
|
||||
int32_t out_fd, uint32_t len);
|
||||
RK_RES rk_oem_otp_key_cipher_virt(enum RK_OEM_OTP_KEYID key_id, rk_cipher_config *config,
|
||||
uint8_t *src, uint8_t *dst, uint32_t len);
|
||||
RK_RES rk_oem_otp_key_cipher(enum RK_OEM_OTP_KEYID key_id, rk_cipher_config *config,
|
||||
int32_t in_fd, int32_t out_fd, uint32_t len);
|
||||
|
||||
#endif /* _RKCRYPTO_OTP_KEY_H_ */
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef __RKCRYPTO_RANDOM_H__
|
||||
#define __RKCRYPTO_RANDOM_H__
|
||||
|
||||
#include "rkcrypto_common.h"
|
||||
#include <stdint.h>
|
||||
#include "rkcrypto_common.h"
|
||||
|
||||
RK_RES rk_get_random(uint8_t *data, uint32_t len);
|
||||
|
||||
|
||||
@@ -4,41 +4,43 @@
|
||||
#ifndef _RKCRYPTO_TRACE_H_
|
||||
#define _RKCRYPTO_TRACE_H_
|
||||
|
||||
#include "rkcrypto_common.h"
|
||||
#include <stdio.h>
|
||||
#include "rkcrypto_common.h"
|
||||
|
||||
enum RKCRYPTO_TRACE_LEVEL {
|
||||
TRACE_TOP = 0,
|
||||
TRACE_ERROR = 1,
|
||||
TRACE_INFO = 2,
|
||||
TRACE_DEBUG = 3,
|
||||
TRACE_VERBOSE = 4,
|
||||
TRACE_BUTT,
|
||||
TRACE_TOP = 0,
|
||||
TRACE_ERROR = 1,
|
||||
TRACE_INFO = 2,
|
||||
TRACE_DEBUG = 3,
|
||||
TRACE_VERBOSE = 4,
|
||||
TRACE_BUTT,
|
||||
};
|
||||
|
||||
void trace_printf(int level, const char *function, int line, const char *fmt,
|
||||
...);
|
||||
void hex_dump(int level, const char *function, int line,
|
||||
const char *buffer_name, const void *buffer, int len);
|
||||
#define V_TRACE(...) \
|
||||
trace_printf(TRACE_VERBOSE, __func__, __LINE__, __VA_ARGS__)
|
||||
void trace_printf(int level, const char *function, int line, const char *fmt, ...);
|
||||
void hex_dump(int level, const char *function, int line, const char *buffer_name,
|
||||
const void *buffer, int len);
|
||||
#define V_TRACE(...) \
|
||||
trace_printf(TRACE_VERBOSE, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define D_TRACE(...) trace_printf(TRACE_DEBUG, __func__, __LINE__, __VA_ARGS__)
|
||||
#define D_TRACE(...) \
|
||||
trace_printf(TRACE_DEBUG, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define I_TRACE(...) trace_printf(TRACE_INFO, __func__, __LINE__, __VA_ARGS__)
|
||||
#define I_TRACE(...) \
|
||||
trace_printf(TRACE_INFO, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define E_TRACE(...) trace_printf(TRACE_ERROR, __func__, __LINE__, __VA_ARGS__)
|
||||
#define E_TRACE(...) \
|
||||
trace_printf(TRACE_ERROR, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define VHEX_DUMP(buffer_name, buffer, len) \
|
||||
hex_dump(TRACE_VERBOSE, __func__, __LINE__, buffer_name, buffer, len)
|
||||
#define VHEX_DUMP(buffer_name, buffer, len) \
|
||||
hex_dump(TRACE_VERBOSE, __func__, __LINE__, buffer_name, buffer, len)
|
||||
|
||||
#define RK_CRYPTO_CHECK_PARAM(_val) \
|
||||
do { \
|
||||
if (_val) { \
|
||||
E_TRACE("RK_CRYPTO_CHECK_PARAM ERR! 0x%08x", RK_CRYPTO_ERR_PARAMETER); \
|
||||
return RK_CRYPTO_ERR_PARAMETER; \
|
||||
} \
|
||||
} while (0)
|
||||
#define RK_CRYPTO_CHECK_PARAM(_val)\
|
||||
do {\
|
||||
if (_val) {\
|
||||
E_TRACE("RK_CRYPTO_CHECK_PARAM ERR! 0x%08x", RK_CRYPTO_ERR_PARAMETER);\
|
||||
return RK_CRYPTO_ERR_PARAMETER;\
|
||||
}\
|
||||
} while (0)
|
||||
|
||||
RK_RES rkcrypto_set_trace_level(enum RKCRYPTO_TRACE_LEVEL level);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user