"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/lib/tcrypt/tcrypt.h" (13 Jan 2022, 3460 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 "tcrypt.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  * TCRYPT (TrueCrypt-compatible)  header definition
    3  *
    4  * Copyright (C) 2012-2021 Red Hat, Inc. All rights reserved.
    5  * Copyright (C) 2012-2021 Milan Broz
    6  *
    7  * This file is free software; you can redistribute it and/or
    8  * modify it under the terms of the GNU Lesser General Public
    9  * License as published by the Free Software Foundation; either
   10  * version 2.1 of the License, or (at your option) any later version.
   11  *
   12  * This file is distributed in the hope that it will be useful,
   13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15  * Lesser General Public License for more details.
   16  *
   17  * You should have received a copy of the GNU Lesser General Public
   18  * License along with this file; if not, write to the Free Software
   19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   20  */
   21 
   22 #ifndef _CRYPTSETUP_TCRYPT_H
   23 #define _CRYPTSETUP_TCRYPT_H
   24 
   25 #include <stdint.h>
   26 
   27 #define TCRYPT_HDR_SALT_LEN 64
   28 #define TCRYPT_HDR_IV_LEN   16
   29 #define TCRYPT_HDR_LEN     448
   30 #define TCRYPT_HDR_KEY_LEN 192
   31 #define TCRYPT_HDR_MAGIC "TRUE"
   32 #define VCRYPT_HDR_MAGIC "VERA"
   33 #define TCRYPT_HDR_MAGIC_LEN 4
   34 
   35 #define TCRYPT_HDR_HIDDEN_OFFSET_OLD -1536
   36 #define TCRYPT_HDR_HIDDEN_OFFSET 65536
   37 
   38 #define TCRYPT_HDR_HIDDEN_OFFSET_BCK -65536
   39 #define TCRYPT_HDR_OFFSET_BCK -131072
   40 
   41 #define TCRYPT_HDR_SYSTEM_OFFSET 31744
   42 
   43 #define TCRYPT_LRW_IKEY_LEN 16
   44 #define TCRYPT_KEY_POOL_LEN 64
   45 #define VCRYPT_KEY_POOL_LEN 128
   46 #define TCRYPT_KEYFILE_LEN  1048576
   47 
   48 #define TCRYPT_HDR_FLAG_SYSTEM    (1 << 0)
   49 #define TCRYPT_HDR_FLAG_NONSYSTEM (1 << 1)
   50 
   51 struct tcrypt_phdr {
   52     char salt[TCRYPT_HDR_SALT_LEN];
   53 
   54     /* encrypted part, TCRYPT_HDR_LEN bytes */
   55     union {
   56     struct __attribute__((__packed__)) {
   57         char     magic[TCRYPT_HDR_MAGIC_LEN];
   58         uint16_t version;
   59         uint16_t version_tc;
   60         uint32_t keys_crc32;
   61         uint64_t _reserved1[2]; /* data/header ctime */
   62         uint64_t hidden_volume_size;
   63         uint64_t volume_size;
   64         uint64_t mk_offset;
   65         uint64_t mk_size;
   66         uint32_t flags;
   67         uint32_t sector_size;
   68         uint8_t  _reserved2[120];
   69         uint32_t header_crc32;
   70         char     keys[256];
   71     } d;
   72     char e[TCRYPT_HDR_LEN];
   73     };
   74 } __attribute__((__packed__));
   75 
   76 struct crypt_device;
   77 struct crypt_params_tcrypt;
   78 struct dm_target;
   79 struct volume_key;
   80 struct device;
   81 
   82 int TCRYPT_read_phdr(struct crypt_device *cd,
   83              struct tcrypt_phdr *hdr,
   84              struct crypt_params_tcrypt *params);
   85 
   86 int TCRYPT_init_by_name(struct crypt_device *cd, const char *name,
   87             const char *uuid,
   88             const struct dm_target *tgt,
   89             struct device **device,
   90             struct crypt_params_tcrypt *tcrypt_params,
   91             struct tcrypt_phdr *tcrypt_hdr);
   92 
   93 int TCRYPT_activate(struct crypt_device *cd,
   94              const char *name,
   95              struct tcrypt_phdr *hdr,
   96              struct crypt_params_tcrypt *params,
   97              uint32_t flags);
   98 
   99 int TCRYPT_deactivate(struct crypt_device *cd,
  100               const char *name,
  101               uint32_t flags);
  102 
  103 uint64_t TCRYPT_get_data_offset(struct crypt_device *cd,
  104                 struct tcrypt_phdr *hdr,
  105                 struct crypt_params_tcrypt *params);
  106 
  107 uint64_t TCRYPT_get_iv_offset(struct crypt_device *cd,
  108                   struct tcrypt_phdr *hdr,
  109                   struct crypt_params_tcrypt *params);
  110 
  111 int TCRYPT_get_volume_key(struct crypt_device *cd,
  112               struct tcrypt_phdr *hdr,
  113               struct crypt_params_tcrypt *params,
  114               struct volume_key **vk);
  115 
  116 int TCRYPT_dump(struct crypt_device *cd,
  117         struct tcrypt_phdr *hdr,
  118         struct crypt_params_tcrypt *params);
  119 
  120 #endif