2 * Copyright (C) 2016 The Android Open Source Project
4 * SPDX-License-Identifier: MIT
7 #include "avb_footer.h"
10 bool avb_footer_validate_and_byteswap(const AvbFooter* src, AvbFooter* dest) {
11 avb_memcpy(dest, src, sizeof(AvbFooter));
13 dest->version_major = avb_be32toh(dest->version_major);
14 dest->version_minor = avb_be32toh(dest->version_minor);
16 dest->original_image_size = avb_be64toh(dest->original_image_size);
17 dest->vbmeta_offset = avb_be64toh(dest->vbmeta_offset);
18 dest->vbmeta_size = avb_be64toh(dest->vbmeta_size);
20 /* Check that magic is correct. */
21 if (avb_safe_memcmp(dest->magic, AVB_FOOTER_MAGIC, AVB_FOOTER_MAGIC_LEN) !=
23 avb_error("Footer magic is incorrect.\n");
27 /* Ensure we don't attempt to access any fields if the footer major
28 * version is not supported.
30 if (dest->version_major > AVB_FOOTER_VERSION_MAJOR) {
31 avb_error("No support for footer version.\n");