src/dpdk/drivers/crypto/zuc/rte_zuc_pmd.c
int
zuc_set_session_parameters(struct zuc_session *sess,
		const struct rte_crypto_sym_xform *xform)
{
	const struct rte_crypto_sym_xform *auth_xform = NULL;
	const struct rte_crypto_sym_xform *cipher_xform = NULL;
	enum zuc_operation mode;

	/* Select Crypto operation - hash then cipher / cipher then hash */
	mode = zuc_get_mode(xform);

	switch (mode) {
	case ZUC_OP_CIPHER_AUTH:
		auth_xform = xform->next;

		/* Fall-through */
	case ZUC_OP_ONLY_CIPHER:
		cipher_xform = xform;
		break;
	case ZUC_OP_AUTH_CIPHER:
		cipher_xform = xform->next;
		/* Fall-through */
	case ZUC_OP_ONLY_AUTH:
		auth_xform = xform;
		break;
	case ZUC_OP_NOT_SUPPORTED:
	default:
		ZUC_LOG(ERR, "Unsupported operation chain order parameter");
		return -ENOTSUP;
	}

	if (cipher_xform) {
		/* Only ZUC EEA3 supported */
		if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_ZUC_EEA3)
			return -ENOTSUP;

		if (cipher_xform->cipher.iv.length != ZUC_IV_KEY_LENGTH) {
			ZUC_LOG(ERR, "Wrong IV length");
			return -EINVAL;
		}
		sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;

		/* Copy the key */
		memcpy(sess->pKey_cipher, cipher_xform->cipher.key.data,
				ZUC_IV_KEY_LENGTH);
	}

	if (auth_xform) {
		/* Only ZUC EIA3 supported */
		if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_ZUC_EIA3)
			return -ENOTSUP;

		if (auth_xform->auth.digest_length != ZUC_DIGEST_LENGTH) {
			ZUC_LOG(ERR, "Wrong digest length");
			return -EINVAL;
		}

		sess->auth_op = auth_xform->auth.op;

		if (auth_xform->auth.iv.length != ZUC_IV_KEY_LENGTH) {
			ZUC_LOG(ERR, "Wrong IV length");
			return -EINVAL;
		}
		sess->auth_iv_offset = auth_xform->auth.iv.offset;

		/* Copy the key */
		memcpy(sess->pKey_hash, auth_xform->auth.key.data,
				ZUC_IV_KEY_LENGTH);
	}


	sess->op = mode;

	return 0;
}
/** Parse crypto xform chain and set private session parameters. */
Parse crypto xform chain and set private session parameters.
Parse crypto xform chain and set private session parameters .
int
zuc_set_session_parameters(struct zuc_session *sess,
		const struct rte_crypto_sym_xform *xform)
{
	const struct rte_crypto_sym_xform *auth_xform = NULL;
	const struct rte_crypto_sym_xform *cipher_xform = NULL;
	enum zuc_operation mode;
	mode = zuc_get_mode(xform);
	switch (mode) {
	case ZUC_OP_CIPHER_AUTH:
		auth_xform = xform->next;
	case ZUC_OP_ONLY_CIPHER:
		cipher_xform = xform;
		break;
	case ZUC_OP_AUTH_CIPHER:
		cipher_xform = xform->next;
	case ZUC_OP_ONLY_AUTH:
		auth_xform = xform;
		break;
	case ZUC_OP_NOT_SUPPORTED:
	default:
		ZUC_LOG(ERR, "Unsupported operation chain order parameter");
		return -ENOTSUP;
	}
	if (cipher_xform) {
		if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_ZUC_EEA3)
			return -ENOTSUP;
		if (cipher_xform->cipher.iv.length != ZUC_IV_KEY_LENGTH) {
			ZUC_LOG(ERR, "Wrong IV length");
			return -EINVAL;
		}
		sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
		memcpy(sess->pKey_cipher, cipher_xform->cipher.key.data,
				ZUC_IV_KEY_LENGTH);
	}
	if (auth_xform) {
		if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_ZUC_EIA3)
			return -ENOTSUP;
		if (auth_xform->auth.digest_length != ZUC_DIGEST_LENGTH) {
			ZUC_LOG(ERR, "Wrong digest length");
			return -EINVAL;
		}
		sess->auth_op = auth_xform->auth.op;
		if (auth_xform->auth.iv.length != ZUC_IV_KEY_LENGTH) {
			ZUC_LOG(ERR, "Wrong IV length");
			return -EINVAL;
		}
		sess->auth_iv_offset = auth_xform->auth.iv.offset;
		memcpy(sess->pKey_hash, auth_xform->auth.key.data,
				ZUC_IV_KEY_LENGTH);
	}
	sess->op = mode;
	return 0;
}
int zuc_set_session_parameters ( struct zuc_session * sess , const struct rte_crypto_sym_xform * xform ) { const struct rte_crypto_sym_xform * auth_xform = NULL ; const struct rte_crypto_sym_xform * cipher_xform = NULL ; enum zuc_operation mode ; mode = zuc_get_mode ( xform ) ; switch ( mode ) { case ZUC_OP_CIPHER_AUTH : auth_xform = xform -> next ; case ZUC_OP_ONLY_CIPHER : cipher_xform = xform ; break ; case ZUC_OP_AUTH_CIPHER : cipher_xform = xform -> next ; case ZUC_OP_ONLY_AUTH : auth_xform = xform ; break ; case ZUC_OP_NOT_SUPPORTED : default : ZUC_LOG ( ERR , " " ) ; return - ENOTSUP ; } if ( cipher_xform ) { if ( cipher_xform -> cipher . algo != RTE_CRYPTO_CIPHER_ZUC_EEA3 ) return - ENOTSUP ; if ( cipher_xform -> cipher . iv . length != ZUC_IV_KEY_LENGTH ) { ZUC_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> cipher_iv_offset = cipher_xform -> cipher . iv . offset ; memcpy ( sess -> pKey_cipher , cipher_xform -> cipher . key . data , ZUC_IV_KEY_LENGTH ) ; } if ( auth_xform ) { if ( auth_xform -> auth . algo != RTE_CRYPTO_AUTH_ZUC_EIA3 ) return - ENOTSUP ; if ( auth_xform -> auth . digest_length != ZUC_DIGEST_LENGTH ) { ZUC_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> auth_op = auth_xform -> auth . op ; if ( auth_xform -> auth . iv . length != ZUC_IV_KEY_LENGTH ) { ZUC_LOG ( ERR , " " ) ; return - EINVAL ; } sess -> auth_iv_offset = auth_xform -> auth . iv . offset ; memcpy ( sess -> pKey_hash , auth_xform -> auth . key . data , ZUC_IV_KEY_LENGTH ) ; } sess -> op = mode ; return 0 ; }
Parse crypto xform chain and set private session parameters.
Parse crypto xform chain and set private session parameters .
/* Select Crypto operation - hash then cipher / cipher then hash */ /* Fall-through */ /* Fall-through */ /* Only ZUC EEA3 supported */ /* Copy the key */ /* Only ZUC EIA3 supported */ /* Copy the key */