"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/lib/integrity/integrity.h" (13 Jan 2022, 3421 Bytes) of package /linux/misc/cryptsetup-2.4.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "integrity.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.3.6_vs_2.4.0.

    1 /*
    2  * Integrity header definition
    3  *
    4  * Copyright (C) 2016-2021 Milan Broz
    5  *
    6  * This file is free software; you can redistribute it and/or
    7  * modify it under the terms of the GNU Lesser General Public
    8  * License as published by the Free Software Foundation; either
    9  * version 2.1 of the License, or (at your option) any later version.
   10  *
   11  * This file is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14  * Lesser General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU Lesser General Public
   17  * License along with this file; if not, write to the Free Software
   18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   19  */
   20 
   21 #ifndef _CRYPTSETUP_INTEGRITY_H
   22 #define _CRYPTSETUP_INTEGRITY_H
   23 
   24 #include <stdint.h>
   25 
   26 struct crypt_device;
   27 struct device;
   28 struct crypt_params_integrity;
   29 struct volume_key;
   30 struct crypt_dm_active_device;
   31 
   32 /* dm-integrity helper */
   33 #define SB_MAGIC    "integrt"
   34 #define SB_VERSION_1    1
   35 #define SB_VERSION_2    2
   36 #define SB_VERSION_3    3
   37 #define SB_VERSION_4    4
   38 #define SB_VERSION_5    5
   39 
   40 #define SB_FLAG_HAVE_JOURNAL_MAC    (1 << 0)
   41 #define SB_FLAG_RECALCULATING       (1 << 1) /* V2 only */
   42 #define SB_FLAG_DIRTY_BITMAP        (1 << 2) /* V3 only */
   43 #define SB_FLAG_FIXED_PADDING       (1 << 3) /* V4 only */
   44 #define SB_FLAG_FIXED_HMAC      (1 << 4) /* V5 only */
   45 
   46 struct superblock {
   47     uint8_t magic[8];
   48     uint8_t version;
   49     int8_t log2_interleave_sectors;
   50     uint16_t integrity_tag_size;
   51     uint32_t journal_sections;
   52     uint64_t provided_data_sectors;
   53     uint32_t flags;
   54     uint8_t log2_sectors_per_block;
   55     uint8_t log2_blocks_per_bitmap_bit; /* V3 only */
   56     uint8_t pad[2];
   57     uint64_t recalc_sector; /* V2 only */
   58 } __attribute__ ((packed));
   59 
   60 int INTEGRITY_read_sb(struct crypt_device *cd,
   61               struct crypt_params_integrity *params,
   62               uint32_t *flags);
   63 
   64 int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offset);
   65 
   66 int INTEGRITY_data_sectors(struct crypt_device *cd,
   67                struct device *device, uint64_t offset,
   68                uint64_t *data_sectors);
   69 int INTEGRITY_key_size(struct crypt_device *cd, const char *integrity);
   70 int INTEGRITY_tag_size(struct crypt_device *cd,
   71                const char *integrity,
   72                const char *cipher,
   73                const char *cipher_mode);
   74 int INTEGRITY_hash_tag_size(const char *integrity);
   75 
   76 int INTEGRITY_format(struct crypt_device *cd,
   77              const struct crypt_params_integrity *params,
   78              struct volume_key *journal_crypt_key,
   79              struct volume_key *journal_mac_key);
   80 
   81 int INTEGRITY_activate(struct crypt_device *cd,
   82                const char *name,
   83                const struct crypt_params_integrity *params,
   84                struct volume_key *vk,
   85                struct volume_key *journal_crypt_key,
   86                struct volume_key *journal_mac_key,
   87                uint32_t flags, uint32_t sb_flags);
   88 
   89 int INTEGRITY_create_dmd_device(struct crypt_device *cd,
   90                const struct crypt_params_integrity *params,
   91                struct volume_key *vk,
   92                struct volume_key *journal_crypt_key,
   93                struct volume_key *journal_mac_key,
   94                struct crypt_dm_active_device *dmd,
   95                uint32_t flags, uint32_t sb_flags);
   96 
   97 int INTEGRITY_activate_dmd_device(struct crypt_device *cd,
   98                const char *name,
   99                const char *type,
  100                struct crypt_dm_active_device *dmd,
  101                uint32_t sb_flags);
  102 #endif