This source file includes following definitions.
- verify_sha256_digest
1
2
3
4
5
6
7
8
9
10 #include <linux/kexec.h>
11 #include <linux/string.h>
12 #include <crypto/sha.h>
13 #include <asm/purgatory.h>
14
15 int verify_sha256_digest(void)
16 {
17 struct kexec_sha_region *ptr, *end;
18 u8 digest[SHA256_DIGEST_SIZE];
19 struct sha256_state sctx;
20
21 sha256_init(&sctx);
22 end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions);
23
24 for (ptr = purgatory_sha_regions; ptr < end; ptr++)
25 sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len);
26
27 sha256_final(&sctx, digest);
28
29 if (memcmp(digest, purgatory_sha256_digest, sizeof(digest)))
30 return 1;
31
32 return 0;
33 }