]> git.proxmox.com Git - libtpms.git/blobdiff - src/tpm_tpm12_interface.c
Support a range of 3k to 4k for TPM 1.2 buffer size
[libtpms.git] / src / tpm_tpm12_interface.c
index d0696f733f9827eaab9942837531564c801a44c5..bc9d9838d00498b8e5716b3baac53c0a3d9061df 100644 (file)
@@ -165,16 +165,33 @@ TPM_RESULT TPM12_GetTPMProperty(enum TPMLIB_TPMProperty prop,
     return TPM_SUCCESS;
 }
 
+static uint32_t tpm12_buffersize = TPM_BUFFER_MAX;
+
 uint32_t TPM12_SetBufferSize(uint32_t wanted_size,
                              uint32_t *min_size,
                              uint32_t *max_size)
 {
-    /* TPM 1.2 has a fixed buffer size; the TIS can handle that */
+    if (wanted_size == 0)
+        return tpm12_buffersize;
+
     if (min_size)
-        *min_size = TPM_BUFFER_MAX;
+        *min_size = TPM_BUFFER_MIN;
     if (max_size)
         *max_size = TPM_BUFFER_MAX;
-    return TPM_BUFFER_MAX;
+
+    if (wanted_size > TPM_BUFFER_MAX)
+        wanted_size = TPM_BUFFER_MAX;
+    else if (wanted_size < TPM_BUFFER_MIN)
+        wanted_size = TPM_BUFFER_MIN;
+
+    tpm12_buffersize = wanted_size;
+
+    return tpm12_buffersize;
+}
+
+uint32_t TPM12_GetBufferSize(void)
+{
+    return TPM12_SetBufferSize(0, NULL, NULL);
 }
 
 const struct tpm_interface TPM12Interface = {