]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tpm: export tpm2_flush_context_cmd
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 26 Nov 2016 11:39:35 +0000 (13:39 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 3 Apr 2017 19:46:01 +0000 (22:46 +0300)
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm2-cmd.c

index 4937b56a275cf28a90d4f96789ee94b541caf54f..08c1f61d396fdf86b91958f40b815e7698297fd5 100644 (file)
@@ -541,6 +541,8 @@ int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
 int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, u32 count,
                    struct tpm2_digest *digests);
 int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max);
+void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
+                           unsigned int flags);
 int tpm2_seal_trusted(struct tpm_chip *chip,
                      struct trusted_key_payload *payload,
                      struct trusted_key_options *options);
index 881aea9732bf1805d2c41a2ce6e218286bab335a..620a27b0412b773e8cb17c6b4e10f8449cec16f8 100644 (file)
@@ -418,6 +418,35 @@ static const struct tpm_input_header tpm2_get_tpm_pt_header = {
        .ordinal = cpu_to_be32(TPM2_CC_GET_CAPABILITY)
 };
 
+/**
+ * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
+ * @chip: TPM chip to use
+ * @payload: the key data in clear and encrypted form
+ * @options: authentication values and other options
+ *
+ * Return: same as with tpm_transmit_cmd
+ */
+void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
+                           unsigned int flags)
+{
+       struct tpm_buf buf;
+       int rc;
+
+       rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_FLUSH_CONTEXT);
+       if (rc) {
+               dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n",
+                        handle);
+               return;
+       }
+
+       tpm_buf_append_u32(&buf, handle);
+
+       (void) tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, flags,
+                               "flushing context");
+
+       tpm_buf_destroy(&buf);
+}
+
 /**
  * tpm_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer.
  *
@@ -627,39 +656,6 @@ out:
        return rc;
 }
 
-/**
- * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
- *
- * @chip: TPM chip to use
- * @handle: the key data in clear and encrypted form
- * @flags: tpm transmit flags
- *
- * Return: Same as with tpm_transmit_cmd.
- */
-static void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
-                                  unsigned int flags)
-{
-       struct tpm_buf buf;
-       int rc;
-
-       rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_FLUSH_CONTEXT);
-       if (rc) {
-               dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n",
-                        handle);
-               return;
-       }
-
-       tpm_buf_append_u32(&buf, handle);
-
-       rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, flags,
-                             "flushing context");
-       if (rc)
-               dev_warn(&chip->dev, "0x%08x was not flushed, rc=%d\n", handle,
-                        rc);
-
-       tpm_buf_destroy(&buf);
-}
-
 /**
  * tpm2_unseal_cmd() - execute a TPM2_Unload command
  *