Skip to content

Commit

Permalink
ima: fix 'd-ng' comments and documentation
Browse files Browse the repository at this point in the history
Initially the 'd-ng' template field did not prefix the digest with either
"md5" or "sha1" hash algorithms.  Prior to being upstreamed this changed,
but the comments and documentation were not updated.  Fix the comments
and documentation.

Fixes: 4d7aeee ("ima: define new template ima-ng and template fields d-ng and n-ng")
Reported-by: Eric Biggers <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Signed-off-by: Mimi Zohar <[email protected]>
  • Loading branch information
mimizohar committed May 1, 2022
1 parent 891163a commit 6446646
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Documentation/security/IMA-templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ descriptors by adding their identifier to the format string
calculated with the SHA1 or MD5 hash algorithm;
- 'n': the name of the event (i.e. the file name), with size up to 255 bytes;
- 'd-ng': the digest of the event, calculated with an arbitrary hash
algorithm (field format: [<hash algo>:]digest, where the digest
prefix is shown only if the hash algorithm is not SHA1 or MD5);
algorithm (field format: <hash algo>:digest);
- 'd-modsig': the digest of the event without the appended modsig;
- 'n-ng': the name of the event, without size limitations;
- 'sig': the file signature, or the EVM portable signature if the file
Expand Down
8 changes: 5 additions & 3 deletions security/integrity/ima/ima_template_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
/*
* digest formats:
* - DATA_FMT_DIGEST: digest
* - DATA_FMT_DIGEST_WITH_ALGO: [<hash algo>] + ':' + '\0' + digest,
* where <hash algo> is provided if the hash algorithm is not
* SHA1 or MD5
* - DATA_FMT_DIGEST_WITH_ALGO: <hash algo> + ':' + '\0' + digest,
*
* where 'DATA_FMT_DIGEST' is the original digest format ('d')
* with a hash size limitation of 20 bytes,
* where <hash algo> is the hash_algo_name[] string.
*/
u8 buffer[CRYPTO_MAX_ALG_NAME + 2 + IMA_MAX_DIGEST_SIZE] = { 0 };
enum data_formats fmt = DATA_FMT_DIGEST;
Expand Down

0 comments on commit 6446646

Please sign in to comment.