src/dpdk/drivers/crypto/mvsam/rte_mrvl_pmd.c
static int
mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *cipher_xform)
{
	uint8_t *cipher_key;

	/* Make sure we've got proper struct */
	if (cipher_xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) {
		MRVL_LOG(ERR, "Wrong xform struct provided!");
		return -EINVAL;
	}

	/* See if map data is present and valid */
	if ((cipher_xform->cipher.algo > RTE_DIM(cipher_map)) ||
		(cipher_map[cipher_xform->cipher.algo].supported
			!= ALGO_SUPPORTED)) {
		MRVL_LOG(ERR, "Cipher algorithm not supported!");
		return -EINVAL;
	}

	sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;

	sess->sam_sess_params.dir =
		(cipher_xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.cipher_alg =
		cipher_map[cipher_xform->cipher.algo].cipher_alg;
	sess->sam_sess_params.cipher_mode =
		cipher_map[cipher_xform->cipher.algo].cipher_mode;

	/* Assume IV will be passed together with data. */
	sess->sam_sess_params.cipher_iv = NULL;

	/* Get max key length. */
	if (cipher_xform->cipher.key.length >
		cipher_map[cipher_xform->cipher.algo].max_key_len) {
		MRVL_LOG(ERR, "Wrong key length!");
		return -EINVAL;
	}

	cipher_key = malloc(cipher_xform->cipher.key.length);
	if (cipher_key == NULL) {
		MRVL_LOG(ERR, "Insufficient memory!");
		return -ENOMEM;
	}

	memcpy(cipher_key, cipher_xform->cipher.key.data,
			cipher_xform->cipher.key.length);

	sess->sam_sess_params.cipher_key_len = cipher_xform->cipher.key.length;
	sess->sam_sess_params.cipher_key = cipher_key;

	return 0;
}
/**
 * Set session parameters for cipher part.
 *
 * @param sess Crypto session pointer.
 * @param cipher_xform Pointer to configuration structure for cipher operations.
 * @returns 0 in case of success, negative value otherwise.
 */
Set session parameters for cipher part.
@param sess Crypto session pointer.
@param cipher_xform Pointer to configuration structure for cipher operations.
@returns 0 in case of success, negative value otherwise.
Set session parameters for cipher part . @param sess Crypto session pointer . @param cipher_xform Pointer to configuration structure for cipher operations . @returns 0 in case of success negative value otherwise .
static int
mrvl_crypto_set_cipher_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *cipher_xform)
{
	uint8_t *cipher_key;
	if (cipher_xform->type != RTE_CRYPTO_SYM_XFORM_CIPHER) {
		MRVL_LOG(ERR, "Wrong xform struct provided!");
		return -EINVAL;
	}
	if ((cipher_xform->cipher.algo > RTE_DIM(cipher_map)) ||
		(cipher_map[cipher_xform->cipher.algo].supported
			!= ALGO_SUPPORTED)) {
		MRVL_LOG(ERR, "Cipher algorithm not supported!");
		return -EINVAL;
	}
	sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
	sess->sam_sess_params.dir =
		(cipher_xform->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.cipher_alg =
		cipher_map[cipher_xform->cipher.algo].cipher_alg;
	sess->sam_sess_params.cipher_mode =
		cipher_map[cipher_xform->cipher.algo].cipher_mode;
	sess->sam_sess_params.cipher_iv = NULL;
	if (cipher_xform->cipher.key.length >
		cipher_map[cipher_xform->cipher.algo].max_key_len) {
		MRVL_LOG(ERR, "Wrong key length!");
		return -EINVAL;
	}
	cipher_key = malloc(cipher_xform->cipher.key.length);
	if (cipher_key == NULL) {
		MRVL_LOG(ERR, "Insufficient memory!");
		return -ENOMEM;
	}
	memcpy(cipher_key, cipher_xform->cipher.key.data,
			cipher_xform->cipher.key.length);
	sess->sam_sess_params.cipher_key_len = cipher_xform->cipher.key.length;
	sess->sam_sess_params.cipher_key = cipher_key;
	return 0;
}
static int mrvl_crypto_set_cipher_session_parameters ( struct mrvl_crypto_session * sess , const struct rte_crypto_sym_xform * cipher_xform ) { uint8_t * cipher_key ; if ( cipher_xform -> type != RTE_CRYPTO_SYM_XFORM_CIPHER ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } if ( ( cipher_xform -> cipher . algo > RTE_DIM ( cipher_map ) ) || ( cipher_map [ cipher_xform -> cipher . algo ] . supported != ALGO_SUPPORTED ) ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> cipher_iv_offset = cipher_xform -> cipher . iv . offset ; sess -> sam_sess_params . dir = ( cipher_xform -> cipher . op == RTE_CRYPTO_CIPHER_OP_ENCRYPT ) ? SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT ; sess -> sam_sess_params . cipher_alg = cipher_map [ cipher_xform -> cipher . algo ] . cipher_alg ; sess -> sam_sess_params . cipher_mode = cipher_map [ cipher_xform -> cipher . algo ] . cipher_mode ; sess -> sam_sess_params . cipher_iv = NULL ; if ( cipher_xform -> cipher . key . length > cipher_map [ cipher_xform -> cipher . algo ] . max_key_len ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } cipher_key = malloc ( cipher_xform -> cipher . key . length ) ; if ( cipher_key == NULL ) { MRVL_LOG ( ERR , " " ) ; return - ENOMEM ; } memcpy ( cipher_key , cipher_xform -> cipher . key . data , cipher_xform -> cipher . key . length ) ; sess -> sam_sess_params . cipher_key_len = cipher_xform -> cipher . key . length ; sess -> sam_sess_params . cipher_key = cipher_key ; return 0 ; }
Set session parameters for cipher part.
Set session parameters for cipher part .
/* Make sure we've got proper struct */ /* See if map data is present and valid */ /* Assume IV will be passed together with data. */ /* Get max key length. */