crypto: msm: Add QTI crypto drivers
This is a snapshot of the crypto drivers as of msm-4.4 commit <726279510b02ba9> (msm: pcie: add sysfs entry for PCIe enumeration). Change-Id: Ic17740bbdba72cf6fca352da7c629c5a3cfcae90 Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
This commit is contained in:
parent
04d60cf014
commit
e78789a497
2 changed files with 19621 additions and 131 deletions
|
|
@ -5,24 +5,24 @@
|
|||
#include <linux/ioctl.h>
|
||||
|
||||
/**
|
||||
* fips_status: global FIPS140-2 status
|
||||
* @FIPS140_STATUS_NA:
|
||||
* Not a FIPS140-2 compliant Build.
|
||||
* The flag status won't
|
||||
* change throughout
|
||||
* the lifetime
|
||||
* @FIPS140_STATUS_PASS_CRYPTO:
|
||||
* KAT self tests are passed.
|
||||
* @FIPS140_STATUS_QCRYPTO_ALLOWED:
|
||||
* Integrity test is passed.
|
||||
* @FIPS140_STATUS_PASS:
|
||||
* All tests are passed and build
|
||||
* is in FIPS140-2 mode
|
||||
* @FIPS140_STATUS_FAIL:
|
||||
* One of the test is failed.
|
||||
* This will block all requests
|
||||
* to crypto modules
|
||||
*/
|
||||
* fips_status: global FIPS140-2 status
|
||||
* @FIPS140_STATUS_NA:
|
||||
* Not a FIPS140-2 compliant Build.
|
||||
* The flag status won't
|
||||
* change throughout
|
||||
* the lifetime
|
||||
* @FIPS140_STATUS_PASS_CRYPTO:
|
||||
* KAT self tests are passed.
|
||||
* @FIPS140_STATUS_QCRYPTO_ALLOWED:
|
||||
* Integrity test is passed.
|
||||
* @FIPS140_STATUS_PASS:
|
||||
* All tests are passed and build
|
||||
* is in FIPS140-2 mode
|
||||
* @FIPS140_STATUS_FAIL:
|
||||
* One of the test is failed.
|
||||
* This will block all requests
|
||||
* to crypto modules
|
||||
*/
|
||||
enum fips_status {
|
||||
FIPS140_STATUS_NA = 0,
|
||||
FIPS140_STATUS_PASS_CRYPTO = 1,
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
#define QCEDEV_AES_KEY_192 24
|
||||
#define QCEDEV_AES_KEY_256 32
|
||||
/**
|
||||
*qcedev_oper_enum: Operation types
|
||||
* @QCEDEV_OPER_ENC: Encrypt
|
||||
* @QCEDEV_OPER_DEC: Decrypt
|
||||
* @QCEDEV_OPER_ENC_NO_KEY: Encrypt. Do not need key to be specified by
|
||||
* user. Key already set by an external processor.
|
||||
* @QCEDEV_OPER_DEC_NO_KEY: Decrypt. Do not need the key to be specified by
|
||||
* user. Key already set by an external processor.
|
||||
*/
|
||||
*qcedev_oper_enum: Operation types
|
||||
* @QCEDEV_OPER_ENC: Encrypt
|
||||
* @QCEDEV_OPER_DEC: Decrypt
|
||||
* @QCEDEV_OPER_ENC_NO_KEY: Encrypt. Do not need key to be specified by
|
||||
* user. Key already set by an external processor.
|
||||
* @QCEDEV_OPER_DEC_NO_KEY: Decrypt. Do not need the key to be specified by
|
||||
* user. Key already set by an external processor.
|
||||
*/
|
||||
enum qcedev_oper_enum {
|
||||
QCEDEV_OPER_DEC = 0,
|
||||
QCEDEV_OPER_ENC = 1,
|
||||
|
|
@ -37,11 +37,11 @@ enum qcedev_oper_enum {
|
|||
};
|
||||
|
||||
/**
|
||||
*qcedev_oper_enum: Cipher algorithm types
|
||||
* @QCEDEV_ALG_DES: DES
|
||||
* @QCEDEV_ALG_3DES: 3DES
|
||||
* @QCEDEV_ALG_AES: AES
|
||||
*/
|
||||
*qcedev_oper_enum: Cipher algorithm types
|
||||
* @QCEDEV_ALG_DES: DES
|
||||
* @QCEDEV_ALG_3DES: 3DES
|
||||
* @QCEDEV_ALG_AES: AES
|
||||
*/
|
||||
enum qcedev_cipher_alg_enum {
|
||||
QCEDEV_ALG_DES = 0,
|
||||
QCEDEV_ALG_3DES = 1,
|
||||
|
|
@ -50,15 +50,15 @@ enum qcedev_cipher_alg_enum {
|
|||
};
|
||||
|
||||
/**
|
||||
*qcedev_cipher_mode_enum : AES mode
|
||||
* @QCEDEV_AES_MODE_CBC: CBC
|
||||
* @QCEDEV_AES_MODE_ECB: ECB
|
||||
* @QCEDEV_AES_MODE_CTR: CTR
|
||||
* @QCEDEV_AES_MODE_XTS: XTS
|
||||
* @QCEDEV_AES_MODE_CCM: CCM
|
||||
* @QCEDEV_DES_MODE_CBC: CBC
|
||||
* @QCEDEV_DES_MODE_ECB: ECB
|
||||
*/
|
||||
*qcedev_cipher_mode_enum : AES mode
|
||||
* @QCEDEV_AES_MODE_CBC: CBC
|
||||
* @QCEDEV_AES_MODE_ECB: ECB
|
||||
* @QCEDEV_AES_MODE_CTR: CTR
|
||||
* @QCEDEV_AES_MODE_XTS: XTS
|
||||
* @QCEDEV_AES_MODE_CCM: CCM
|
||||
* @QCEDEV_DES_MODE_CBC: CBC
|
||||
* @QCEDEV_DES_MODE_ECB: ECB
|
||||
*/
|
||||
enum qcedev_cipher_mode_enum {
|
||||
QCEDEV_AES_MODE_CBC = 0,
|
||||
QCEDEV_AES_MODE_ECB = 1,
|
||||
|
|
@ -71,13 +71,13 @@ enum qcedev_cipher_mode_enum {
|
|||
};
|
||||
|
||||
/**
|
||||
*enum qcedev_sha_alg_enum : Secure Hashing Algorithm
|
||||
* @QCEDEV_ALG_SHA1: Digest returned: 20 bytes (160 bits)
|
||||
* @QCEDEV_ALG_SHA256: Digest returned: 32 bytes (256 bit)
|
||||
* @QCEDEV_ALG_SHA1_HMAC: HMAC returned 20 bytes (160 bits)
|
||||
* @QCEDEV_ALG_SHA256_HMAC: HMAC returned 32 bytes (256 bit)
|
||||
* @QCEDEV_ALG_AES_CMAC: Configurable MAC size
|
||||
*/
|
||||
*enum qcedev_sha_alg_enum : Secure Hashing Algorithm
|
||||
* @QCEDEV_ALG_SHA1: Digest returned: 20 bytes (160 bits)
|
||||
* @QCEDEV_ALG_SHA256: Digest returned: 32 bytes (256 bit)
|
||||
* @QCEDEV_ALG_SHA1_HMAC: HMAC returned 20 bytes (160 bits)
|
||||
* @QCEDEV_ALG_SHA256_HMAC: HMAC returned 32 bytes (256 bit)
|
||||
* @QCEDEV_ALG_AES_CMAC: Configurable MAC size
|
||||
*/
|
||||
enum qcedev_sha_alg_enum {
|
||||
QCEDEV_ALG_SHA1 = 0,
|
||||
QCEDEV_ALG_SHA256 = 1,
|
||||
|
|
@ -88,12 +88,12 @@ enum qcedev_sha_alg_enum {
|
|||
};
|
||||
|
||||
/**
|
||||
* struct buf_info - Buffer information
|
||||
* @offset: Offset from the base address of the buffer
|
||||
* (Used when buffer is allocated using PMEM)
|
||||
* @vaddr: Virtual buffer address pointer
|
||||
* @len: Size of the buffer
|
||||
*/
|
||||
* struct buf_info - Buffer information
|
||||
* @offset: Offset from the base address of the buffer
|
||||
* (Used when buffer is allocated using PMEM)
|
||||
* @vaddr: Virtual buffer address pointer
|
||||
* @len: Size of the buffer
|
||||
*/
|
||||
struct buf_info {
|
||||
union {
|
||||
uint32_t offset;
|
||||
|
|
@ -103,26 +103,26 @@ struct buf_info {
|
|||
};
|
||||
|
||||
/**
|
||||
* struct qcedev_vbuf_info - Source and destination Buffer information
|
||||
* @src: Array of buf_info for input/source
|
||||
* @dst: Array of buf_info for output/destination
|
||||
*/
|
||||
* struct qcedev_vbuf_info - Source and destination Buffer information
|
||||
* @src: Array of buf_info for input/source
|
||||
* @dst: Array of buf_info for output/destination
|
||||
*/
|
||||
struct qcedev_vbuf_info {
|
||||
struct buf_info src[QCEDEV_MAX_BUFFERS];
|
||||
struct buf_info dst[QCEDEV_MAX_BUFFERS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct qcedev_pmem_info - Stores PMEM buffer information
|
||||
* @fd_src: Handle to /dev/adsp_pmem used to allocate
|
||||
* memory for input/src buffer
|
||||
* @src: Array of buf_info for input/source
|
||||
* @fd_dst: Handle to /dev/adsp_pmem used to allocate
|
||||
* memory for output/dst buffer
|
||||
* @dst: Array of buf_info for output/destination
|
||||
* @pmem_src_offset: The offset from input/src buffer
|
||||
* (allocated by PMEM)
|
||||
*/
|
||||
* struct qcedev_pmem_info - Stores PMEM buffer information
|
||||
* @fd_src: Handle to /dev/adsp_pmem used to allocate
|
||||
* memory for input/src buffer
|
||||
* @src: Array of buf_info for input/source
|
||||
* @fd_dst: Handle to /dev/adsp_pmem used to allocate
|
||||
* memory for output/dst buffer
|
||||
* @dst: Array of buf_info for output/destination
|
||||
* @pmem_src_offset: The offset from input/src buffer
|
||||
* (allocated by PMEM)
|
||||
*/
|
||||
struct qcedev_pmem_info {
|
||||
int fd_src;
|
||||
struct buf_info src[QCEDEV_MAX_BUFFERS];
|
||||
|
|
@ -131,52 +131,52 @@ struct qcedev_pmem_info {
|
|||
};
|
||||
|
||||
/**
|
||||
* struct qcedev_cipher_op_req - Holds the ciphering request information
|
||||
* @use_pmem (IN): Flag to indicate if buffer source is PMEM
|
||||
* QCEDEV_USE_PMEM/QCEDEV_NO_PMEM
|
||||
* @pmem (IN): Stores PMEM buffer information.
|
||||
* Refer struct qcedev_pmem_info
|
||||
* @vbuf (IN/OUT): Stores Source and destination Buffer information
|
||||
* Refer to struct qcedev_vbuf_info
|
||||
* @data_len (IN): Total Length of input/src and output/dst in bytes
|
||||
* @in_place_op (IN): Indicates whether the operation is inplace where
|
||||
* source == destination
|
||||
* When using PMEM allocated memory, must set this to 1
|
||||
* @enckey (IN): 128 bits of confidentiality key
|
||||
* enckey[0] bit 127-120, enckey[1] bit 119-112,..
|
||||
* enckey[15] bit 7-0
|
||||
* @encklen (IN): Length of the encryption key(set to 128 bits/16
|
||||
* bytes in the driver)
|
||||
* @iv (IN/OUT): Initialisation vector data
|
||||
* This is updated by the driver, incremented by
|
||||
* number of blocks encrypted/decrypted.
|
||||
* @ivlen (IN): Length of the IV
|
||||
* @byteoffset (IN): Offset in the Cipher BLOCK (applicable and to be set
|
||||
* for AES-128 CTR mode only)
|
||||
* @alg (IN): Type of ciphering algorithm: AES/DES/3DES
|
||||
* @mode (IN): Mode use when using AES algorithm: ECB/CBC/CTR
|
||||
* Apllicabel when using AES algorithm only
|
||||
* @op (IN): Type of operation: QCEDEV_OPER_DEC/QCEDEV_OPER_ENC or
|
||||
* QCEDEV_OPER_ENC_NO_KEY/QCEDEV_OPER_DEC_NO_KEY
|
||||
*
|
||||
*If use_pmem is set to 0, the driver assumes that memory was not allocated
|
||||
* via PMEM, and kernel will need to allocate memory and copy data from user
|
||||
* space buffer (data_src/dta_dst) and process accordingly and copy data back
|
||||
* to the user space buffer
|
||||
*
|
||||
* If use_pmem is set to 1, the driver assumes that memory was allocated via
|
||||
* PMEM.
|
||||
* The kernel driver will use the fd_src to determine the kernel virtual address
|
||||
* base that maps to the user space virtual address base for the buffer
|
||||
* allocated in user space.
|
||||
* The final input/src and output/dst buffer pointer will be determined
|
||||
* by adding the offsets to the kernel virtual addr.
|
||||
*
|
||||
* If use of hardware key is supported in the target, user can configure the
|
||||
* key parameters (encklen, enckey) to use the hardware key.
|
||||
* In order to use the hardware key, set encklen to 0 and set the enckey
|
||||
* data array to 0.
|
||||
*/
|
||||
* struct qcedev_cipher_op_req - Holds the ciphering request information
|
||||
* @use_pmem (IN): Flag to indicate if buffer source is PMEM
|
||||
* QCEDEV_USE_PMEM/QCEDEV_NO_PMEM
|
||||
* @pmem (IN): Stores PMEM buffer information.
|
||||
* Refer struct qcedev_pmem_info
|
||||
* @vbuf (IN/OUT): Stores Source and destination Buffer information
|
||||
* Refer to struct qcedev_vbuf_info
|
||||
* @data_len (IN): Total Length of input/src and output/dst in bytes
|
||||
* @in_place_op (IN): Indicates whether the operation is inplace where
|
||||
* source == destination
|
||||
* When using PMEM allocated memory, must set this to 1
|
||||
* @enckey (IN): 128 bits of confidentiality key
|
||||
* enckey[0] bit 127-120, enckey[1] bit 119-112,..
|
||||
* enckey[15] bit 7-0
|
||||
* @encklen (IN): Length of the encryption key(set to 128 bits/16
|
||||
* bytes in the driver)
|
||||
* @iv (IN/OUT): Initialisation vector data
|
||||
* This is updated by the driver, incremented by
|
||||
* number of blocks encrypted/decrypted.
|
||||
* @ivlen (IN): Length of the IV
|
||||
* @byteoffset (IN): Offset in the Cipher BLOCK (applicable and to be set
|
||||
* for AES-128 CTR mode only)
|
||||
* @alg (IN): Type of ciphering algorithm: AES/DES/3DES
|
||||
* @mode (IN): Mode use when using AES algorithm: ECB/CBC/CTR
|
||||
* Apllicabel when using AES algorithm only
|
||||
* @op (IN): Type of operation: QCEDEV_OPER_DEC/QCEDEV_OPER_ENC or
|
||||
* QCEDEV_OPER_ENC_NO_KEY/QCEDEV_OPER_DEC_NO_KEY
|
||||
*
|
||||
*If use_pmem is set to 0, the driver assumes that memory was not allocated
|
||||
* via PMEM, and kernel will need to allocate memory and copy data from user
|
||||
* space buffer (data_src/dta_dst) and process accordingly and copy data back
|
||||
* to the user space buffer
|
||||
*
|
||||
* If use_pmem is set to 1, the driver assumes that memory was allocated via
|
||||
* PMEM.
|
||||
* The kernel driver will use the fd_src to determine the kernel virtual address
|
||||
* base that maps to the user space virtual address base for the buffer
|
||||
* allocated in user space.
|
||||
* The final input/src and output/dst buffer pointer will be determined
|
||||
* by adding the offsets to the kernel virtual addr.
|
||||
*
|
||||
* If use of hardware key is supported in the target, user can configure the
|
||||
* key parameters (encklen, enckey) to use the hardware key.
|
||||
* In order to use the hardware key, set encklen to 0 and set the enckey
|
||||
* data array to 0.
|
||||
*/
|
||||
struct qcedev_cipher_op_req {
|
||||
uint8_t use_pmem;
|
||||
union {
|
||||
|
|
@ -197,16 +197,16 @@ struct qcedev_cipher_op_req {
|
|||
};
|
||||
|
||||
/**
|
||||
* struct qcedev_sha_op_req - Holds the hashing request information
|
||||
* @data (IN): Array of pointers to the data to be hashed
|
||||
* @entries (IN): Number of buf_info entries in the data array
|
||||
* @data_len (IN): Length of data to be hashed
|
||||
* @digest (IN/OUT): Returns the hashed data information
|
||||
* @diglen (OUT): Size of the hashed/digest data
|
||||
* @authkey (IN): Pointer to authentication key for HMAC
|
||||
* @authklen (IN): Size of the authentication key
|
||||
* @alg (IN): Secure Hash algorithm
|
||||
*/
|
||||
* struct qcedev_sha_op_req - Holds the hashing request information
|
||||
* @data (IN): Array of pointers to the data to be hashed
|
||||
* @entries (IN): Number of buf_info entries in the data array
|
||||
* @data_len (IN): Length of data to be hashed
|
||||
* @digest (IN/OUT): Returns the hashed data information
|
||||
* @diglen (OUT): Size of the hashed/digest data
|
||||
* @authkey (IN): Pointer to authentication key for HMAC
|
||||
* @authklen (IN): Size of the authentication key
|
||||
* @alg (IN): Secure Hash algorithm
|
||||
*/
|
||||
struct qcedev_sha_op_req {
|
||||
struct buf_info data[QCEDEV_MAX_BUFFERS];
|
||||
uint32_t entries;
|
||||
|
|
@ -219,20 +219,16 @@ struct qcedev_sha_op_req {
|
|||
};
|
||||
|
||||
/**
|
||||
* struct qfips_verify_t - Holds data for FIPS Integrity test
|
||||
* @kernel_size (IN): Size of kernel Image
|
||||
* @kernel (IN): pointer to buffer containing the kernel Image
|
||||
*/
|
||||
* struct qfips_verify_t - Holds data for FIPS Integrity test
|
||||
* @kernel_size (IN): Size of kernel Image
|
||||
* @kernel (IN): pointer to buffer containing the kernel Image
|
||||
*/
|
||||
struct qfips_verify_t {
|
||||
unsigned int kernel_size;
|
||||
void *kernel;
|
||||
};
|
||||
|
||||
struct file;
|
||||
/* temporiraly comment out for msm-4.9 headfile upgrade */
|
||||
/* extern long qcedev_ioctl(struct file *file,
|
||||
* unsigned int cmd, unsigned long arg);
|
||||
*/
|
||||
|
||||
#define QCEDEV_IOC_MAGIC 0x87
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue