mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 11:20:10 +01:00
FEC (Forward Error Correction) data should cover the whole data area, hashes (Merkle tree) and optionally additional metadata (located after hash area). Unfortunately, if FEC data is stored in the same file as hash, the calculation wrongly used the whole file size thus overlaps with FEC area itself. This produces unusable and too large FEC data. (There is not a problem if FEC image is a separate image.) This patch fixes the problem, introducing FEC blocks calculation as: -If hash device is in a separate image, metadata covers the whole rest of the image after hash area. (Unchanged behaviour.) -If hash and FEC device is in the image, metadata ends on the FEC area offset. This should probably fix several issues reported with FEC wrong calculations. Fixes: #554
81 lines
2.4 KiB
C
81 lines
2.4 KiB
C
/*
|
|
* dm-verity volume handling
|
|
*
|
|
* Copyright (C) 2012-2021 Red Hat, Inc. All rights reserved.
|
|
*
|
|
* This file is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This file is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this file; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#ifndef _VERITY_H
|
|
#define _VERITY_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define VERITY_MAX_HASH_TYPE 1
|
|
#define VERITY_BLOCK_SIZE_OK(x) ((x) % 512 || (x) < 512 || \
|
|
(x) > (512 * 1024) || (x) & ((x)-1))
|
|
|
|
struct crypt_device;
|
|
struct crypt_params_verity;
|
|
struct device;
|
|
|
|
int VERITY_read_sb(struct crypt_device *cd,
|
|
uint64_t sb_offset,
|
|
char **uuid,
|
|
struct crypt_params_verity *params);
|
|
|
|
int VERITY_write_sb(struct crypt_device *cd,
|
|
uint64_t sb_offset,
|
|
const char *uuid_string,
|
|
struct crypt_params_verity *params);
|
|
|
|
int VERITY_activate(struct crypt_device *cd,
|
|
const char *name,
|
|
const char *root_hash,
|
|
size_t root_hash_size,
|
|
const char *signature_description,
|
|
struct device *fec_device,
|
|
struct crypt_params_verity *verity_hdr,
|
|
uint32_t activation_flags);
|
|
|
|
int VERITY_verify(struct crypt_device *cd,
|
|
struct crypt_params_verity *verity_hdr,
|
|
const char *root_hash,
|
|
size_t root_hash_size);
|
|
|
|
int VERITY_create(struct crypt_device *cd,
|
|
struct crypt_params_verity *verity_hdr,
|
|
const char *root_hash,
|
|
size_t root_hash_size);
|
|
|
|
int VERITY_FEC_process(struct crypt_device *cd,
|
|
struct crypt_params_verity *params,
|
|
struct device *fec_device,
|
|
int check_fec,
|
|
unsigned int *errors);
|
|
|
|
uint64_t VERITY_hash_offset_block(struct crypt_params_verity *params);
|
|
|
|
uint64_t VERITY_hash_blocks(struct crypt_device *cd, struct crypt_params_verity *params);
|
|
|
|
uint64_t VERITY_FEC_blocks(struct crypt_device *cd,
|
|
struct device *fec_device,
|
|
struct crypt_params_verity *params);
|
|
|
|
int VERITY_UUID_generate(struct crypt_device *cd, char **uuid_string);
|
|
|
|
#endif
|