src/dpdk/drivers/crypto/mvsam/rte_mrvl_pmd.c
static int
mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *auth_xform)
{
	uint8_t *auth_key = NULL;

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

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

	sess->sam_sess_params.dir =
		(auth_xform->auth.op == RTE_CRYPTO_AUTH_OP_GENERATE) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.auth_alg =
		auth_map[auth_xform->auth.algo].auth_alg;
	sess->sam_sess_params.u.basic.auth_icv_len =
		auth_xform->auth.digest_length;

	if (auth_xform->auth.key.length > 0) {
		auth_key = malloc(auth_xform->auth.key.length);
		if (auth_key == NULL) {
			MRVL_LOG(ERR, "Not enough memory!");
			return -EINVAL;
		}

		memcpy(auth_key, auth_xform->auth.key.data,
				auth_xform->auth.key.length);
	}

	/* auth_key must be NULL if auth algorithm does not use HMAC */
	sess->sam_sess_params.auth_key = auth_key;
	sess->sam_sess_params.auth_key_len = auth_xform->auth.key.length;

	return 0;
}
/**
 * Set session parameters for authentication part.
 *
 * @param sess Crypto session pointer.
 * @param auth_xform Pointer to configuration structure for auth operations.
 * @returns 0 in case of success, negative value otherwise.
 */
Set session parameters for authentication part.
@param sess Crypto session pointer.
@param auth_xform Pointer to configuration structure for auth operations.
@returns 0 in case of success, negative value otherwise.
Set session parameters for authentication part . @param sess Crypto session pointer . @param auth_xform Pointer to configuration structure for auth operations . @returns 0 in case of success negative value otherwise .
static int
mrvl_crypto_set_auth_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *auth_xform)
{
	uint8_t *auth_key = NULL;
	if (auth_xform->type != RTE_CRYPTO_SYM_XFORM_AUTH) {
		MRVL_LOG(ERR, "Wrong xform struct provided!");
		return -EINVAL;
	}
	if ((auth_xform->auth.algo > RTE_DIM(auth_map)) ||
		(auth_map[auth_xform->auth.algo].supported != ALGO_SUPPORTED)) {
		MRVL_LOG(ERR, "Auth algorithm not supported!");
		return -EINVAL;
	}
	sess->sam_sess_params.dir =
		(auth_xform->auth.op == RTE_CRYPTO_AUTH_OP_GENERATE) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.auth_alg =
		auth_map[auth_xform->auth.algo].auth_alg;
	sess->sam_sess_params.u.basic.auth_icv_len =
		auth_xform->auth.digest_length;
	if (auth_xform->auth.key.length > 0) {
		auth_key = malloc(auth_xform->auth.key.length);
		if (auth_key == NULL) {
			MRVL_LOG(ERR, "Not enough memory!");
			return -EINVAL;
		}
		memcpy(auth_key, auth_xform->auth.key.data,
				auth_xform->auth.key.length);
	}
	sess->sam_sess_params.auth_key = auth_key;
	sess->sam_sess_params.auth_key_len = auth_xform->auth.key.length;
	return 0;
}
static int mrvl_crypto_set_auth_session_parameters ( struct mrvl_crypto_session * sess , const struct rte_crypto_sym_xform * auth_xform ) { uint8_t * auth_key = NULL ; if ( auth_xform -> type != RTE_CRYPTO_SYM_XFORM_AUTH ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } if ( ( auth_xform -> auth . algo > RTE_DIM ( auth_map ) ) || ( auth_map [ auth_xform -> auth . algo ] . supported != ALGO_SUPPORTED ) ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> sam_sess_params . dir = ( auth_xform -> auth . op == RTE_CRYPTO_AUTH_OP_GENERATE ) ? SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT ; sess -> sam_sess_params . auth_alg = auth_map [ auth_xform -> auth . algo ] . auth_alg ; sess -> sam_sess_params . u . basic . auth_icv_len = auth_xform -> auth . digest_length ; if ( auth_xform -> auth . key . length > 0 ) { auth_key = malloc ( auth_xform -> auth . key . length ) ; if ( auth_key == NULL ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } memcpy ( auth_key , auth_xform -> auth . key . data , auth_xform -> auth . key . length ) ; } sess -> sam_sess_params . auth_key = auth_key ; sess -> sam_sess_params . auth_key_len = auth_xform -> auth . key . length ; return 0 ; }
Set session parameters for authentication part.
Set session parameters for authentication part .
/* Make sure we've got proper struct */ /* See if map data is present and valid */ /* auth_key must be NULL if auth algorithm does not use HMAC */