1 // SPDX-License-Identifier: GPL-2.0
3 * Purgatory code running between two kernels.
5 * Copyright IBM Corp. 2018
7 * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
10 #include <linux/kexec.h>
11 #include <linux/string.h>
12 #include <crypto/sha.h>
13 #include <asm/purgatory.h>
15 int verify_sha256_digest(void)
17 struct kexec_sha_region
*ptr
, *end
;
18 u8 digest
[SHA256_DIGEST_SIZE
];
19 struct sha256_state sctx
;
22 end
= purgatory_sha_regions
+ ARRAY_SIZE(purgatory_sha_regions
);
24 for (ptr
= purgatory_sha_regions
; ptr
< end
; ptr
++)
25 sha256_update(&sctx
, (uint8_t *)(ptr
->start
), ptr
->len
);
27 sha256_final(&sctx
, digest
);
29 if (memcmp(digest
, purgatory_sha256_digest
, sizeof(digest
)))