Loading Documentation/devicetree/bindings/crypto/msm/qcrypto.txt +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ Required properties: Optional properties: - qcom,ce-hw-shared : optional, indicates if the hardware is shared between EE. - qcom,ce-hw-key : optional, indicates if the hardware supports use of HW KEY. - qcom,use-sw-aes-cbc-ecb-ctr-algo : optional, indicates if use SW aes-cbc/ecb/ctr algorithm. - qcom,use-sw-aes-xts-algo : optional, indicates if use SW aes-xts algorithm. - qcom,use-sw-aead-algo : optional, indicates if use SW aead algorithm. - qcom,use-sw-ahash-algo : optional, indicates if use SW hash algorithm. - qcom,use-sw-hmac-algo : optional, indicates if use SW hmac algorithm. - qcom,use-sw-aes-ccm-algo : optional, indicates if use SW aes-ccm algorithm. Example: Loading drivers/crypto/msm/qce.h +7 −1 Original line number Diff line number Diff line /* Qualcomm Crypto Engine driver API * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -116,6 +116,12 @@ struct ce_hw_support { bool bam; bool is_shared; bool hw_key; bool use_sw_aes_cbc_ecb_ctr_algo; bool use_sw_aead_algo; bool use_sw_aes_xts_algo; bool use_sw_ahash_algo; bool use_sw_hmac_algo; bool use_sw_aes_ccm_algo; }; /* Sha operation parameters */ Loading drivers/crypto/msm/qce50.c +40 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,13 @@ struct qce_device { dma_addr_t phy_ota_src; dma_addr_t phy_ota_dst; unsigned int ota_size; bool use_sw_aes_cbc_ecb_ctr_algo; bool use_sw_aead_algo; bool use_sw_aes_xts_algo; bool use_sw_ahash_algo; bool use_sw_hmac_algo; bool use_sw_aes_ccm_algo; }; /* Standard initialization vector for SHA-1, source: FIPS 180-2 */ Loading Loading @@ -5060,6 +5067,26 @@ static int __qce_get_device_tree_data(struct platform_device *pdev, "qcom,ce-hw-shared"); pce_dev->support_hw_key = of_property_read_bool((&pdev->dev)->of_node, "qcom,ce-hw-key"); pce_dev->use_sw_aes_cbc_ecb_ctr_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-cbc-ecb-ctr-algo"); pce_dev->use_sw_aead_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aead-algo"); pce_dev->use_sw_aes_xts_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-xts-algo"); pce_dev->use_sw_ahash_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-ahash-algo"); pce_dev->use_sw_hmac_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-hmac-algo"); pce_dev->use_sw_aes_ccm_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-ccm-algo"); if (of_property_read_u32((&pdev->dev)->of_node, "qcom,bam-pipe-pair", &pce_dev->ce_sps.pipe_pair_index)) { Loading Loading @@ -5391,6 +5418,19 @@ int qce_hw_support(void *handle, struct ce_hw_support *ce_support) ce_support->aligned_only = false; else ce_support->aligned_only = true; ce_support->use_sw_aes_cbc_ecb_ctr_algo = pce_dev->use_sw_aes_cbc_ecb_ctr_algo; ce_support->use_sw_aead_algo = pce_dev->use_sw_aead_algo; ce_support->use_sw_aes_xts_algo = pce_dev->use_sw_aes_xts_algo; ce_support->use_sw_ahash_algo = pce_dev->use_sw_ahash_algo; ce_support->use_sw_hmac_algo = pce_dev->use_sw_hmac_algo; ce_support->use_sw_aes_ccm_algo = pce_dev->use_sw_aes_ccm_algo; return 0; } EXPORT_SYMBOL(qce_hw_support); Loading drivers/crypto/msm/qcrypto.c +78 −4 Original line number Diff line number Diff line /* Qualcomm Crypto driver * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -3237,6 +3237,16 @@ static int _sha256_hmac_digest(struct ahash_request *req) return _sha_digest(req); } static int _qcrypto_prefix_alg_cra_name(char cra_name[], unsigned int size) { char new_cra_name[CRYPTO_MAX_ALG_NAME] = "qcom-"; if (CRYPTO_MAX_ALG_NAME < size + 5) return -EINVAL; strlcat(new_cra_name, cra_name, CRYPTO_MAX_ALG_NAME); strlcpy(cra_name, new_cra_name, CRYPTO_MAX_ALG_NAME); return 0; } int qcrypto_cipher_set_flag(struct ablkcipher_request *req, unsigned int flags) { struct qcrypto_cipher_ctx *ctx = crypto_tfm_ctx(req->base.tfm); Loading Loading @@ -3868,6 +3878,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_cbc_ecb_ctr_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3890,6 +3911,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_xts_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3915,7 +3947,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_ahash_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->sha_alg.halg.base.cra_name, strlen(q_alg->sha_alg.halg.base.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->sha_alg.halg.base.cra_name); goto err; } } rc = crypto_register_ahash(&q_alg->sha_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3941,7 +3983,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aead_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, Loading @@ -3968,7 +4020,18 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_hmac_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->sha_alg.halg.base.cra_name, strlen( q_alg->sha_alg.halg.base.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->sha_alg.halg.base.cra_name); goto err; } } rc = crypto_register_ahash(&q_alg->sha_alg); if (rc) { dev_err(&pdev->dev, Loading @@ -3994,6 +4057,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_ccm_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading Loading
Documentation/devicetree/bindings/crypto/msm/qcrypto.txt +6 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,12 @@ Required properties: Optional properties: - qcom,ce-hw-shared : optional, indicates if the hardware is shared between EE. - qcom,ce-hw-key : optional, indicates if the hardware supports use of HW KEY. - qcom,use-sw-aes-cbc-ecb-ctr-algo : optional, indicates if use SW aes-cbc/ecb/ctr algorithm. - qcom,use-sw-aes-xts-algo : optional, indicates if use SW aes-xts algorithm. - qcom,use-sw-aead-algo : optional, indicates if use SW aead algorithm. - qcom,use-sw-ahash-algo : optional, indicates if use SW hash algorithm. - qcom,use-sw-hmac-algo : optional, indicates if use SW hmac algorithm. - qcom,use-sw-aes-ccm-algo : optional, indicates if use SW aes-ccm algorithm. Example: Loading
drivers/crypto/msm/qce.h +7 −1 Original line number Diff line number Diff line /* Qualcomm Crypto Engine driver API * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -116,6 +116,12 @@ struct ce_hw_support { bool bam; bool is_shared; bool hw_key; bool use_sw_aes_cbc_ecb_ctr_algo; bool use_sw_aead_algo; bool use_sw_aes_xts_algo; bool use_sw_ahash_algo; bool use_sw_hmac_algo; bool use_sw_aes_ccm_algo; }; /* Sha operation parameters */ Loading
drivers/crypto/msm/qce50.c +40 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,13 @@ struct qce_device { dma_addr_t phy_ota_src; dma_addr_t phy_ota_dst; unsigned int ota_size; bool use_sw_aes_cbc_ecb_ctr_algo; bool use_sw_aead_algo; bool use_sw_aes_xts_algo; bool use_sw_ahash_algo; bool use_sw_hmac_algo; bool use_sw_aes_ccm_algo; }; /* Standard initialization vector for SHA-1, source: FIPS 180-2 */ Loading Loading @@ -5060,6 +5067,26 @@ static int __qce_get_device_tree_data(struct platform_device *pdev, "qcom,ce-hw-shared"); pce_dev->support_hw_key = of_property_read_bool((&pdev->dev)->of_node, "qcom,ce-hw-key"); pce_dev->use_sw_aes_cbc_ecb_ctr_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-cbc-ecb-ctr-algo"); pce_dev->use_sw_aead_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aead-algo"); pce_dev->use_sw_aes_xts_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-xts-algo"); pce_dev->use_sw_ahash_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-ahash-algo"); pce_dev->use_sw_hmac_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-hmac-algo"); pce_dev->use_sw_aes_ccm_algo = of_property_read_bool((&pdev->dev)->of_node, "qcom,use-sw-aes-ccm-algo"); if (of_property_read_u32((&pdev->dev)->of_node, "qcom,bam-pipe-pair", &pce_dev->ce_sps.pipe_pair_index)) { Loading Loading @@ -5391,6 +5418,19 @@ int qce_hw_support(void *handle, struct ce_hw_support *ce_support) ce_support->aligned_only = false; else ce_support->aligned_only = true; ce_support->use_sw_aes_cbc_ecb_ctr_algo = pce_dev->use_sw_aes_cbc_ecb_ctr_algo; ce_support->use_sw_aead_algo = pce_dev->use_sw_aead_algo; ce_support->use_sw_aes_xts_algo = pce_dev->use_sw_aes_xts_algo; ce_support->use_sw_ahash_algo = pce_dev->use_sw_ahash_algo; ce_support->use_sw_hmac_algo = pce_dev->use_sw_hmac_algo; ce_support->use_sw_aes_ccm_algo = pce_dev->use_sw_aes_ccm_algo; return 0; } EXPORT_SYMBOL(qce_hw_support); Loading
drivers/crypto/msm/qcrypto.c +78 −4 Original line number Diff line number Diff line /* Qualcomm Crypto driver * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -3237,6 +3237,16 @@ static int _sha256_hmac_digest(struct ahash_request *req) return _sha_digest(req); } static int _qcrypto_prefix_alg_cra_name(char cra_name[], unsigned int size) { char new_cra_name[CRYPTO_MAX_ALG_NAME] = "qcom-"; if (CRYPTO_MAX_ALG_NAME < size + 5) return -EINVAL; strlcat(new_cra_name, cra_name, CRYPTO_MAX_ALG_NAME); strlcpy(cra_name, new_cra_name, CRYPTO_MAX_ALG_NAME); return 0; } int qcrypto_cipher_set_flag(struct ablkcipher_request *req, unsigned int flags) { struct qcrypto_cipher_ctx *ctx = crypto_tfm_ctx(req->base.tfm); Loading Loading @@ -3868,6 +3878,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_cbc_ecb_ctr_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3890,6 +3911,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_xts_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3915,7 +3947,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_ahash_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->sha_alg.halg.base.cra_name, strlen(q_alg->sha_alg.halg.base.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->sha_alg.halg.base.cra_name); goto err; } } rc = crypto_register_ahash(&q_alg->sha_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading @@ -3941,7 +3983,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aead_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, Loading @@ -3968,7 +4020,18 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_hmac_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->sha_alg.halg.base.cra_name, strlen( q_alg->sha_alg.halg.base.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->sha_alg.halg.base.cra_name); goto err; } } rc = crypto_register_ahash(&q_alg->sha_alg); if (rc) { dev_err(&pdev->dev, Loading @@ -3994,6 +4057,17 @@ static int _qcrypto_probe(struct platform_device *pdev) rc = PTR_ERR(q_alg); goto err; } if (cp->ce_support.use_sw_aes_ccm_algo) { rc = _qcrypto_prefix_alg_cra_name( q_alg->cipher_alg.cra_name, strlen(q_alg->cipher_alg.cra_name)); if (rc) { dev_err(&pdev->dev, "The algorithm name %s is too long.\n", q_alg->cipher_alg.cra_name); goto err; } } rc = crypto_register_alg(&q_alg->cipher_alg); if (rc) { dev_err(&pdev->dev, "%s alg registration failed\n", Loading