mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
crypto: rockchip: cryptodev: optimized CIOCGSESSION return value
When the CIOCGSESSION command creates an unsupported algorithm or mode, errno is set to -ENOEN. Add SM3/HMAC_SM3 support. Move CMAC/CBCMAC from cipher to hmac. Signed-off-by: Lin Jinhan <troy.lin@rock-chips.com> Change-Id: I4f5f274ffe47d2b81584c192991670ddb2e3def5
This commit is contained in:
@@ -154,7 +154,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
|
||||
out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0);
|
||||
if (unlikely(IS_ERR(out->async.s))) {
|
||||
ddebug(1, "Failed to load cipher %s", alg_name);
|
||||
return -EINVAL;
|
||||
return PTR_ERR(out->async.s);
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0))
|
||||
@@ -358,7 +358,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name,
|
||||
hdata->async.s = crypto_alloc_ahash(alg_name, 0, 0);
|
||||
if (unlikely(IS_ERR(hdata->async.s))) {
|
||||
ddebug(1, "Failed to load transform for %s", alg_name);
|
||||
return -EINVAL;
|
||||
return PTR_ERR(hdata->async.s);
|
||||
}
|
||||
|
||||
/* Copy the key from user and set to TFM. */
|
||||
|
||||
@@ -98,6 +98,8 @@ enum cryptodev_crypto_op_t {
|
||||
CRYPTO_RK_SHA1_HMAC,
|
||||
CRYPTO_RK_SHA256_HMAC,
|
||||
CRYPTO_RK_SHA512_HMAC,
|
||||
CRYPTO_RK_SM3,
|
||||
CRYPTO_RK_SM3_HMAC,
|
||||
|
||||
CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */
|
||||
};
|
||||
|
||||
@@ -275,7 +275,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
|
||||
keylen, stream, aead);
|
||||
if (ret < 0) {
|
||||
ddebug(1, "Failed to load cipher for %s", alg_name);
|
||||
ret = -EINVAL;
|
||||
goto session_error;
|
||||
}
|
||||
}
|
||||
@@ -298,7 +297,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
|
||||
keys.mkey, sop->mackeylen);
|
||||
if (ret != 0) {
|
||||
ddebug(1, "Failed to load hash for %s", hash_name);
|
||||
ret = -EINVAL;
|
||||
goto session_error;
|
||||
}
|
||||
|
||||
|
||||
@@ -887,8 +887,6 @@ static const struct cipher_algo_name_map c_algo_map_tbl[] = {
|
||||
{CRYPTO_RK_SM4_XTS, "xts-sm4-rk", 0, 0},
|
||||
{CRYPTO_RK_SM4_CCM, "ccm-sm4-rk", 1, 1},
|
||||
{CRYPTO_RK_SM4_GCM, "gcm-sm4-rk", 1, 1},
|
||||
{CRYPTO_RK_SM4_CMAC, NULL, 0, 0},
|
||||
{CRYPTO_RK_SM4_CBC_MAC, NULL, 0, 0},
|
||||
{CRYPTO_RK_AES_ECB, "ecb-aes-rk", 0, 0},
|
||||
{CRYPTO_RK_AES_CBC, "cbc-aes-rk", 0, 0},
|
||||
{CRYPTO_RK_AES_CFB, "cfb-aes-rk", 0, 0},
|
||||
@@ -898,8 +896,6 @@ static const struct cipher_algo_name_map c_algo_map_tbl[] = {
|
||||
{CRYPTO_RK_AES_XTS, "xts-aes-rk", 0, 0},
|
||||
{CRYPTO_RK_AES_CCM, "ccm-aes-rk", 1, 1},
|
||||
{CRYPTO_RK_AES_GCM, "gcm-aes-rk", 1, 1},
|
||||
{CRYPTO_RK_AES_CMAC, NULL, 0, 0},
|
||||
{CRYPTO_RK_AES_CBC_MAC, NULL, 0, 0},
|
||||
};
|
||||
|
||||
static const struct hash_algo_name_map h_algo_map_tbl[] = {
|
||||
@@ -912,10 +908,16 @@ static const struct hash_algo_name_map h_algo_map_tbl[] = {
|
||||
{CRYPTO_RK_SHA512, "sha512-rk", 0},
|
||||
{CRYPTO_RK_SHA512_224, "sha512_224-rk", 0},
|
||||
{CRYPTO_RK_SHA512_256, "sha512_256-rk", 0},
|
||||
{CRYPTO_RK_SM3, "sm3-rk", 0},
|
||||
{CRYPTO_RK_MD5_HMAC, "hmac-md5-rk", 1},
|
||||
{CRYPTO_RK_SHA1_HMAC, "hmac-sha1-rk", 1},
|
||||
{CRYPTO_RK_SHA256_HMAC, "hmac-sha256-rk", 1},
|
||||
{CRYPTO_RK_SHA512_HMAC, "hmac-sha512-rk", 1},
|
||||
{CRYPTO_RK_SM3_HMAC, "hmac-sm3-rk", 1},
|
||||
{CRYPTO_RK_SM4_CMAC, "cmac-sm4-rk", 1},
|
||||
{CRYPTO_RK_SM4_CBC_MAC, "cbcmac-sm4-rk", 1},
|
||||
{CRYPTO_RK_AES_CMAC, "cmac-aes-rk", 1},
|
||||
{CRYPTO_RK_AES_CBC_MAC, "cbcmac-aes-rk", 1},
|
||||
};
|
||||
|
||||
const char *rk_get_cipher_name(uint32_t id, int *is_stream, int *is_aead)
|
||||
|
||||
Reference in New Issue
Block a user