|
@@ -38,9 +38,6 @@
|
|
|
cds_crypto_init() - Initializes Crypto module
|
|
|
cds_crypto_deinit() - De-initializes Crypto module
|
|
|
cds_rand_get_bytes() - Generates random byte
|
|
|
- cds_sha1_hmac_str() - Generate the HMAC-SHA1 of a string given a key
|
|
|
- cds_encrypt_aes() - Generate AES Encrypted byte stream
|
|
|
- cds_decrypt_aes() - Decrypts an AES Encrypted byte stream
|
|
|
|
|
|
DEPENDENCIES:
|
|
|
============================================================================*/
|
|
@@ -568,532 +565,6 @@ err_tfm:
|
|
|
}
|
|
|
|
|
|
#endif /* WLAN_FEATURE_11W */
|
|
|
-/**
|
|
|
- * cds_sha1_hmac_str
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * Generate the HMAC-SHA1 of a string given a key.
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- * Standard HMAC processing from RFC 2104. The code is provided in the
|
|
|
- * appendix of the RFC.
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * The RFC is correct.
|
|
|
- *
|
|
|
- * @param text text to be hashed
|
|
|
- * @param textLen length of text
|
|
|
- * @param key key to use for HMAC
|
|
|
- * @param keyLen length of key
|
|
|
- * @param digest holds resultant SHA1 HMAC (20B)
|
|
|
- *
|
|
|
- * @return QDF_STATUS_SUCCSS if the operation succeeds
|
|
|
- *
|
|
|
- */
|
|
|
-
|
|
|
-struct hmac_sha1_result {
|
|
|
- struct completion completion;
|
|
|
- int err;
|
|
|
-};
|
|
|
-
|
|
|
-static void hmac_sha1_complete(struct crypto_async_request *req, int err)
|
|
|
-{
|
|
|
- struct hmac_sha1_result *r = req->data;
|
|
|
- if (err == -EINPROGRESS)
|
|
|
- return;
|
|
|
- r->err = err;
|
|
|
- complete(&r->completion);
|
|
|
-}
|
|
|
-
|
|
|
-static int
|
|
|
-hmac_sha1(uint8_t *key, uint8_t ksize, char *plaintext, uint8_t psize,
|
|
|
- uint8_t *output, uint8_t outlen)
|
|
|
-{
|
|
|
- int ret = 0;
|
|
|
- struct crypto_ahash *tfm;
|
|
|
- struct scatterlist sg;
|
|
|
- struct ahash_request *req;
|
|
|
- struct hmac_sha1_result tresult;
|
|
|
- void *hash_buff = NULL;
|
|
|
-
|
|
|
- unsigned char hash_result[64];
|
|
|
- int i;
|
|
|
-
|
|
|
- memset(output, 0, outlen);
|
|
|
-
|
|
|
- init_completion(&tresult.completion);
|
|
|
-
|
|
|
- tfm = cds_crypto_alloc_ahash("hmac(sha1)", CRYPTO_ALG_TYPE_AHASH,
|
|
|
- CRYPTO_ALG_TYPE_AHASH_MASK);
|
|
|
- if (IS_ERR(tfm)) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_alloc_ahash failed");
|
|
|
- ret = PTR_ERR(tfm);
|
|
|
- goto err_tfm;
|
|
|
- }
|
|
|
-
|
|
|
- req = ahash_request_alloc(tfm, GFP_KERNEL);
|
|
|
- if (!req) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "failed to allocate request for hmac(sha1)");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_req;
|
|
|
- }
|
|
|
-
|
|
|
- ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
|
|
|
- hmac_sha1_complete, &tresult);
|
|
|
-
|
|
|
- hash_buff = kzalloc(psize, GFP_KERNEL);
|
|
|
- if (!hash_buff) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "failed to kzalloc hash_buff");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_hash_buf;
|
|
|
- }
|
|
|
-
|
|
|
- memset(hash_result, 0, 64);
|
|
|
- memcpy(hash_buff, plaintext, psize);
|
|
|
- sg_init_one(&sg, hash_buff, psize);
|
|
|
-
|
|
|
- if (ksize) {
|
|
|
- crypto_ahash_clear_flags(tfm, ~0);
|
|
|
- ret = cds_crypto_ahash_setkey(tfm, key, ksize);
|
|
|
- if (ret) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_ahash_setkey failed");
|
|
|
- goto err_setkey;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ahash_request_set_crypt(req, &sg, hash_result, psize);
|
|
|
- ret = cds_crypto_ahash_digest(req);
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, "ret 0x%x", ret);
|
|
|
-
|
|
|
- switch (ret) {
|
|
|
- case 0:
|
|
|
- for (i = 0; i < outlen; i++)
|
|
|
- output[i] = hash_result[i];
|
|
|
- break;
|
|
|
- case -EINPROGRESS:
|
|
|
- case -EBUSY:
|
|
|
- ret = wait_for_completion_interruptible(&tresult.completion);
|
|
|
- if (!ret && !tresult.err) {
|
|
|
- for (i = 0; i < outlen; i++)
|
|
|
- output[i] = hash_result[i];
|
|
|
- INIT_COMPLETION(tresult.completion);
|
|
|
- break;
|
|
|
- } else {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "wait_for_completion_interruptible failed");
|
|
|
- if (!ret)
|
|
|
- ret = tresult.err;
|
|
|
- goto out;
|
|
|
- }
|
|
|
- default:
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
-out:
|
|
|
-err_setkey:
|
|
|
- kfree(hash_buff);
|
|
|
-err_hash_buf:
|
|
|
- ahash_request_free(req);
|
|
|
-err_req:
|
|
|
- cds_crypto_free_ahash(tfm);
|
|
|
-err_tfm:
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-QDF_STATUS cds_sha1_hmac_str(uint32_t cryptHandle, /* Handle */
|
|
|
- uint8_t *pText, /* pointer to data stream */
|
|
|
- uint32_t textLen, /* length of data stream */
|
|
|
- uint8_t *pKey, /* pointer to authentication key */
|
|
|
- uint32_t keyLen, /* length of authentication key */
|
|
|
- uint8_t digest[CDS_DIGEST_SHA1_SIZE])
|
|
|
-{ /* caller digest to be filled in */
|
|
|
- int ret = 0;
|
|
|
-
|
|
|
- ret = hmac_sha1(pKey, /* uint8_t *key, */
|
|
|
- (uint8_t) keyLen, /* uint8_t ksize, */
|
|
|
- (char *)pText, /* char *plaintext, */
|
|
|
- (uint8_t) textLen, /* uint8_t psize, */
|
|
|
- digest, /* uint8_t *output, */
|
|
|
- CDS_DIGEST_SHA1_SIZE /* uint8_t outlen */
|
|
|
- );
|
|
|
-
|
|
|
- if (ret != 0) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "hmac_sha1() call failed");
|
|
|
- return QDF_STATUS_E_FAULT;
|
|
|
- }
|
|
|
-
|
|
|
- return QDF_STATUS_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * cds_md5_hmac_str
|
|
|
- *
|
|
|
- * FUNCTION:
|
|
|
- * Generate the HMAC-MD5 of a string given a key.
|
|
|
- *
|
|
|
- * LOGIC:
|
|
|
- * Standard HMAC processing from RFC 2104. The code is provided in the
|
|
|
- * appendix of the RFC.
|
|
|
- *
|
|
|
- * ASSUMPTIONS:
|
|
|
- * The RFC is correct.
|
|
|
- *
|
|
|
- * @param text text to be hashed
|
|
|
- * @param textLen length of text
|
|
|
- * @param key key to use for HMAC
|
|
|
- * @param keyLen length of key
|
|
|
- * @param digest holds resultant MD5 HMAC (20B)
|
|
|
- *
|
|
|
- * @return QDF_STATUS_SUCCSS if the operation succeeds
|
|
|
- *
|
|
|
- */
|
|
|
-struct hmac_md5_result {
|
|
|
- struct completion completion;
|
|
|
- int err;
|
|
|
-};
|
|
|
-
|
|
|
-static void hmac_md5_complete(struct crypto_async_request *req, int err)
|
|
|
-{
|
|
|
- struct hmac_md5_result *r = req->data;
|
|
|
- if (err == -EINPROGRESS)
|
|
|
- return;
|
|
|
- r->err = err;
|
|
|
- complete(&r->completion);
|
|
|
-}
|
|
|
-
|
|
|
-static int
|
|
|
-hmac_md5(uint8_t *key, uint8_t ksize, char *plaintext, uint8_t psize,
|
|
|
- uint8_t *output, uint8_t outlen)
|
|
|
-{
|
|
|
- int ret = 0;
|
|
|
- struct crypto_ahash *tfm;
|
|
|
- struct scatterlist sg;
|
|
|
- struct ahash_request *req;
|
|
|
- struct hmac_md5_result tresult = {.err = 0 };
|
|
|
- void *hash_buff = NULL;
|
|
|
-
|
|
|
- unsigned char hash_result[64];
|
|
|
- int i;
|
|
|
-
|
|
|
- memset(output, 0, outlen);
|
|
|
-
|
|
|
- init_completion(&tresult.completion);
|
|
|
-
|
|
|
- tfm = cds_crypto_alloc_ahash("hmac(md5)", CRYPTO_ALG_TYPE_AHASH,
|
|
|
- CRYPTO_ALG_TYPE_AHASH_MASK);
|
|
|
- if (IS_ERR(tfm)) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_alloc_ahash failed");
|
|
|
- ret = PTR_ERR(tfm);
|
|
|
- goto err_tfm;
|
|
|
- }
|
|
|
-
|
|
|
- req = ahash_request_alloc(tfm, GFP_KERNEL);
|
|
|
- if (!req) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "failed to allocate request for hmac(md5)");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_req;
|
|
|
- }
|
|
|
-
|
|
|
- ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
|
|
|
- hmac_md5_complete, &tresult);
|
|
|
-
|
|
|
- hash_buff = kzalloc(psize, GFP_KERNEL);
|
|
|
- if (!hash_buff) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "failed to kzalloc hash_buff");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_hash_buf;
|
|
|
- }
|
|
|
-
|
|
|
- memset(hash_result, 0, 64);
|
|
|
- memcpy(hash_buff, plaintext, psize);
|
|
|
- sg_init_one(&sg, hash_buff, psize);
|
|
|
-
|
|
|
- if (ksize) {
|
|
|
- crypto_ahash_clear_flags(tfm, ~0);
|
|
|
- ret = cds_crypto_ahash_setkey(tfm, key, ksize);
|
|
|
- if (ret) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_ahash_setkey failed");
|
|
|
- goto err_setkey;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ahash_request_set_crypt(req, &sg, hash_result, psize);
|
|
|
- ret = cds_crypto_ahash_digest(req);
|
|
|
-
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, "ret 0x%x", ret);
|
|
|
-
|
|
|
- switch (ret) {
|
|
|
- case 0:
|
|
|
- for (i = 0; i < outlen; i++)
|
|
|
- output[i] = hash_result[i];
|
|
|
- break;
|
|
|
- case -EINPROGRESS:
|
|
|
- case -EBUSY:
|
|
|
- ret = wait_for_completion_interruptible(&tresult.completion);
|
|
|
- if (!ret && !tresult.err) {
|
|
|
- INIT_COMPLETION(tresult.completion);
|
|
|
- break;
|
|
|
- } else {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "wait_for_completion_interruptible failed");
|
|
|
- if (!ret)
|
|
|
- ret = tresult.err;
|
|
|
- goto out;
|
|
|
- }
|
|
|
- default:
|
|
|
- goto out;
|
|
|
- }
|
|
|
-
|
|
|
-out:
|
|
|
-err_setkey:
|
|
|
- kfree(hash_buff);
|
|
|
-err_hash_buf:
|
|
|
- ahash_request_free(req);
|
|
|
-err_req:
|
|
|
- cds_crypto_free_ahash(tfm);
|
|
|
-err_tfm:
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-QDF_STATUS cds_md5_hmac_str(uint32_t cryptHandle, /* Handle */
|
|
|
- uint8_t *pText, /* pointer to data stream */
|
|
|
- uint32_t textLen, /* length of data stream */
|
|
|
- uint8_t *pKey, /* pointer to authentication key */
|
|
|
- uint32_t keyLen, /* length of authentication key */
|
|
|
- uint8_t digest[CDS_DIGEST_MD5_SIZE])
|
|
|
-{ /* caller digest to be filled in */
|
|
|
- int ret = 0;
|
|
|
-
|
|
|
- ret = hmac_md5(pKey, /* uint8_t *key, */
|
|
|
- (uint8_t) keyLen, /* uint8_t ksize, */
|
|
|
- (char *)pText, /* char *plaintext, */
|
|
|
- (uint8_t) textLen, /* uint8_t psize, */
|
|
|
- digest, /* uint8_t *output, */
|
|
|
- CDS_DIGEST_MD5_SIZE /* uint8_t outlen */
|
|
|
- );
|
|
|
-
|
|
|
- if (ret != 0) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "hmac_md5() call failed");
|
|
|
- return QDF_STATUS_E_FAULT;
|
|
|
- }
|
|
|
-
|
|
|
- return QDF_STATUS_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-struct ecb_aes_result {
|
|
|
- struct completion completion;
|
|
|
- int err;
|
|
|
-};
|
|
|
-
|
|
|
-static void ecb_aes_complete(struct crypto_async_request *req, int err)
|
|
|
-{
|
|
|
- struct ecb_aes_result *r = req->data;
|
|
|
- if (err == -EINPROGRESS)
|
|
|
- return;
|
|
|
- r->err = err;
|
|
|
- complete(&r->completion);
|
|
|
-}
|
|
|
-
|
|
|
-/*--------------------------------------------------------------------------
|
|
|
-
|
|
|
- \brief cds_encrypt_aes() - Generate AES Encrypted byte stream
|
|
|
-
|
|
|
- The cds_encrypt_aes() function generates the encrypted byte stream for given text.
|
|
|
-
|
|
|
- Buffer should be allocated before calling cds_rand_get_bytes().
|
|
|
-
|
|
|
- Attempting to initialize an already initialized lock results in
|
|
|
- a failure.
|
|
|
-
|
|
|
- \param lock - pointer to the opaque lock object to initialize
|
|
|
-
|
|
|
- \return QDF_STATUS_SUCCESS - Successfully generated random memory.
|
|
|
-
|
|
|
- QDF_STATUS_E_FAULT - pbBuf is an invalid pointer.
|
|
|
-
|
|
|
- QDF_STATUS_E_FAILURE - default return value if it fails due to
|
|
|
- unknown reasons
|
|
|
-
|
|
|
- ***QDF_STATUS_E_RESOURCES - System resources (other than memory)
|
|
|
- are unavailable
|
|
|
- \sa
|
|
|
-
|
|
|
- ( *** return value not considered yet )
|
|
|
- --------------------------------------------------------------------------*/
|
|
|
-
|
|
|
-QDF_STATUS cds_encrypt_aes(uint32_t cryptHandle, /* Handle */
|
|
|
- uint8_t *pPlainText, /* pointer to data stream */
|
|
|
- uint8_t *pCiphertext, uint8_t *pKey)
|
|
|
-{ /* pointer to authentication key */
|
|
|
- struct ecb_aes_result result;
|
|
|
- struct ablkcipher_request *req;
|
|
|
- struct crypto_ablkcipher *tfm;
|
|
|
- int ret = 0;
|
|
|
- char iv[IV_SIZE_AES_128];
|
|
|
- struct scatterlist sg_in;
|
|
|
- struct scatterlist sg_out;
|
|
|
-
|
|
|
- init_completion(&result.completion);
|
|
|
-
|
|
|
- tfm = cds_crypto_alloc_ablkcipher("cbc(aes)", 0, 0);
|
|
|
- if (IS_ERR(tfm)) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_alloc_ablkcipher failed");
|
|
|
- ret = PTR_ERR(tfm);
|
|
|
- goto err_tfm;
|
|
|
- }
|
|
|
-
|
|
|
- req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
|
|
|
- if (!req) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "Failed to allocate request for cbc(aes)");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_req;
|
|
|
- }
|
|
|
-
|
|
|
- ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
|
|
|
- ecb_aes_complete, &result);
|
|
|
-
|
|
|
- crypto_ablkcipher_clear_flags(tfm, ~0);
|
|
|
-
|
|
|
- ret = crypto_ablkcipher_setkey(tfm, pKey, AES_KEYSIZE_128);
|
|
|
- if (ret) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_cipher_setkey failed");
|
|
|
- goto err_setkey;
|
|
|
- }
|
|
|
-
|
|
|
- memset(iv, 0, IV_SIZE_AES_128);
|
|
|
-
|
|
|
- sg_init_one(&sg_in, pPlainText, AES_BLOCK_SIZE);
|
|
|
-
|
|
|
- sg_init_one(&sg_out, pCiphertext, AES_BLOCK_SIZE);
|
|
|
-
|
|
|
- ablkcipher_request_set_crypt(req, &sg_in, &sg_out, AES_BLOCK_SIZE, iv);
|
|
|
-
|
|
|
- crypto_ablkcipher_encrypt(req);
|
|
|
-
|
|
|
-/* ------------------------------------- */
|
|
|
-err_setkey:
|
|
|
- cds_ablkcipher_request_free(req);
|
|
|
-err_req:
|
|
|
- cds_crypto_free_ablkcipher(tfm);
|
|
|
-err_tfm:
|
|
|
- /* return ret; */
|
|
|
- if (ret != 0) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "%s() call failed", __func__);
|
|
|
- return QDF_STATUS_E_FAULT;
|
|
|
- }
|
|
|
-
|
|
|
- return QDF_STATUS_SUCCESS;
|
|
|
-}
|
|
|
-
|
|
|
-/*--------------------------------------------------------------------------
|
|
|
-
|
|
|
- \brief cds_decrypt_aes() - Decrypts an AES Encrypted byte stream
|
|
|
-
|
|
|
- The cds_decrypt_aes() function decrypts the encrypted byte stream.
|
|
|
-
|
|
|
- Buffer should be allocated before calling cds_rand_get_bytes().
|
|
|
-
|
|
|
- Attempting to initialize an already initialized lock results in
|
|
|
- a failure.
|
|
|
-
|
|
|
- \param lock - pointer to the opaque lock object to initialize
|
|
|
-
|
|
|
- \return QDF_STATUS_SUCCESS - Successfully generated random memory.
|
|
|
-
|
|
|
- QDF_STATUS_E_FAULT - pbBuf is an invalid pointer.
|
|
|
-
|
|
|
- QDF_STATUS_E_FAILURE - default return value if it fails due to
|
|
|
- unknown reasons
|
|
|
-
|
|
|
- ***QDF_STATUS_E_RESOURCES - System resources (other than memory)
|
|
|
- are unavailable
|
|
|
- \sa
|
|
|
-
|
|
|
- ( *** return value not considered yet )
|
|
|
- --------------------------------------------------------------------------*/
|
|
|
-
|
|
|
-QDF_STATUS cds_decrypt_aes(uint32_t cryptHandle, /* Handle */
|
|
|
- uint8_t *pText, /* pointer to data stream */
|
|
|
- uint8_t *pDecrypted, uint8_t *pKey)
|
|
|
-{ /* pointer to authentication key */
|
|
|
-/* QDF_STATUS uResult = QDF_STATUS_E_FAILURE; */
|
|
|
- struct ecb_aes_result result;
|
|
|
- struct ablkcipher_request *req;
|
|
|
- struct crypto_ablkcipher *tfm;
|
|
|
- int ret = 0;
|
|
|
- char iv[IV_SIZE_AES_128];
|
|
|
- struct scatterlist sg_in;
|
|
|
- struct scatterlist sg_out;
|
|
|
-
|
|
|
- init_completion(&result.completion);
|
|
|
-
|
|
|
- tfm = cds_crypto_alloc_ablkcipher("cbc(aes)", 0, 0);
|
|
|
- if (IS_ERR(tfm)) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_alloc_ablkcipher failed");
|
|
|
- ret = PTR_ERR(tfm);
|
|
|
- goto err_tfm;
|
|
|
- }
|
|
|
-
|
|
|
- req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
|
|
|
- if (!req) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "Failed to allocate request for cbc(aes)");
|
|
|
- ret = -ENOMEM;
|
|
|
- goto err_req;
|
|
|
- }
|
|
|
-
|
|
|
- ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
|
|
|
- ecb_aes_complete, &result);
|
|
|
-
|
|
|
- crypto_ablkcipher_clear_flags(tfm, ~0);
|
|
|
-
|
|
|
- ret = crypto_ablkcipher_setkey(tfm, pKey, AES_KEYSIZE_128);
|
|
|
- if (ret) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "crypto_cipher_setkey failed");
|
|
|
- goto err_setkey;
|
|
|
- }
|
|
|
-
|
|
|
- memset(iv, 0, IV_SIZE_AES_128);
|
|
|
-
|
|
|
- sg_init_one(&sg_in, pText, AES_BLOCK_SIZE);
|
|
|
-
|
|
|
- sg_init_one(&sg_out, pDecrypted, AES_BLOCK_SIZE);
|
|
|
-
|
|
|
- ablkcipher_request_set_crypt(req, &sg_in, &sg_out, AES_BLOCK_SIZE, iv);
|
|
|
-
|
|
|
- crypto_ablkcipher_decrypt(req);
|
|
|
-
|
|
|
-/* ------------------------------------- */
|
|
|
-err_setkey:
|
|
|
- cds_ablkcipher_request_free(req);
|
|
|
-err_req:
|
|
|
- cds_crypto_free_ablkcipher(tfm);
|
|
|
-err_tfm:
|
|
|
- /* return ret; */
|
|
|
- if (ret != 0) {
|
|
|
- QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
|
|
|
- "%s() call failed", __func__);
|
|
|
- return QDF_STATUS_E_FAULT;
|
|
|
- }
|
|
|
-
|
|
|
- return QDF_STATUS_SUCCESS;
|
|
|
-}
|
|
|
|
|
|
uint32_t cds_chan_to_freq(uint8_t chan)
|
|
|
{
|