Skip to content

Add support for V3 signatures for EVM & IMA for all supported key types#29

Open
stefanberger wants to merge 10 commits intolinux-integrity:next-testingfrom
stefanberger:v3-for-all-schemes
Open

Add support for V3 signatures for EVM & IMA for all supported key types#29
stefanberger wants to merge 10 commits intolinux-integrity:next-testingfrom
stefanberger:v3-for-all-schemes

Conversation

@stefanberger
Copy link
Copy Markdown
Contributor

@stefanberger stefanberger commented Feb 27, 2026

This PR adds support for the V3 signatures for EVM & IMA for all supported key types. It implements a imaevm_create_sigv3() library function that takes the file hash as input and creates the hash of the ima_file_id needed for V3 signatures.

Add a few test cases for V3 signature creation and verification to sign_verify.test.

Later on, inside this function, we will check whether the signing key is an ML-DSA key and pass the ima_file_id structure to ML-DSA pure-mode signing saving the cycles for hashing this structure. Avoiding the hashing here will also save cycles when being able to avoid the hashing upon signature verification in Linux IMA.

Signature verification of V3 signatures is already supported in imaevm_verify_hash() through fsverify's V3 signature support.

@stefanberger stefanberger force-pushed the v3-for-all-schemes branch 3 times, most recently from e72e058 to 7d62b78 Compare March 1, 2026 05:21
@stefanberger stefanberger changed the title Add support for V3 signatures for IMA for all supported key types Add support for V3 signatures for EVM & IMA for all supported key types Mar 1, 2026
xattr_type = EVM_IMA_XATTR_DIGSIG;

if (evm_immutable)
sig[1] = 3; /* immutable signature version */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why this was '3'.

@stefanberger stefanberger force-pushed the v3-for-all-schemes branch 2 times, most recently from 779d7d2 to b31cbaa Compare March 6, 2026 14:07
@stefanberger stefanberger force-pushed the v3-for-all-schemes branch 2 times, most recently from c0fbd1e to 8a6d276 Compare March 12, 2026 19:59
@stefanberger stefanberger force-pushed the v3-for-all-schemes branch 2 times, most recently from 109314f to b765770 Compare March 24, 2026 16:09
Use EVP_PKEY_free to fix a memory leak that occurs when using free() on the
key field of public_key_entry that is a pointer to an EVP_PKEY.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Avoid a memory leak of a public_key_entry if the passed public_keys
pointer is NULL because in this case the entry is lost. For this particular
case to work we would need public keys to be passed in as
'struct public_key_entry **public_keys' so that '*public_keys = entry'
could be assign. However, this change would propagate all the way to the
API of the library and we don't want to change existing functions'
signature.

This change should not have any noticeable side-effect since the resolved
case did not work before but the newly allocated entry was lost.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Implement imaevm_create_sigv3 that creates v3 signatures. This function
will now also allocate a buffer if the caller did not provide one.
Further, it will write the full signature into the signature buffer,
including the leading xattr type byte.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Add support for creating IMA signatures with the V3 signing scheme.
Introduce a global variable that states which signing scheme to
use and for now set it to SIGNATURE_V2. Implement the SIGNATURE_V3
case where necessary for IMA.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Add support for creating EVM signatures with the V3 signing scheme.
Implement the SIGNATURE_v3 case where necessary for EVM.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Enable both IMA and EVM file signatures with a new --v3 option that sets
the previously introduced global variable that states which signature
version to use.

Similarly, introduce a --v2 option for users to (already) choose old V2
type of signatures.

Update the README with the dump of the evmctl help screen and mention
v3 signature format that is expected for Linux 7.1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Convert the code that built the fsverity signature with V3 signing scheme
to use the new imaevm_create_sigv3 function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Add the new --v3 option to the sign_verify test cases.

For --v3, adjust openssl signature verification to build an ima_file_id
structure in a file that is then used for signature verification rather
than the plain file (as before).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
To enable sigv3 signature verification for EVM portable signatures, allow
signature verification on EVM_XATTR_PORTABLE_DIGSIG type of xattrs
with sigv3.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
To enable sigv3 for EVM portable signatures, enable hashing for sigv3 for
EVM_XATTR_PORTABLE_DIGSIG.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant