|
6 | 6 | #include <linux/slab.h>
|
7 | 7 | #include <linux/audit.h>
|
8 | 8 | #include <linux/types.h>
|
9 |
| -#include <crypto/hash.h> |
| 9 | +#include <crypto/sha2.h> |
10 | 10 |
|
11 | 11 | #include "ipe.h"
|
12 | 12 | #include "eval.h"
|
|
17 | 17 |
|
18 | 18 | #define ACTSTR(x) ((x) == IPE_ACTION_ALLOW ? "ALLOW" : "DENY")
|
19 | 19 |
|
20 |
| -#define IPE_AUDIT_HASH_ALG "sha256" |
| 20 | +#define IPE_AUDIT_HASH_ALG "sha256" /* keep in sync with audit_policy() */ |
21 | 21 |
|
22 | 22 | #define AUDIT_POLICY_LOAD_FMT "policy_name=\"%s\" policy_version=%hu.%hu.%hu "\
|
23 | 23 | "policy_digest=" IPE_AUDIT_HASH_ALG ":"
|
@@ -182,37 +182,14 @@ static void audit_policy(struct audit_buffer *ab,
|
182 | 182 | const char *audit_format,
|
183 | 183 | const struct ipe_policy *const p)
|
184 | 184 | {
|
185 |
| - SHASH_DESC_ON_STACK(desc, tfm); |
186 |
| - struct crypto_shash *tfm; |
187 |
| - u8 *digest = NULL; |
| 185 | + u8 digest[SHA256_DIGEST_SIZE]; |
188 | 186 |
|
189 |
| - tfm = crypto_alloc_shash(IPE_AUDIT_HASH_ALG, 0, 0); |
190 |
| - if (IS_ERR(tfm)) |
191 |
| - return; |
192 |
| - |
193 |
| - desc->tfm = tfm; |
194 |
| - |
195 |
| - digest = kzalloc(crypto_shash_digestsize(tfm), GFP_KERNEL); |
196 |
| - if (!digest) |
197 |
| - goto out; |
198 |
| - |
199 |
| - if (crypto_shash_init(desc)) |
200 |
| - goto out; |
201 |
| - |
202 |
| - if (crypto_shash_update(desc, p->pkcs7, p->pkcs7len)) |
203 |
| - goto out; |
204 |
| - |
205 |
| - if (crypto_shash_final(desc, digest)) |
206 |
| - goto out; |
| 187 | + sha256(p->pkcs7, p->pkcs7len, digest); |
207 | 188 |
|
208 | 189 | audit_log_format(ab, audit_format, p->parsed->name,
|
209 | 190 | p->parsed->version.major, p->parsed->version.minor,
|
210 | 191 | p->parsed->version.rev);
|
211 |
| - audit_log_n_hex(ab, digest, crypto_shash_digestsize(tfm)); |
212 |
| - |
213 |
| -out: |
214 |
| - kfree(digest); |
215 |
| - crypto_free_shash(tfm); |
| 192 | + audit_log_n_hex(ab, digest, sizeof(digest)); |
216 | 193 | }
|
217 | 194 |
|
218 | 195 | /**
|
|
0 commit comments