public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ramalingam C <ramalingam.c@intel.com>
To: seanpaul@chromium.org, intel-gfx@lists.freedesktop.org,
	rodrigo.vivi@intel.com, daniel.vetter@ffwll.ch
Cc: tomas.winkler@intel.com
Subject: [PATCH 28/43] drm/i915: Implement HDCP2.2 receiver authentication
Date: Wed, 14 Feb 2018 19:43:43 +0530	[thread overview]
Message-ID: <1518617638-21684-29-git-send-email-ramalingam.c@intel.com> (raw)
In-Reply-To: <1518617638-21684-1-git-send-email-ramalingam.c@intel.com>

Implements HDCP2.2 authentication for hdcp2.2 receivers, with
following steps:
	Authentication and Key enchange (AKE).
	Locality Check (LC).
	Session Key Exchange(SKE).
	DP Errata for stream type confuguration for receivers.

At AKE, the HDCP Receiver’s public key certificate is verified by the
HDCP Transmitter. A Master Key k m is exchanged.

At LC, the HDCP Transmitter enforces locality on the content by
requiring that the Round Trip Time (RTT) between a pair of messages
is not more than 20 ms.

At SKE, The HDCP Transmitter exchanges Session Key ks with
the HDCP Receiver.

In DP HDCP2.2 encryption and decryption logics use the stream type as
one of the parameter. So Before enabling the Encryption DP HDCP2.2
receiver needs to be communicated with stream type. This is added to
spec as ERRATA.

This generic implementation is complete only with the hdcp2_shim
defined.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/gpu/drm/i915/intel_hdcp.c | 183 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 183 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 8ac824f0ed35..64276f180e45 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -19,6 +19,7 @@
 #define GET_MEI_DDI_INDEX(port)		(((port) == PORT_A) ? DDI_A : \
 					 (enum physical_port) (port))
 #define KEY_LOAD_TRIES	5
+#define HDCP2_LC_RETRY_CNT		3
 
 static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port,
 				    const struct intel_hdcp_shim *shim)
@@ -1020,3 +1021,185 @@ static inline int hdcp2_deauthenticate_port(struct intel_hdcp *hdcp)
 {
 	return hdcp2_close_mei_session(hdcp);
 }
+
+static int hdcp2_authentication_key_exchange(struct intel_hdcp *hdcp)
+{
+	struct intel_digital_port *intel_dig_port =
+					conn_to_dig_port(hdcp->connector);
+	union {
+		struct hdcp2_ake_init ake_init;
+		struct hdcp2_ake_send_cert send_cert;
+		struct hdcp2_ake_no_stored_km no_stored_km;
+		struct hdcp2_ake_send_hprime send_hprime;
+		struct hdcp2_ake_send_pairing_info pairing_info;
+	} msgs;
+	const struct intel_hdcp2_shim *shim = hdcp->hdcp2_shim;
+	size_t size;
+	int ret;
+
+	/* Init for seq_num */
+	hdcp->seq_num_v = 0;
+	hdcp->seq_num_m = 0;
+
+	ret = hdcp2_prepare_ake_init(hdcp, &msgs.ake_init);
+	if (ret < 0)
+		return ret;
+
+	ret = shim->write_msg(intel_dig_port, &msgs.ake_init,
+			      sizeof(msgs.ake_init));
+	if (ret < 0)
+		return ret;
+
+	ret = shim->read_msg(intel_dig_port, AKE_SEND_CERT, &msgs.send_cert,
+			     sizeof(msgs.send_cert));
+	if (ret < 0)
+		return ret;
+
+	if (msgs.send_cert.rx_caps.fields.version !=
+	    HDCP_2_2_RX_CAPS_VERSION_VAL)
+		return -EINVAL;
+
+	hdcp->is_repeater = msgs.send_cert.rx_caps.fields.repeater;
+
+	/*
+	 * Here msgs.no_stored_km will hold msgs corresponding to the km
+	 * stored also.
+	 */
+	ret = hdcp2_verify_rx_cert_prepare_km(hdcp, &msgs.send_cert,
+					      &hdcp->is_paired,
+					      &msgs.no_stored_km, &size);
+	if (ret < 0)
+		return ret;
+
+	ret = shim->write_msg(intel_dig_port, &msgs.no_stored_km, size);
+	if (ret < 0)
+		return ret;
+
+	ret = shim->read_msg(intel_dig_port, AKE_SEND_HPRIME, &msgs.send_hprime,
+			     sizeof(msgs.send_hprime));
+	if (ret < 0)
+		return ret;
+
+	ret = hdcp2_verify_hprime(hdcp, &msgs.send_hprime);
+	if (ret < 0)
+		return ret;
+
+	if (!hdcp->is_paired) {
+		/* Pairing is required */
+		ret = shim->read_msg(intel_dig_port, AKE_SEND_PARING_INFO,
+				     &msgs.pairing_info,
+				     sizeof(msgs.pairing_info));
+		if (ret < 0)
+			return ret;
+
+		ret = hdcp2_store_paring_info(hdcp, &msgs.pairing_info);
+		if (ret < 0)
+			return ret;
+		hdcp->is_paired = true;
+	}
+	return 0;
+}
+
+static int hdcp2_locality_check(struct intel_hdcp *hdcp)
+{
+	struct intel_digital_port *intel_dig_port =
+					conn_to_dig_port(hdcp->connector);
+	union {
+		struct hdcp2_lc_init lc_init;
+		struct hdcp2_lc_send_lprime send_lprime;
+	} msgs;
+	const struct intel_hdcp2_shim *shim = hdcp->hdcp2_shim;
+	int tries = HDCP2_LC_RETRY_CNT, ret, i;
+
+	for (i = 0; i < tries; i++) {
+		ret = hdcp2_prepare_lc_init(hdcp, &msgs.lc_init);
+		if (ret < 0)
+			continue;
+
+		ret = shim->write_msg(intel_dig_port, &msgs.lc_init,
+				      sizeof(msgs.lc_init));
+		if (ret < 0)
+			continue;
+
+		ret = shim->read_msg(intel_dig_port, LC_SEND_LPRIME,
+				     &msgs.send_lprime,
+				     sizeof(msgs.send_lprime));
+		if (ret < 0)
+			continue;
+
+		ret = hdcp2_verify_lprime(hdcp, &msgs.send_lprime);
+		if (!ret)
+			break;
+	}
+	return ret;
+}
+
+static int hdcp2_session_key_exchange(struct intel_hdcp *hdcp)
+{
+	struct intel_digital_port *intel_dig_port =
+					conn_to_dig_port(hdcp->connector);
+	struct hdcp2_ske_send_eks send_eks;
+	int ret;
+
+	ret = hdcp2_prepare_skey(hdcp, &send_eks);
+	if (ret < 0)
+		return ret;
+
+	ret = hdcp->hdcp2_shim->write_msg(intel_dig_port, &send_eks,
+					  sizeof(send_eks));
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static int hdcp2_authenticate_sink(struct intel_hdcp *hdcp)
+{
+	struct intel_digital_port *intel_dig_port =
+					conn_to_dig_port(hdcp->connector);
+	struct hdcp2_dp_errata_stream_type stream_type_msg;
+	const struct intel_hdcp2_shim *shim = hdcp->hdcp2_shim;
+	int ret;
+
+	ret = hdcp2_authentication_key_exchange(hdcp);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("AKE Failed. Err : %d\n", ret);
+		return ret;
+	}
+
+	ret = hdcp2_locality_check(hdcp);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("Locality Check failed. Err : %d\n", ret);
+		return ret;
+	}
+
+	ret = hdcp2_session_key_exchange(hdcp);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("SKE Failed. Err : %d\n", ret);
+		return ret;
+	}
+
+	if (!hdcp->is_repeater && shim->config_stream_type) {
+
+		/* Errata for DP: As Stream type is used for encryption,
+		 * Receiver should be communicated with stream type for the
+		 * decryption of the content.
+		 * Repeater will be communicated with stream type as a
+		 * part of it's auth in later in time
+		 */
+		stream_type_msg.msg_id = ERRATA_DP_STREAM_TYPE;
+		stream_type_msg.stream_type = hdcp->content_type;
+
+		ret = shim->config_stream_type(intel_dig_port, &stream_type_msg,
+					       sizeof(stream_type_msg));
+		if (ret < 0)
+			return ret;
+	}
+
+	hdcp->mei_hdcp_data->streams[0].stream_type = hdcp->content_type;
+	ret = hdcp2_authenticate_port(hdcp);
+	if (ret < 0)
+		return ret;
+
+	return ret;
+}
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-02-14 14:20 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 14:13 [PATCH 00/43] drm/i915: Implement HDCP2.2 Ramalingam C
2018-02-14 14:13 ` [PATCH 01/43] drm: hdcp2.2 authentication msg definitions Ramalingam C
2018-02-14 15:15   ` Winkler, Tomas
2018-02-14 19:40     ` Jani Nikula
2018-02-22  5:24       ` Ramalingam C
2018-02-22  5:29     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 02/43] drm: HDMI and DP specific HDCP2.2 defines Ramalingam C
2018-02-14 14:13 ` [PATCH 03/43] mei: bus: whitelist hdcp client Ramalingam C
2018-02-14 14:13 ` [PATCH 04/43] mei: me: add gemini lake devices ids Ramalingam C
2018-02-14 14:45   ` Winkler, Tomas
2018-02-22  5:22     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 05/43] misc/mei/hdcp: Client driver for HDCP application Ramalingam C
2018-02-14 14:54   ` Winkler, Tomas
2018-02-14 14:57     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 06/43] misc/mei/hdcp: Add KBuild for mei hdcp driver Ramalingam C
2018-02-14 14:54   ` Winkler, Tomas
2018-02-14 14:58     ` Ramalingam C
2018-02-28 15:43     ` Ramalingam C
2018-02-28 16:11       ` Winkler, Tomas
2018-02-14 14:13 ` [PATCH 07/43] misc/mei/hdcp: Verify mei client device status Ramalingam C
2018-02-14 14:13 ` [PATCH 08/43] misc/mei/hdcp: Get & Put for mei cl_device Ramalingam C
2018-02-14 14:13 ` [PATCH 09/43] misc/mei/hdcp: Define ME FW interface for HDCP2.2 Ramalingam C
2018-02-14 14:13 ` [PATCH 10/43] linux/mei: Header for mei_hdcp driver interface Ramalingam C
2018-02-14 14:13 ` [PATCH 11/43] misc/mei/hdcp: Initiate Wired HDCP2.2 Tx Session Ramalingam C
2018-02-14 14:13 ` [PATCH 12/43] misc/mei/hdcp: Verify Receiver Cert and prepare km Ramalingam C
2018-02-14 14:13 ` [PATCH 13/43] misc/mei/hdcp: Verify H_prime Ramalingam C
2018-02-14 14:13 ` [PATCH 14/43] misc/mei/hdcp: Store the HDCP Pairing info Ramalingam C
2018-02-14 14:13 ` [PATCH 15/43] misc/mei/hdcp: Initiate Locality check Ramalingam C
2018-02-14 14:13 ` [PATCH 16/43] misc/mei/hdcp: Verify L_prime Ramalingam C
2018-02-14 14:13 ` [PATCH 17/43] misc/mei/hdcp: Prepare Session Key Ramalingam C
2018-02-14 14:13 ` [PATCH 18/43] misc/mei/hdcp: Repeater topology verifcation and ack Ramalingam C
2018-02-14 14:13 ` [PATCH 19/43] misc/mei/hdcp: Verify M_prime Ramalingam C
2018-02-14 14:13 ` [PATCH 20/43] misc/mei/hdcp: Enabling the HDCP authentication Ramalingam C
2018-02-14 14:13 ` [PATCH 21/43] misc/mei/hdcp: Closing wired HDCP2.2 Tx Session Ramalingam C
2018-02-14 14:13 ` [PATCH 22/43] drm/i915: Async execution of hdcp authentication Ramalingam C
2018-02-22 14:39   ` Sean Paul
2018-02-26  6:32     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 23/43] drm/i915: wrapping all hdcp var into intel_hdcp Ramalingam C
2018-02-22 14:47   ` Sean Paul
2018-02-26  6:05     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 24/43] drm/i915: wait for cp_irq Ramalingam C
2018-02-22 15:46   ` Sean Paul
2018-02-26  5:49     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 25/43] drm/i915: Define HDCP2.2 related variables Ramalingam C
2018-02-14 14:36   ` Chris Wilson
2018-02-14 14:56     ` Ramalingam C
2018-02-22 14:59   ` Sean Paul
2018-02-26  5:46     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 26/43] drm/i915: Define Intel HDCP2.2 registers Ramalingam C
2018-02-22 15:43   ` Sean Paul
2018-02-26  5:33     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 27/43] drm/i915: Wrappers for mei HDCP2.2 services Ramalingam C
2018-02-14 14:13 ` Ramalingam C [this message]
2018-02-14 14:13 ` [PATCH 29/43] drm/i915: Implement HDCP2.2 repeater authentication Ramalingam C
2018-02-14 14:13 ` [PATCH 30/43] drm/i915: Enable and Disable HDCP2.2 port encryption Ramalingam C
2018-02-14 14:38   ` Chris Wilson
2018-02-14 14:52     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 31/43] drm/i915: Implement HDCP2.2 En/Dis-able Ramalingam C
2018-02-14 14:13 ` [PATCH 32/43] drm/i915: Implement HDCP2.2 link integrity check Ramalingam C
2018-02-14 14:13 ` [PATCH 33/43] drm/i915: Handle HDCP2.2 downstream topology change Ramalingam C
2018-02-14 14:13 ` [PATCH 34/43] drm/i915: Pullout the bksv read and validation Ramalingam C
2018-02-14 14:13 ` [PATCH 35/43] drm/i915: Enable HDCP version that is best capable Ramalingam C
2018-02-14 14:42   ` Chris Wilson
2018-02-14 14:51     ` Ramalingam C
2018-02-14 15:00       ` Chris Wilson
2018-02-14 15:00         ` Ramalingam C
2018-02-14 14:13 ` [PATCH 36/43] drm/i915: Enable HDCP1.4 incase of HDCP2.2 failure Ramalingam C
2018-02-14 14:13 ` [PATCH 37/43] drm/i915: Initialize HDCP2.2 and its MEI interface Ramalingam C
2018-02-14 14:45   ` Chris Wilson
2018-02-14 14:45     ` Ramalingam C
2018-02-14 14:13 ` [PATCH 38/43] drm/i915: Implement gmbus burst read Ramalingam C
2018-02-14 14:13 ` [PATCH 39/43] drm/i915: Implement the HDCP2.2 support for DP Ramalingam C
2018-02-14 14:13 ` [PATCH 40/43] drm/i915: Implement the HDCP2.2 support for HDMI Ramalingam C
2018-02-14 14:13 ` [PATCH 41/43] drm/i915: Add HDCP2.2 support for DP connectors Ramalingam C
2018-02-14 14:13 ` [PATCH 42/43] drm/i915: Add HDCP2.2 support for HDMI connectors Ramalingam C
2018-02-14 14:13 ` [PATCH 43/43] drm/i915: Invoke check link on CP_IRQ of DP Ramalingam C
2018-02-14 15:07 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Implement HDCP2.2 Patchwork
2018-02-14 15:13 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-02-14 15:20 ` ✗ Fi.CI.BAT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518617638-21684-29-git-send-email-ramalingam.c@intel.com \
    --to=ramalingam.c@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=seanpaul@chromium.org \
    --cc=tomas.winkler@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox