aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2014-07-30 16:41:32 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-08-01 10:36:13 -0400
commit6391723293bb55f05b43973bbbc7a06822b50555 (patch)
tree7135736b047b64fbdba25688a06f45ca6e5c5bff /drivers/crypto
parent2fc0d258bc5f88de31d1d2e239a3521e2a6535f8 (diff)
crypto: ccp - Do not sign extend input data to CCP
The CCP hardware interprets all numbers as unsigned numbers, therefore sign extending input data is not valid. Modify the function calls for RSA and ECC to not perform sign extending. This patch is based on the cryptodev-2.6 kernel tree. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/ccp/ccp-ops.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index 9ae006d69df4..8729364261d7 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -1606,7 +1606,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1606 goto e_ksb; 1606 goto e_ksb;
1607 1607
1608 ccp_reverse_set_dm_area(&exp, rsa->exp, rsa->exp_len, CCP_KSB_BYTES, 1608 ccp_reverse_set_dm_area(&exp, rsa->exp, rsa->exp_len, CCP_KSB_BYTES,
1609 true); 1609 false);
1610 ret = ccp_copy_to_ksb(cmd_q, &exp, op.jobid, op.ksb_key, 1610 ret = ccp_copy_to_ksb(cmd_q, &exp, op.jobid, op.ksb_key,
1611 CCP_PASSTHRU_BYTESWAP_NOOP); 1611 CCP_PASSTHRU_BYTESWAP_NOOP);
1612 if (ret) { 1612 if (ret) {
@@ -1623,10 +1623,10 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1623 goto e_exp; 1623 goto e_exp;
1624 1624
1625 ccp_reverse_set_dm_area(&src, rsa->mod, rsa->mod_len, CCP_KSB_BYTES, 1625 ccp_reverse_set_dm_area(&src, rsa->mod, rsa->mod_len, CCP_KSB_BYTES,
1626 true); 1626 false);
1627 src.address += o_len; /* Adjust the address for the copy operation */ 1627 src.address += o_len; /* Adjust the address for the copy operation */
1628 ccp_reverse_set_dm_area(&src, rsa->src, rsa->src_len, CCP_KSB_BYTES, 1628 ccp_reverse_set_dm_area(&src, rsa->src, rsa->src_len, CCP_KSB_BYTES,
1629 true); 1629 false);
1630 src.address -= o_len; /* Reset the address to original value */ 1630 src.address -= o_len; /* Reset the address to original value */
1631 1631
1632 /* Prepare the output area for the operation */ 1632 /* Prepare the output area for the operation */
@@ -1841,20 +1841,20 @@ static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1841 1841
1842 /* Copy the ECC modulus */ 1842 /* Copy the ECC modulus */
1843 ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, 1843 ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len,
1844 CCP_ECC_OPERAND_SIZE, true); 1844 CCP_ECC_OPERAND_SIZE, false);
1845 src.address += CCP_ECC_OPERAND_SIZE; 1845 src.address += CCP_ECC_OPERAND_SIZE;
1846 1846
1847 /* Copy the first operand */ 1847 /* Copy the first operand */
1848 ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_1, 1848 ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_1,
1849 ecc->u.mm.operand_1_len, 1849 ecc->u.mm.operand_1_len,
1850 CCP_ECC_OPERAND_SIZE, true); 1850 CCP_ECC_OPERAND_SIZE, false);
1851 src.address += CCP_ECC_OPERAND_SIZE; 1851 src.address += CCP_ECC_OPERAND_SIZE;
1852 1852
1853 if (ecc->function != CCP_ECC_FUNCTION_MINV_384BIT) { 1853 if (ecc->function != CCP_ECC_FUNCTION_MINV_384BIT) {
1854 /* Copy the second operand */ 1854 /* Copy the second operand */
1855 ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_2, 1855 ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_2,
1856 ecc->u.mm.operand_2_len, 1856 ecc->u.mm.operand_2_len,
1857 CCP_ECC_OPERAND_SIZE, true); 1857 CCP_ECC_OPERAND_SIZE, false);
1858 src.address += CCP_ECC_OPERAND_SIZE; 1858 src.address += CCP_ECC_OPERAND_SIZE;
1859 } 1859 }
1860 1860
@@ -1960,17 +1960,17 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1960 1960
1961 /* Copy the ECC modulus */ 1961 /* Copy the ECC modulus */
1962 ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, 1962 ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len,
1963 CCP_ECC_OPERAND_SIZE, true); 1963 CCP_ECC_OPERAND_SIZE, false);
1964 src.address += CCP_ECC_OPERAND_SIZE; 1964 src.address += CCP_ECC_OPERAND_SIZE;
1965 1965
1966 /* Copy the first point X and Y coordinate */ 1966 /* Copy the first point X and Y coordinate */
1967 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.x, 1967 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.x,
1968 ecc->u.pm.point_1.x_len, 1968 ecc->u.pm.point_1.x_len,
1969 CCP_ECC_OPERAND_SIZE, true); 1969 CCP_ECC_OPERAND_SIZE, false);
1970 src.address += CCP_ECC_OPERAND_SIZE; 1970 src.address += CCP_ECC_OPERAND_SIZE;
1971 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.y, 1971 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.y,
1972 ecc->u.pm.point_1.y_len, 1972 ecc->u.pm.point_1.y_len,
1973 CCP_ECC_OPERAND_SIZE, true); 1973 CCP_ECC_OPERAND_SIZE, false);
1974 src.address += CCP_ECC_OPERAND_SIZE; 1974 src.address += CCP_ECC_OPERAND_SIZE;
1975 1975
1976 /* Set the first point Z coordianate to 1 */ 1976 /* Set the first point Z coordianate to 1 */
@@ -1981,11 +1981,11 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1981 /* Copy the second point X and Y coordinate */ 1981 /* Copy the second point X and Y coordinate */
1982 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.x, 1982 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.x,
1983 ecc->u.pm.point_2.x_len, 1983 ecc->u.pm.point_2.x_len,
1984 CCP_ECC_OPERAND_SIZE, true); 1984 CCP_ECC_OPERAND_SIZE, false);
1985 src.address += CCP_ECC_OPERAND_SIZE; 1985 src.address += CCP_ECC_OPERAND_SIZE;
1986 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.y, 1986 ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.y,
1987 ecc->u.pm.point_2.y_len, 1987 ecc->u.pm.point_2.y_len,
1988 CCP_ECC_OPERAND_SIZE, true); 1988 CCP_ECC_OPERAND_SIZE, false);
1989 src.address += CCP_ECC_OPERAND_SIZE; 1989 src.address += CCP_ECC_OPERAND_SIZE;
1990 1990
1991 /* Set the second point Z coordianate to 1 */ 1991 /* Set the second point Z coordianate to 1 */
@@ -1995,14 +1995,14 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
1995 /* Copy the Domain "a" parameter */ 1995 /* Copy the Domain "a" parameter */
1996 ccp_reverse_set_dm_area(&src, ecc->u.pm.domain_a, 1996 ccp_reverse_set_dm_area(&src, ecc->u.pm.domain_a,
1997 ecc->u.pm.domain_a_len, 1997 ecc->u.pm.domain_a_len,
1998 CCP_ECC_OPERAND_SIZE, true); 1998 CCP_ECC_OPERAND_SIZE, false);
1999 src.address += CCP_ECC_OPERAND_SIZE; 1999 src.address += CCP_ECC_OPERAND_SIZE;
2000 2000
2001 if (ecc->function == CCP_ECC_FUNCTION_PMUL_384BIT) { 2001 if (ecc->function == CCP_ECC_FUNCTION_PMUL_384BIT) {
2002 /* Copy the scalar value */ 2002 /* Copy the scalar value */
2003 ccp_reverse_set_dm_area(&src, ecc->u.pm.scalar, 2003 ccp_reverse_set_dm_area(&src, ecc->u.pm.scalar,
2004 ecc->u.pm.scalar_len, 2004 ecc->u.pm.scalar_len,
2005 CCP_ECC_OPERAND_SIZE, true); 2005 CCP_ECC_OPERAND_SIZE, false);
2006 src.address += CCP_ECC_OPERAND_SIZE; 2006 src.address += CCP_ECC_OPERAND_SIZE;
2007 } 2007 }
2008 } 2008 }