Commit Graph

23 Commits

Author SHA1 Message Date
Stefan Berger
ecff064e8d tpm2: Implement check to disable ECC key derivation: no-ecc-key-derivation
Per "TCG FIPS 140-3 guidance for TPM 2.0" document the following functions
must prevent an asymmetric ECC key derivation:
- Table 14: TPM2_CreateLoaded
- Table 18: TPM2_ZGen_2Phase
- Table 26: TPM2_Commit
- Table 26: TPM2_EC_Ephemeral

Return TPM_RC_TYPE as a return code to indicate failure of deriving a key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-10-15 11:56:24 -04:00
Stefan Berger
4b89a028dd rev180: Sync whitespace changes and changes to comments
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2024-07-29 11:25:31 -04:00
Stefan Berger
a5977d2018 rev180: Add hierarchy field to OBJECT and use it
Add new field hierarchy to OBJECT and assign values to it and access it.

Beyond the sync with upstream we need to also set the hierachy when
- an older OBJECT is converted to the current OBJECT
- an OBJECT is unmarshalled

Remove ObjectGetHierarchy since it is not needed anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-07-25 11:17:42 -04:00
Stefan Berger
a848c37b7b tpm2: Implement RuntimeProfileGetSeedCompatLevel()
The maximum SEED_COMPAT_LEVEL that libtpms may use depends on the earliest
version of libtpms that a profile can run on. Therefore, implement
RuntimeProfileGetSeedCompatLevel() to determine the SEED_COMPAT_LEVEL that
a profile can use, which depends on the profile's stateCompatLevel (which
in turn depends on the version of libtpms)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-07-15 11:51:38 -04:00
Stefan Berger
5ad0256d1a rev180: Sync comment and whitespace changes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-02-27 12:18:03 -05:00
Stefan Berger
ccd3fd8f9e rev180: Sync usage of DRBG_Uninstantiate (where missing)
Add calls to DRBG_Uninstantiate where it was missing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-03 20:23:19 -05:00
Stefan Berger
a0a48464ac rev180: Add (unused) parameter to PublicAttributesValidation
Add yet unused parameter 'primaryHierarchy to PublicAttributesValidation.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-03 20:23:19 -05:00
Stefan Berger
b3a00577e8 rev180: Add HierarchyNormalizeHandle and use it
Add a simplified version of HierarchyNormalizeHandle that simply returns
the passed handle and sync the callers with upstream.
HierarchyNormalizeHandle will be extended at some later point.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-03 20:23:19 -05:00
Stefan Berger
eb38a9d822 rev180: Return TPM_RC from HierarchyGetProof/PrimarySeed & adjust callchain
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-03 20:23:19 -05:00
Stefan Berger
f01c9776f5 rev180: Sync whitespace, comment and trivial changes
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-03 20:23:19 -05:00
Stefan Berger
9137a773d8 rev164: Change AGL_XYZ_VALUE to equivalend TPM_ALG_XYZ
$ grep -En "ALG_[A-Z]*_VALUE" src/tpm2/TpmTypes.h
71:#define     ALG_ERROR_VALUE             0x0000
72:#define TPM_ALG_ERROR                   (TPM_ALG_ID)(ALG_ERROR_VALUE)
73:#define     ALG_RSA_VALUE               0x0001
74:#define TPM_ALG_RSA                     (TPM_ALG_ID)(ALG_RSA_VALUE)
[...]

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-19 15:59:52 -04:00
Stefan Berger
232b00cef4 tpm2: rev162: Rename MAX_DERIVATION_BITS to TPM_MAX_DERIVATION_BITS
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-05-27 07:45:29 -04:00
Stefan Berger
fb94dadeca tpm2: Rename TPM_MAX_DERIVATION_BITS to MAX_DERIVATION_BITS
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
2296a4dd2a tpm2: Comments and whitespace changes only
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
b546847a17 tpm2: sync svn 1490; whitespace and comment changes only
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
4903a423ea tpm2: Pass SEED_COMPAT_LEVEL to Object for use when deriving keys
When a child key is derived from an Object, we need to know what
SEED_COMPAT_LEVEL the Object was created under (or what the its seed is)
so that we can later on derive child with the appropriate
SEED_COMPAT_LEVEL.

When an external object is loaded we set the SEED_COMPAT_LEVEL to
SEED_COMPAT_LEVEL_ORIGINAL so that any RSA key that could possibly be
derived from it will always create the same RSA key independent
of the SEED_COMPAT_LEVEL of the hierarchy it is loaded under. This
way any key derivation that could happen on an external key remains
the same before and after this code change.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
c97d016d27 tpm2: Add SEED_COMPAT_LEVEL to DRBG state
Add a SEED_COMPAT_LEVEL to the DRBG state that is associated with the seed
and indicates the seed compatibility level we need to maintain when deriving
RSA keys from seeds. We only need to be able to handle RSA keys derived via
the DRBG state. Other keys, such as symmetric keys, are not affected. Also
RSA keys cannot be derived from a KDR, so the KDF does not need to carry
the SEED_COMPAT_LEVEL.

All functions that need to pass a value set SEED_COMPAT_LEVEL to
SEED_COMPAT_LEVEL_ORIGINAL (0) for now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
f4316a7011 tpm2: rev155: Consider return value of DRBG_InstantiateSeeded
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
110bb0ea8d tpm2: rev155: Change parameter to SensitivetoPrivate to TPM2B_NAME 2020-04-14 16:03:45 -04:00
Stefan Berger
9ccad78596 tpm2: Initialize variable to address valgrind complaint
This patch addresses the following valgrind issue detetcted by swtpm test suite:

== Syscall param write(buf) points to uninitialised byte(s)
==3515669==    at 0x4DC14B7: write (in /usr/lib64/libc-2.30.so)
==3515669==    by 0x48547FB: write_full (utils.c:242)
==3515669==    by 0x48548F3: writev_full (utils.c:301)
==3515669==    by 0x48520A6: SWTPM_IO_Write (swtpm_io.c:229)
==3515669==    by 0x4850662: mainLoop (mainloop.c:282)
==3515669==    by 0x402BE7: swtpm_main (swtpm.c:497)
==3515669==    by 0x4CF61A2: (below main) (in /usr/lib64/libc-2.30.so)
==3515669==  Address 0x52413a2 is 34 bytes inside a block of size 2,006 alloc'd
==3515669==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==3515669==    by 0x48548A1: writev_full (utils.c:287)
==3515669==    by 0x48520A6: SWTPM_IO_Write (swtpm_io.c:229)
==3515669==    by 0x4850662: mainLoop (mainloop.c:282)
==3515669==    by 0x402BE7: swtpm_main (swtpm.c:497)
==3515669==    by 0x4CF61A2: (below main) (in /usr/lib64/libc-2.30.so)
==3515669==  Uninitialised value was created by a stack allocation
==3515669==    at 0x4953993: TPM2_Load (ObjectCommands.c:132)
==3515669==

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-01-10 08:34:27 -05:00
Stefan Berger
16ec2970d7 rev148: Replace #ifdef TPM_CC_* with #if CC_*
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
992a5bfad8 Upgrade from rev 142 to rev 146
This is the diff patch between rev 142 and 146.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00
Stefan Berger
ccce8b5f49 Add TPM 2 code
Add TPM 2 code.

This is rev. 142 code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-06-15 18:07:47 -04:00