Commit Graph

8 Commits

Author SHA1 Message Date
Stefan Berger
d4be04707e rev180: Add new function to generate RSA primes (StateFormatLevel 9)
Some time around rev169 a new function to generate RSA prime numbers was
introduced. Use this function for a 'new' SEED_COMPAT_LEVEL_LAST that now
gets value '2'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-06-12 11:21:38 -04:00
Dan Streetman
e814a1c731 tpm2: Enable support for 4096 bit RSA keys (with fixes)
- Enable RSA_4096
- Add RSA_4096 to s_KeySizesRSA at stateFormatLevel 8
- Increase STATE_FORMAT_LEVEL_CURRENT to 8
- Update tests for larger object size and increased StateFormatLevel
- In NVMarshal.c replace MAX_RSA_KEY_BITS with old value 3072
  so that the state is acceptable to older versions of libtpms;
  if we wrote 4096, then older versions of libtpms would reject the
  state.
- In NVMarshal.c replace RSA_4096 with '0' so it is acceptable to older
  versions; if we wrote '1', then older versions of libtpms would reject
  the state.

Fixes: #491

Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-05-07 12:23:44 -04:00
Stefan Berger
f756952283 Revert "tpm2: Enable support for 4096 bit RSA keys"
This reverts commit 63627b335e.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-05-07 11:45:36 -04:00
Dan Streetman
63627b335e tpm2: Enable support for 4096 bit RSA keys
- Enable RSA_4096
- Add RSA_4096 to s_KeySizesRSA at stateFormatLevel 8
- Increase STATE_FORMAT_LEVEL_CURRENT to 8
- Update tests for larger object size and increased StateFormatLevel

Fixes: #491

Signed-off-by: Dan Streetman <ddstreet@ieee.org>
2025-05-07 10:38:22 -04:00
Stefan Berger
fa4f9ab561 tests: Ignore gcc -Wmissing-braces on OBJECT initialization
Have gcc ignore -Wmissing-braces to suppress 15 of these types of
warnings:

/home/stefanb/dev/libtpms/tests/object_size.c:13:21: warning: missing braces around initializer [-Wmissing-braces] <--[gcc]
   13 |     OBJECT object = {
      |                     ^
/home/stefanb/dev/libtpms/tests/object_size.c:13:21: warning: missing braces around initializer [-Wmissing-braces] <--[gcc]
[...]

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-11-11 17:11:19 -05:00
Stefan Berger
18cffed604 tests: Use %zu for size_t
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-07-26 22:34:38 -04:00
Stefan Berger
1df35f6c77 tpm2: Change marshalled fields of OBJECT (StateFormatLevel 6)
Bump up the StateFormatLevel to 6 and use it to introduce a new OBJECT
marshalling format version '4' that slighly changes how an OBJECT is
marshalled:

- only marshal the private exponent for an RSA key
- always marshal the new hierarchy field

The marshalling code can still write previous version '3' when an older
StateFormatLevel is used to support backwards compatibility.

Adjust the test cases marshalling an RSA key OBJECT to check against
expected sizes across a series of StateFormatLevels.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-07-25 11:17:42 -04:00
Stefan Berger
bb4dafb1e7 tpm2: NVMarshal: Introduce MAX_MARSHALLED_OBJECT_SIZE
Introduce the #define MAX_MARSHALLED_OBJECT_SIZE to be used for a size of
a byte buffer that is supposed to hold a marshalled OBJECT. The number
is not exact but provides for a 'safe' size of a buffer.

Add a test case to check that MAX_MARSHALLED_OBJECT_SIZE is sufficient.
The test case needs access to ANY_OBJECT_Marshal, which is only available
when -static can be used for linking since otherwise the function is
private to the library. Static linking the test case does not work when
test-coverage is enabled, therefore disable statically linked test cases
in when test-coverage is enabled and give control to the user to disable
statically linked test cases in other cases as well.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-03-05 21:13:57 -05:00