src/dpdk/drivers/crypto/mvsam/rte_mrvl_pmd.c
static int
mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *aead_xform)
{
	uint8_t *aead_key;

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

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

	sess->sam_sess_params.dir =
		(aead_xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.cipher_alg =
		aead_map[aead_xform->aead.algo].cipher_alg;
	sess->sam_sess_params.cipher_mode =
		aead_map[aead_xform->aead.algo].cipher_mode;

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

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

	aead_key = malloc(aead_xform->aead.key.length);
	if (aead_key == NULL) {
		MRVL_LOG(ERR, "Insufficient memory!");
		return -ENOMEM;
	}

	memcpy(aead_key, aead_xform->aead.key.data,
			aead_xform->aead.key.length);

	sess->sam_sess_params.cipher_key = aead_key;
	sess->sam_sess_params.cipher_key_len = aead_xform->aead.key.length;

	if (sess->sam_sess_params.cipher_mode == SAM_CIPHER_GCM)
		sess->sam_sess_params.auth_alg = SAM_AUTH_AES_GCM;

	sess->sam_sess_params.u.basic.auth_icv_len =
		aead_xform->aead.digest_length;

	sess->sam_sess_params.u.basic.auth_aad_len =
		aead_xform->aead.aad_length;

	return 0;
}
/**
 * Set session parameters for aead part.
 *
 * @param sess Crypto session pointer.
 * @param aead_xform Pointer to configuration structure for aead operations.
 * @returns 0 in case of success, negative value otherwise.
 */
Set session parameters for aead part.
@param sess Crypto session pointer.
@param aead_xform Pointer to configuration structure for aead operations.
@returns 0 in case of success, negative value otherwise.
Set session parameters for aead part . @param sess Crypto session pointer . @param aead_xform Pointer to configuration structure for aead operations . @returns 0 in case of success negative value otherwise .
static int
mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess,
		const struct rte_crypto_sym_xform *aead_xform)
{
	uint8_t *aead_key;
	if (aead_xform->type != RTE_CRYPTO_SYM_XFORM_AEAD) {
		MRVL_LOG(ERR, "Wrong xform struct provided!");
		return -EINVAL;
	}
	if ((aead_xform->aead.algo > RTE_DIM(aead_map)) ||
		(aead_map[aead_xform->aead.algo].supported
			!= ALGO_SUPPORTED)) {
		MRVL_LOG(ERR, "AEAD algorithm not supported!");
		return -EINVAL;
	}
	sess->sam_sess_params.dir =
		(aead_xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ?
		SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT;
	sess->sam_sess_params.cipher_alg =
		aead_map[aead_xform->aead.algo].cipher_alg;
	sess->sam_sess_params.cipher_mode =
		aead_map[aead_xform->aead.algo].cipher_mode;
	sess->sam_sess_params.cipher_iv = NULL;
	if (aead_xform->aead.key.length >
		aead_map[aead_xform->aead.algo].max_key_len) {
		MRVL_LOG(ERR, "Wrong key length!");
		return -EINVAL;
	}
	aead_key = malloc(aead_xform->aead.key.length);
	if (aead_key == NULL) {
		MRVL_LOG(ERR, "Insufficient memory!");
		return -ENOMEM;
	}
	memcpy(aead_key, aead_xform->aead.key.data,
			aead_xform->aead.key.length);
	sess->sam_sess_params.cipher_key = aead_key;
	sess->sam_sess_params.cipher_key_len = aead_xform->aead.key.length;
	if (sess->sam_sess_params.cipher_mode == SAM_CIPHER_GCM)
		sess->sam_sess_params.auth_alg = SAM_AUTH_AES_GCM;
	sess->sam_sess_params.u.basic.auth_icv_len =
		aead_xform->aead.digest_length;
	sess->sam_sess_params.u.basic.auth_aad_len =
		aead_xform->aead.aad_length;
	return 0;
}
static int mrvl_crypto_set_aead_session_parameters ( struct mrvl_crypto_session * sess , const struct rte_crypto_sym_xform * aead_xform ) { uint8_t * aead_key ; if ( aead_xform -> type != RTE_CRYPTO_SYM_XFORM_AEAD ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } if ( ( aead_xform -> aead . algo > RTE_DIM ( aead_map ) ) || ( aead_map [ aead_xform -> aead . algo ] . supported != ALGO_SUPPORTED ) ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> sam_sess_params . dir = ( aead_xform -> aead . op == RTE_CRYPTO_AEAD_OP_ENCRYPT ) ? SAM_DIR_ENCRYPT : SAM_DIR_DECRYPT ; sess -> sam_sess_params . cipher_alg = aead_map [ aead_xform -> aead . algo ] . cipher_alg ; sess -> sam_sess_params . cipher_mode = aead_map [ aead_xform -> aead . algo ] . cipher_mode ; sess -> sam_sess_params . cipher_iv = NULL ; if ( aead_xform -> aead . key . length > aead_map [ aead_xform -> aead . algo ] . max_key_len ) { MRVL_LOG ( ERR , " " ) ; return - EINVAL ; } aead_key = malloc ( aead_xform -> aead . key . length ) ; if ( aead_key == NULL ) { MRVL_LOG ( ERR , " " ) ; return - ENOMEM ; } memcpy ( aead_key , aead_xform -> aead . key . data , aead_xform -> aead . key . length ) ; sess -> sam_sess_params . cipher_key = aead_key ; sess -> sam_sess_params . cipher_key_len = aead_xform -> aead . key . length ; if ( sess -> sam_sess_params . cipher_mode == SAM_CIPHER_GCM ) sess -> sam_sess_params . auth_alg = SAM_AUTH_AES_GCM ; sess -> sam_sess_params . u . basic . auth_icv_len = aead_xform -> aead . digest_length ; sess -> sam_sess_params . u . basic . auth_aad_len = aead_xform -> aead . aad_length ; return 0 ; }
Set session parameters for aead part.
Set session parameters for aead 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. */