summaryrefslogtreecommitdiff
path: root/board/cr50/u2f.c
diff options
context:
space:
mode:
authorLouis Collard <louiscollard@chromium.org>2019-10-18 17:31:38 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-24 14:54:33 +0000
commit39f7d5d0e5c3ae72b9837a676fac401dfe51e745 (patch)
tree9bd2804f8111cf00d814136c6fc4086421eb52a3 /board/cr50/u2f.c
parent82064ca887f74b6f4a424dd9ec228c28478560a4 (diff)
downloadchrome-ec-39f7d5d0e5c3ae72b9837a676fac401dfe51e745.tar.gz
cr50: Add dummy U2F_ADPU vendor command.
This command is called by u2fd in M77 on startup, and if a success response is not returned, u2fd will not start up or send commands. We need to support M77 in newer cr50 versions, due to the enterprise rollback feature. cr50 has been updated to not require these commands to be sent, so the dummy command here does nothing other than return success. BUG=b:133275654 TEST=flash M77 and ToT cr50 with this change, check u2fd starts up and works BRANCH=none Signed-off-by: Louis Collard <louiscollard@chromium.org> Change-Id: Ie1576f582df6c3a076a8b9a3cbc7101fb05204b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1869172 Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'board/cr50/u2f.c')
-rw-r--r--board/cr50/u2f.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/board/cr50/u2f.c b/board/cr50/u2f.c
index 6d186ae2bd..b99722e48f 100644
--- a/board/cr50/u2f.c
+++ b/board/cr50/u2f.c
@@ -290,3 +290,59 @@ int u2f_gen_kek_seed(int commit)
return EC_SUCCESS;
}
+
+/*
+ * We need to keep a dummy version of this function around, as u2fd on M77 will
+ * call it and not start up or send commands unless it receives a success
+ * response. cr50 has been updated to no longer require the commands being sent,
+ * so we don't need to do anything other than return a valid success response.
+ */
+static enum vendor_cmd_rc vc_u2f_apdu_dummy(enum vendor_cmd_cc code, void *body,
+ size_t cmd_size,
+ size_t *response_size)
+{
+ uint8_t *cmd = body;
+
+ if (cmd_size < 3)
+ return VENDOR_RC_BOGUS_ARGS;
+
+ /*
+ * The incoming APDUs are in the following format:
+ *
+ * CLA INS P1 P2 Le
+ * 00 <ins> ?? ?? ??
+ */
+
+ if (cmd[1] == 0xbf /* U2F_VENDOR_MODE */) {
+ /*
+ * The u2fd code that call this command expects confirmation
+ * that the mode was correctly set in the return message.
+ *
+ * The incoming APDU is in the following format:
+ *
+ * CLA INS P1 P2 Le
+ * 00 bf 01 <mode> 00
+ */
+ cmd[0] = cmd[3];
+ } else if (cmd[1] == 0x03 /* U2F_VERSION */) {
+ /*
+ * The returned value for U2F_VERSION is not checked; return
+ * a known string just to be safe.
+ */
+ cmd[0] = '2';
+ } else {
+ /* We're not expecting any other commands. */
+ *response_size = 0;
+ return VENDOR_RC_NO_SUCH_SUBCOMMAND;
+ }
+
+ /*
+ * Return U2F_SW_NO_ERROR status.
+ */
+ cmd[1] = 0x90;
+ cmd[2] = 0x00;
+ *response_size = 3;
+
+ return VENDOR_RC_SUCCESS;
+}
+DECLARE_VENDOR_COMMAND(VENDOR_CC_U2F_APDU, vc_u2f_apdu_dummy);