/* ipfreescale.h - implementation of hardware cryptographic support for Freescale SEC 2 processor * */ /* ****************************************************************************** * INTERPEAK API HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipfreescale.h,v $ $Revision: 1.23.28.1 $ * $Source: /home/interpeak/CVSRoot/ipfreescale/include/ipfreescale.h,v $ * $Author: svc-cmnet $ $Date: 2013-03-13 07:45:24 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Markus Carlstedt ****************************************************************************** */ #ifndef IPFREESCALE_H #define IPFREESCALE_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* * DESCRIPTION * This library provides an implementation of a cryptographic engine for the * Freescale SEC 2 and SEC 4 processor, * for use with Wind River Cryptography Libraries. */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipfreescale_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #include #include #include #if defined (IPFREESCALE_SEC4) && defined (IPCOM_USE_FORWARDER_IPSEC) #include #endif #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ /* Some functions take options to further control its operation */ /* General options */ #define IPFREESCALE_OPT_NONE (0) /* No options, use default behaviour */ #define IPFREESCALE_OPT_INPUTDATA_IS_SGT (1 << 0) /* Input data is a scatter gather table * Associated length is length of actual data */ #define IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT (1 << 1) /* Input data is a HW specific scatter gather table * Associated length is length of actual data */ #define IPFREESCALE_OPT_OUTPUTDATA_IS_SGT (1 << 2) /* Output data is a scatter gather table * Associated length is length of actual data */ #define IPFREESCALE_OPT_OUTPUTDATA_IS_HW_SGT (1 << 3) /* Output data is a HW specific scatter gather table * Associated length is length of actual data */ /* CRC checksum generation options */ #define IPFREESCALE_OPT_CRC_IEEE802 (1 << 16) /* Do bit and byte swapping and complement according to IEEE 802 */ #define IPFREESCALE_OPT_CRC_IETF3385 (1 << 17) /* Do bit and byte swapping and complement according to IETF 3385 */ #define IPFREESCALE_OPT_CRC_DIS (1 << 18) /* Don't swap input data bits */ #define IPFREESCALE_OPT_CRC_DOS (1 << 19) /* Don't swap output data bits */ #define IPFREESCALE_OPT_CRC_DOC (1 << 20) /* Don't complement output data */ /* AES CCM options */ #define IPFREESCALE_OPT_AESCCM_ICV (1 << 16) /* Do integrity check verification during decrypt */ /* CRC checksum generation defines */ #define IPFREESCALE_CRC32_POLY_IEEE802 (0x04c11db7) /* Polynomial according to IEEE 802 */ #define IPFREESCALE_CRC32_POLY_IETF3385 (0x1EDC6F41) /* Polynomial according to IETF 3385 */ #define IPFREESCALE_CRC_INCTX_DFLT (0xFFFFFFFF) /* *=========================================================================== * IPFREESCALE_RELEASE *=========================================================================== * IPFREESCALE release version. */ #define IPFREESCALE_RELEASE 60600 /* **************************************************************************** * 5 TYPES **************************************************************************** */ /* * A scatter gather table is an array of Ipfreescale_sgt_entry. It may be used * for some funtions to provide scattered input data. * The last entry must have the final field set. * */ IP_PUBLIC typedef struct { void *addr; /* Address of buffer holding the data */ Ip_u16 offset; /* Offset in bytes to valid data */ Ip_u16 length; /* Length of valid data in bytes */ Ip_bool final; /* IP_TRUE if this is the last entry in the table */ } Ipfreescale_sgt_entry; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ /******************************************************************************* * * ipfreescale_async_done_cbf_register - Register async job done call back routine * * This routine registers the call back routine for successfull completed non-IPsec * asynchronous jobs. It must be called before submitting an asynchronous job. * The call back routine need o have a (void *) handle as input parameter to * identify the completed job. * * Parameters: * \is * \i * Pointer to call back function. * \ie * * RETURNS: 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_async_done_cbf_register ( void (*cbf)(void *) ); /******************************************************************************* * * ipfreescale_async_error_cbf_register - Register async job error call back routine * * This routine registers the call back routine for completed non-IPsec asynchronous * jobs with errors. It must be called before submitting an asynchronous job. * The call back routine need o have a (void *) handle to identify the completed job * and an (int) status as input parameters. * * Parameters: * \is * \i * Pointer to call back function. * \ie * * RETURNS: 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_async_error_cbf_register ( void (*cbf)(void *, int) ); /* MD5 digest functions */ /******************************************************************************* * * ipfreescale_md5_digest - Calculate message digest using the MD5 algorithm. * * This routine calculates a message digest using the MD5 algorithm. * * Parameters: * \is * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * * \i * Pointer to buffer for the digest (16 bytes). * \ie * * RETURNS: -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_md5_digest ( Ip_u8 *data, Ip_u32 length, Ip_u8 *digest ); /******************************************************************************* * * ipfreescale_md5_hmac - Calculate HMAC using the MD5 algorithm. * * This routine calculates a HMAC using the MD5 algorithm. * * Parameters: * \is * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key. * * \i * Length of key in bytes. * * \i * Pointer to buffer for the hmac (16 bytes). * \ie * * RETURNS: -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_md5_hmac ( Ip_u8 *data, Ip_u32 length, Ip_u8 *key, Ip_u32 keylength, Ip_u8 *hmac ); /******************************************************************************* * * ipfreescale_md5_digest_init - initialize MD5 message digest context * * This routine initializes an MD5 message context. * * Parameters: * \is * \i * Pointer to the context. * \ie * * RETURNS: 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_md5_digest_init ( void *ctx ); /******************************************************************************* * * ipfreescale_md5_digest_update - update MD5 message digest context * * This routine updates an MD5 message context. * * Parameters: * \is * \i * Pointer to the context. * * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * \ie * * RETURNS: -1 = error, 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_md5_digest_update ( void *ctx, IP_CONST Ip_u8 *data, Ip_u32 length ); /******************************************************************************* * * ipfreescale_md5_digest_final - finalize MD5 message digest context * * This routine finalizes an MD5 message digest context. * * Parameters: * \is * \i * Pointer to the context. * * \i * Pointer to buffer for the digest (16 bytes). * \ie * * RETURNS: -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_md5_digest_final ( void *ctx, Ip_u8 *digest ); /* SHA1 digest functions */ /******************************************************************************* * * ipfreescale_sha1_digest - calculate message digest using the SHA1 algorithm * * This routine calculates a message digest using the SHA1 algorithm. * * Parameters: * \is * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * * \i * Pointer to buffer for the digest (20 bytes). * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_sha1_digest ( Ip_u8 *data, Ip_u32 length, Ip_u8 *digest ); /******************************************************************************* * * ipfreescale_sha1_hmac - Calculate HMAC using the SHA1 algorithm. * * This routine calculates a HMAC using the SHA1 algorithm. * * Parameters: * \is * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key. * * \i * Length of key in bytes. * * \i * Pointer to buffer for the hmac (20 bytes). * \ie * * RETURNS: -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_sha1_hmac ( Ip_u8 *data, Ip_u32 length, Ip_u8 *key, Ip_u32 keylength, Ip_u8 *hmac ); /******************************************************************************* * * ipfreescale_sha1_digest_init - initialize SHA1 message digest context * * This routine initializes a SHA1 message digest context. * * Parameters: * \is * \i * Pointer to the context. * \ie * * RETURNS: * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_sha1_digest_init ( void *ctx ); /******************************************************************************* * * ipfreescale_sha1_digest_update - update SHA1 message digest context * * This routine updates a SHA1 message digest context. * * Parameters: * \is * \i * Pointer to the context. * * \i * Pointer to buffer with the data to hash. * * \i * Length of data in bytes. * \ie * * RETURNS: * -1 = error, 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_sha1_digest_update ( void *ctx, IP_CONST Ip_u8 *data, Ip_u32 length ); /******************************************************************************* * * ipfreescale_sha1_digest_final - Finalize SHA1 message digest context * * This routine finalizes a SHA1 message digest context. * * Parameters: * \is * \i * Pointer to the context. * * \i * Pointer to buffer for the digest (20 bytes). * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_sha1_digest_final ( void *ctx, Ip_u8 *digest ); /******************************************************************************* * * ipfreescale_digest_copy - copy message digest context * * This routine copies a message digest context. * * Parameters: * \is * \i * Pointer to the destination context. * * \i * Pointer to the source context. * \ie * * RETURNS: * -1 = error, 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_digest_copy ( void *ctx_to, IP_CONST void *ctx_from ); /******************************************************************************* * * ipfreescale_digest_cleanup - clean up message digest context * * This routine cleans up a message digest context. * * Parameters: * \is * \i * Pointer to the context. * \ie * * RETURNS: * 1= ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_digest_cleanup ( void *ctx ); /******************************************************************************* * * ipfreescale_des_cbc_cipher - encrypt or decrypt using DES-CBC cipher * * This routine encrypts or decrypts a data buffer using the DES-CBC cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (8 bytes). * * \i * Initialization vector (8 bytes). Updated by hardware. * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_des_cbc_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc ); /******************************************************************************* * * ipfreescale_des_ecb_cipher - encrypt or decrypt using DES-ECB cipher * * This routine encrypts or decrypts a data buffer using the DES-ECB cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (8 bytes). * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_des_ecb_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc ); /******************************************************************************* * * ipfreescale_3des_cbc_cipher - encrypt or decrypt using 3DES-CBC cipher * * This routine encrypts or decrypts a data buffer using the 3DES-CBC cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (24 bytes). * * \i * Initialization vector (8 bytes). Updated by hardware. * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_3des_cbc_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc ); /******************************************************************************* * * ipfreescale_3des_ecb_cipher - encrypt or decrypt using 3DES-ECB cipher * * This routine encrypts or decrypts a data buffer using the 3DES-ECB cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (24 bytes). * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_3des_ecb_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc ); /******************************************************************************* * * ipfreescale_aes128_cbc_cipher - encrypt or decrypt using the AES-CBC-128 cipher * * This routine encrypts or decrypts a data buffer using the AES-CBC-128 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (16 bytes). * * \i * Initialization vector (16 bytes). Updated by hardware. * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes128_cbc_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc ); /******************************************************************************* * * ipfreescale_aes128_ecb_cipher - encrypt or decrypt using the AES-ECB-128 cipher * * This routine encrypts or decrypts a data buffer using the AES-ECB-128 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (16 bytes). * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes128_ecb_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc ); /******************************************************************************* * * ipfreescale_aes192_cbc_cipher - encrypt or decrypt using the AES-CBC-192 cipher * * This routine encrypts or decrypts a data buffer using the AES-CBC-192 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (24 bytes). * * \i * Initialization vector (24 bytes). Updated by hardware. * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes192_cbc_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc ); /******************************************************************************* * * ipfreescale_aes192_ecb_cipher - encrypt or decrypt using the AES-ECB-192 cipher * * This routine encrypts or decrypts a data buffer using the AES-ECB-192 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (24 bytes). * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes192_ecb_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc ); /******************************************************************************* * * ipfreescale_aes256_cbc_cipher - encrypt or decrypt using the AES-CBC-256 cipher * * This routine encrypts or decrypts a data buffer using the AES-CBC-256 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (32 bytes). * * \i * Initialization vector (32 bytes). Updated by hardware. * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes256_cbc_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u8 *iv, int enc ); /******************************************************************************* * * ipfreescale_aes256_ecb_cipher - encrypt or decrypt using the AES-ECB-256 cipher * * This routine encrypts or decrypts a data buffer using the AES-ECB-256 cipher. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key (32 bytes). * * \i * 1 = encryption. 0 = decryption. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_aes256_ecb_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, int enc ); /******************************************************************************* * * ipfreescale_rc4_cipher - RC4 stream cipher * * This routine performs an RC4 stream cipher. * Provide key and output context for operation with key load and context save. * Provide input context and output context for operation with context load and context save. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt/decrypt. * * \i * Length of data in bytes. * * \i * Pointer to buffer with the key. * * \i * Length of encryption key (1-16 bytes). * * \i * Buffer with input context (259 bytes). * * \i * Buffer with output context (259 bytes). * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_rc4_cipher ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, void *key, Ip_u32 keylen, Ip_u8 *ctxi, Ip_u8 *ctxo ); /******************************************************************************* * * ipfreescale_mod_exp - modular exponentiation * * This routine performs modular exponentiation. Calculates b^e mod m. The size of * the base and exponent buffers are assumed to be of equal size as the modulus * length and zero padded with leading zeros if necessary. The size of the result buffer * is also equal to the modulus length and the result will be zero padded if necessary. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the base. * * \i * Pointer to buffer with the exponent. * * \i * Pointer to buffer with the result. * * \i * Length of modulus. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_mod_exp ( Ip_u8 *out, IP_CONST Ip_u8 *base, IP_CONST Ip_u8 *e, IP_CONST Ip_u8 *mod, Ip_u32 modlen ); /******************************************************************************* * * ipfreescale_random_gen - generate sequence of random data * * This routine generates a sequence of random data. * * Parameters: * \is * \i * Pointer to buffer for the generated random data. * * \i * Number of bytes in the sequence. * \ie * * RETURNS: -1 = error, * 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_random_gen ( Ip_u8 *data, Ip_u32 length ); /******************************************************************************* * * ipfreescale_ccmp_encrypt - Counter mode with Cipher Block chaining * * This routine performs CCMP encryption. (AES-CCM according to IEEE802.11) * Provide key and output context for operation with key load and context save. * Provide input context for operation with context load. * * Parameters: * \is * \i * Pointer to the result. * * \i * Pointer to buffer with the data to encrypt. * * \i * Length of data in bytes. * * \i * Pointer to Message Integrity Code * * \i * Pointer to Additional Authentication Data * * \i * Additional Authentication Data Length * * \i * Pointer to buffer with the key. * * \i * Length of encryption key. * * \i * Buffer with input context. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok * * ERRNO * \&N/A * */ IP_GLOBAL int ipfreescale_ccmp_encrypt ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, Ip_u8 *mic, IP_CONST Ip_u8 *aad, Ip_u32 aadlen, void *key, Ip_u32 keylen, Ip_u8 *ctxi ); /******************************************************************************* * * ipfreescale_aesccm - AES Counter mode with Cipher Block chaining * * This routine performs AES - CCM encryption or decryption with associated * generation or verification of authenticity. * Provide key and output context for operation with key load and context save. * Provide input context for operation with context load. * Failed integrity check during decrypt will optionally generate an error. * * Parameters: * \is * \i * Pointer to the buffer or scatter gather table (if options IPFREESCALE_OPT_OUTPUTDATA_IS_SGT or * IPFREESCALE_OPT_OUTPUTDATA_IS_HW_SGT are set) for output data. * * \i * Pointer to buffer or scatter gather table (if options IPFREESCALE_OPT_INPUTDATA_IS_SGT or * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT are set) with the input data to process. * * \i * Length of in data in bytes. * * \i * Pointer to output Message Integrity Code * * \i * Pointer to input Message Integrity Code * * \i * Length in bytes of Message Integrity Code * * \i * Pointer to Additional Authentication Data * Set to IP_NULL if there isn't any AAD. * * \i * Additional Authentication Data Length * Set to 0 if there isn't any AAD * * \i * Pointer to buffer with the key. * * \i * Length in bytes of encryption key. * * \i * Buffer with input context. * * \i * 1 for encrypt, 0 for decrypt. * * \i * IP_TRUE for asynchronous operation, IP_FALSE for synchronous operation * * \i * Handle to identify the job in case of asynchronous job. Should be set to IP_NULL * for synchronous jobs. * * \i * Ored bit options to control AES CCM. * Valid options: IPFREESCALE_OPT_NONE * IPFREESCALE_OPT_AESCCM_ICV * IPFREESCALE_OPT_INPUTDATA_IS_SGT * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT * IPFREESCALE_OPT_OUTPUTDATA_IS_SGT * IPFREESCALE_OPT_OUTPUTDATA_IS_HW_SGT * \ie * * RETURNS: * -1 = error, * 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_GLOBAL int ipfreescale_aesccm ( Ip_u8 *out, IP_CONST Ip_u8 *in, Ip_u32 length, Ip_u8 *micout, Ip_u8 *micin, Ip_u32 miclen, IP_CONST Ip_u8 *aad, Ip_u32 aadlen, void *key, Ip_u32 keylen, Ip_u8 *ctxi, int enc, Ip_bool async, void * asynchandle, Ip_u32 options); /******************************************************************************* * * ipfreescale_crc - calculate the CRC checksum on data * * This routine generates CRC checksum on supplied data. * * Parameters: * \is * \i * CRC polynomial. E.g. for IEEE802: IPFREESCALE_CRC32_POLY_IEEE802 * * \i * Pointer to buffer for data to generate CRC checksum from. Or pointer to * scatter gather table if options IPFREESCALE_OPT_INPUTDATA_IS_SGT or * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT are set. * * \i * Number of bytes in the sequence. If indata is a SGT, total length of valid data. * * \i * Input context data (initial CRC value). * * \i * IP_TRUE for asynchronous operation, IP_FALSE for synchronous operation * * \i * Handle to identify the job in case of asynchronous job. Should be set to IP_NULL * for synchronous jobs. * * \i * Ored bit options to control CRC generation. * Valid options: IPFREESCALE_OPT_NONE * IPFREESCALE_OPT_INPUTDATA_IS_SGT * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT * IPFREESCALE_OPT_CRC_IEEE802 * IPFREESCALE_OPT_CRC_IETF3385 * IPFREESCALE_OPT_CRC_DIS * IPFREESCALE_OPT_CRC_DOS * IPFREESCALE_OPT_CRC_DOC * \ie * * \os * \o * Pointer to where to store the calculated CRC. * \oe * * RETURNS: -1 = error, * 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_crc ( IP_CONST Ip_u8 *indata, Ip_u32 length, Ip_u8 *crc, Ip_u32 polynomial, Ip_u32 inctx, Ip_bool async, void * asynchandle, Ip_u32 options ); /******************************************************************************* * * ipfreescale_dma - DMA copy data using freescale engine * * This routine copies data using the freescale engine. * * Parameters: * \is * \i * Pointer to buffer for data to be copied. Or pointer to * scatter gather table if options IPFREESCALE_OPT_INPUTDATA_IS_SGT or * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT are set. * * \i * Number of bytes in the sequence. If indata is a SGT, this is the total length * of valid data. * * \i * IP_TRUE for asynchronous operation, IP_FALSE for synchronous operation * * \i * Handle to identify the job in case of asynchronous job. Should be set to IP_NULL * for synchronous jobs. * * \i * Ored bit options to control CRC generation. * Valid options: IPFREESCALE_OPT_NONE * IPFREESCALE_OPT_INPUTDATA_IS_SGT * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT * IPFREESCALE_OPT_OUTPUTDATA_IS_SGT * IPFREESCALE_OPT_OUTPUTDATA_IS_HW_SGT * \ie * * \os * \o * Pointer to where to copy the data. Or pointer to scatter gather table if * options IPFREESCALE_OPT_OUTPUTDATA_IS_SGT or * IPFREESCALE_OPT_INPUTDATA_IS_HW_SGT are set. * \oe * * RETURNS: -1 = error, * 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_dma ( IP_CONST Ip_u8 *indata, Ip_u32 length, Ip_u8 *outdata, Ip_bool async, void * asynchandle, Ip_u32 options ); /* IPSEC ESP functions */ #ifdef IPIPSEC2 IP_PUBLIC int ipfreescale_ipsec_esp_null_md5_input(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_null_md5_output(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_null_sha1_input(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_null_sha1_output(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_null_input(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_null_output(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); #if defined (IPFREESCALE_SEC4) && defined (IPCOM_USE_FORWARDER_IPSEC) IP_PUBLIC int ipfreescale_ipsec_populate_sa(Ipcom_fw_ipsec_sa_t *sa, Ip_u16 sa_index, int enc); IP_PUBLIC int ipfreescale_ipsec_esp_encrypt(Ip_u16 sa_index, Ip_u32 seq_no, Ip_u8 *iv, Ip_u8 *p, Ip_u16 inOffset, Ip_u16 pktlen, Ip_u16 outOffset, Ip_u8 poolId); IP_PUBLIC int ipfreescale_ipsec_esp_decrypt(Ip_u16 sa_index, Ip_u8 *p, Ip_u16 inOffset, Ip_u16 pktlen, Ip_u16 outOffset, Ip_u8 poolId); IP_PUBLIC void ipfreescale_ipsec_set_enqueue_resource(void *resource); IP_PUBLIC void ipfreescale_ipsec_set_buffer_resource(void *resource, Ip_u32 poolId); IP_PUBLIC void ipfreescale_ipsec_set_enqueue_ix_base(Ip_u32 ixBase); IP_PUBLIC void ipfreescale_ipsec_set_dequeue_ix(Ip_u32 ixBaseEncrypt, Ip_u32 ixBaseDecrypt); #endif /* defined (IPFREESCALE_SEC4) && defined (IPCOM_USE_FORWARDER_IPSEC) */ /******************************************************************************* * * ipfreescale_ipsec_esp_des_cbc_md5_input - IPsec ESP input processing using DES-CBC-MD5 * * This routine performs IPsec ESP input processing using DES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_md5_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_md5_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_des_cbc_md5_output - IPsec ESP output processing using DES-CBC-MD5 * * This routine performs IPsec ESP output processing using DES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_md5_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_md5_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_des_cbc_sha1_input - IPsec ESP input processing using DES-CBC-SHA1 * * This routine performs input processing using DES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_sha1_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_sha1_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_des_cbc_sha1_output - IPsec ESP output processing using DES-CBC-SHA1 * * This routine performs IPsec ESP output processing using DES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2= kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_sha1_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_des_cbc_sha1_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_null_input(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_null_output(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); /******************************************************************************* * * ipfreescale_ipsec_esp_3des_cbc_md5_input - IPsec ESP input processing using 3DES-CBC-MD5 * * This routine performs IPsec ESP input processing using 3DES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_md5_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_md5_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_3des_cbc_md5_output - IPsec ESP output processing using 3DES-CBC-MD5 * * This routine performs IPsec ESP output processing using 3DES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_md5_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_md5_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_3des_cbc_sha1_input - IPsec ESP input processing using 3DES-CBC-SHA1 * * This routine performs IPsec ESP input processing using 3DES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_sha1_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_sha1_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_3des_cbc_sha1_output - IPsec ESP output processing using 3DES-CBC-SHA1 * * This routine performs IPsec ESP output processing using 3DES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_sha1_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_3des_cbc_sha1_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_null_input(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_null_output(Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt); /******************************************************************************* * * ipfreescale_ipsec_esp_aes_cbc_md5_input - IPsec ESP input processing using AES-CBC-MD5 * * This routine performs IPsec ESP input processing using AES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_md5_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_md5_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_aes_cbc_md5_output - IPsec ESP output processing using AES-CBC-MD5 * * This routine performs IPsec ESP output processing using AES-CBC-MD5. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_md5_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_md5_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_aes_cbc_sha1_input - IPsec ESP input processing using AES-CBC-SHA1 * * This routine performs IPsec ESP input processing using AES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_sha1_input ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_sha1_input_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); /******************************************************************************* * * ipfreescale_ipsec_esp_aes_cbc_sha1_output - IPsec ESP output processing using AES-CBC-SHA1 * * This routine performs IPsec ESP output processing using AES-CBC-SHA1. * * Parameters: * \is * \i * Pointer to the packet data. * * \i * Length of the packet. * * \i * Pointer to the sa (Security Association). * * \i * Pointer to the message authentication code. * * \i * Pointer to IPsec Parameters * * \i * Pointer to the packet structure. * \ie * * RETURNS: * -1 = error, 0 = timeout, * 1 = ok, * 2 = kept * * ERRNO * \&N/A * */ IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_sha1_output ( Ip_u8 *data, Ip_u32 length, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); IP_PUBLIC int ipfreescale_ipsec_esp_aes_cbc_sha1_output_relocate ( Ip_u8 *data, Ip_u32 length, Ip_u8 *outdata, Iphwcrypto_esp_cbc_sa *sa, Ip_u8 *digest, Ipipsec_param *param, Ipcom_pkt *pkt ); #endif /* #ifdef IPIPSEC2 */ #ifdef __cplusplus } #endif #endif /* **************************************************************************** * END OF FILE **************************************************************************** */