Skip to content

Commit 6446646

Browse files
committed
ima: fix 'd-ng' comments and documentation
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 <ebiggers@kernel.org> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 891163a commit 6446646

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Documentation/security/IMA-templates.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ descriptors by adding their identifier to the format string
6666
calculated with the SHA1 or MD5 hash algorithm;
6767
- 'n': the name of the event (i.e. the file name), with size up to 255 bytes;
6868
- 'd-ng': the digest of the event, calculated with an arbitrary hash
69-
algorithm (field format: [<hash algo>:]digest, where the digest
70-
prefix is shown only if the hash algorithm is not SHA1 or MD5);
69+
algorithm (field format: <hash algo>:digest);
7170
- 'd-modsig': the digest of the event without the appended modsig;
7271
- 'n-ng': the name of the event, without size limitations;
7372
- 'sig': the file signature, or the EVM portable signature if the file

security/integrity/ima/ima_template_lib.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,11 @@ static int ima_eventdigest_init_common(const u8 *digest, u32 digestsize,
271271
/*
272272
* digest formats:
273273
* - DATA_FMT_DIGEST: digest
274-
* - DATA_FMT_DIGEST_WITH_ALGO: [<hash algo>] + ':' + '\0' + digest,
275-
* where <hash algo> is provided if the hash algorithm is not
276-
* SHA1 or MD5
274+
* - DATA_FMT_DIGEST_WITH_ALGO: <hash algo> + ':' + '\0' + digest,
275+
*
276+
* where 'DATA_FMT_DIGEST' is the original digest format ('d')
277+
* with a hash size limitation of 20 bytes,
278+
* where <hash algo> is the hash_algo_name[] string.
277279
*/
278280
u8 buffer[CRYPTO_MAX_ALG_NAME + 2 + IMA_MAX_DIGEST_SIZE] = { 0 };
279281
enum data_formats fmt = DATA_FMT_DIGEST;

0 commit comments

Comments
 (0)