diff --git a/src/tpm2/NVMarshal.c b/src/tpm2/NVMarshal.c index 85cb98c6..8e26063f 100644 --- a/src/tpm2/NVMarshal.c +++ b/src/tpm2/NVMarshal.c @@ -3565,7 +3565,7 @@ static const struct _entry { { COMPILE_CONSTANT(ALG_CBC, EQ) }, { COMPILE_CONSTANT(ALG_CFB, EQ) }, { COMPILE_CONSTANT(ALG_ECB, EQ) }, - { COMPILE_CONSTANT(MAX_RSA_KEY_BITS, EQ) }, + { COMPILE_CONSTANT(MAX_RSA_KEY_BITS, LE) }, /* old: 2048 */ { COMPILE_CONSTANT(MAX_TDES_KEY_BITS, EQ) }, { COMPILE_CONSTANT(MAX_AES_KEY_BITS, EQ) }, { COMPILE_CONSTANT(128, EQ) }, /* MAX_SM4_KEY_BITS in older code was 128 also with SM4 not active */ diff --git a/src/tpm2/TpmProfile.h b/src/tpm2/TpmProfile.h index feffbd75..22d91af5 100644 --- a/src/tpm2/TpmProfile.h +++ b/src/tpm2/TpmProfile.h @@ -277,7 +277,9 @@ #define MAX_CAP_BUFFER 1024 #endif #ifndef NV_MEMORY_SIZE -#define NV_MEMORY_SIZE (128 * 1024) /* libtpms changed */ +/* libtmps: 65 OBJECTs in USER NVRAM expanded by 704 bytes due to size + * increase of OBJECT from 2048 bit RSA keys to 3072 bit by 704 bytes*/ +#define NV_MEMORY_SIZE (128 * 1024 + 65 * 704) /* libtpms changed */ #endif #ifndef MIN_COUNTER_INDICES #define MIN_COUNTER_INDICES 8 @@ -469,7 +471,7 @@ #define RSA_2048 (ALG_RSA && YES) #endif #ifndef RSA_3072 -#define RSA_3072 (ALG_RSA && NO) +#define RSA_3072 (ALG_RSA && YES) #endif #ifndef RSA_4096 #define RSA_4096 (ALG_RSA && NO) diff --git a/src/tpm2/Unmarshal.c b/src/tpm2/Unmarshal.c index 7f3928e1..6e3002a3 100644 --- a/src/tpm2/Unmarshal.c +++ b/src/tpm2/Unmarshal.c @@ -3461,6 +3461,7 @@ TPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *siz switch (*target) { case 1024: case 2048: + case 3072: break; default: rc = TPM_RC_VALUE; diff --git a/tests/nvram_offsets.c b/tests/nvram_offsets.c index 16ec241b..d1cdef86 100644 --- a/tests/nvram_offsets.c +++ b/tests/nvram_offsets.c @@ -59,16 +59,22 @@ int main(void) * size of the OBJECT is the same on all architectures so that a full * NVRAM fits on all architectures */ -#define OBJECT_EXP_SIZE 1896 +#if RSA_4096 +# error Unsuported RSA key size +#elif RSA_3072 +# define OBJECT_EXP_SIZE 2600 +#elif RSA_2048 +# define OBJECT_EXP_SIZE 1896 +#endif if (sizeof(OBJECT) != OBJECT_EXP_SIZE) { fprintf(stderr, "sizeof(OBJECT) does not have expected size of %u bytes" "but %zu bytes\n", OBJECT_EXP_SIZE, sizeof(OBJECT)); fprintf(stderr, "sizeof(TPMT_PUBLIC) is now %zu bytes;" - "was 356 bytes for 2048 bit RSA keys\n", sizeof(TPMT_PUBLIC)); + "was 356/484 bytes for 2048/3072 bit RSA keys\n", sizeof(TPMT_PUBLIC)); fprintf(stderr, "sizeof(TPMT_SENSITIVE) is now %zu bytes;" - "was 776 bytes for 2048 bit RSA keys\n", sizeof(TPMT_SENSITIVE)); + "was 776/1096 bytes for 2048/3072 bit RSA keys\n", sizeof(TPMT_SENSITIVE)); fprintf(stderr, "sizeof(privateExponent_t) is now %zu bytes;" - "was 608 bytes for 2048 bit RSA keys\n", sizeof(privateExponent_t)); + "was 608/864 bytes for 2048/3072 bit RSA keys\n", sizeof(privateExponent_t)); return EXIT_FAILURE; } diff --git a/tests/tpm2_createprimary.sh b/tests/tpm2_createprimary.sh index 2fa7e45c..a95ce63a 100755 --- a/tests/tpm2_createprimary.sh +++ b/tests/tpm2_createprimary.sh @@ -24,7 +24,7 @@ rc=$? fs=$(get_filesize NVChip) [ $? -ne 0 ] && exit 1 -if [ $fs -ne 131072 ]; then +if [ $fs -ne 176832 ]; then echo "Error: Unexpected size of NVChip file." echo "Expected: 131072" echo "Got : $fs" diff --git a/tests/tpm2_pcr_read.sh b/tests/tpm2_pcr_read.sh index 08c2b86c..f2dbe6e3 100755 --- a/tests/tpm2_pcr_read.sh +++ b/tests/tpm2_pcr_read.sh @@ -24,7 +24,7 @@ rc=$? fs=$(get_filesize NVChip) [ $? -ne 0 ] && exit 1 -if [ $fs -ne 131072 ]; then +if [ $fs -ne 176832 ]; then echo "Error: Unexpected size of NVChip file." echo "Expected: 131072" echo "Got : $fs" diff --git a/tests/tpm2_selftest.sh b/tests/tpm2_selftest.sh index 6e514651..c06d7655 100755 --- a/tests/tpm2_selftest.sh +++ b/tests/tpm2_selftest.sh @@ -24,7 +24,7 @@ rc=$? fs=$(get_filesize NVChip) [ $? -ne 0 ] && exit 1 -if [ $fs -ne 131072 ]; then +if [ $fs -ne 176832 ]; then echo "Error: Unexpected size of NVChip file." echo "Expected: 131072" echo "Got : $fs"