Add basic support for system TCRYPT device.
[platform/upstream/cryptsetup.git] / src / cryptsetup.h
1 /*
2  * cryptsetup - setup cryptographic volumes for dm-crypt
3  *
4  * Copyright (C) 2004, Christophe Saout <christophe@saout.de>
5  * Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
6  * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
7  * Copyright (C) 2009-2012, Milan Broz
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef CRYPTSETUP_H
24 #define CRYPTSETUP_H
25
26 #define _LARGEFILE64_SOURCE
27 #define _FILE_OFFSET_BITS 64
28
29 #include <config.h>
30
31 #include <string.h>
32 #include <stdlib.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <stdint.h>
36 #include <errno.h>
37 #include <unistd.h>
38 #include <inttypes.h>
39 #include <limits.h>
40 #include <ctype.h>
41 #include <fcntl.h>
42 #include <popt.h>
43 #include <sys/stat.h>
44
45 #include "lib/nls.h"
46 #include "lib/utils_crypt.h"
47 #include "lib/utils_loop.h"
48 #include "lib/utils_fips.h"
49
50 #include "libcryptsetup.h"
51
52 #define CONST_CAST(x) (x)(uintptr_t)
53 #define DEFAULT_CIPHER(type)    (DEFAULT_##type##_CIPHER "-" DEFAULT_##type##_MODE)
54 #define SECTOR_SIZE 512
55 #define ROUND_SECTOR(x) (((x) + SECTOR_SIZE - 1) / SECTOR_SIZE)
56
57 extern int opt_debug;
58 extern int opt_verbose;
59 extern int opt_batch_mode;
60 extern int opt_force_password;
61
62 /* Common tools */
63 void clogger(struct crypt_device *cd, int level, const char *file, int line,
64              const char *format, ...);
65 void tool_log(int level, const char *msg, void *usrptr __attribute__((unused)));
66 void quiet_log(int level, const char *msg, void *usrptr);
67
68 int yesDialog(const char *msg, void *usrptr __attribute__((unused)));
69 void show_status(int errcode);
70 const char *uuid_or_device(const char *spec);
71 void usage(poptContext popt_context, int exitcode, const char *error, const char *more);
72 void dbg_version_and_cmd(int argc, const char **argv);
73 int translate_errno(int r);
74
75 extern volatile int quit;
76 void set_int_block(int block);
77 void set_int_handler(int block);
78 void check_signal(int *r);
79 int tools_signals_blocked(void);
80
81 int tools_get_key(const char *prompt,
82                   char **key, size_t *key_size,
83                   size_t keyfile_offset, size_t keyfile_size_max,
84                   const char *key_file,
85                   int timeout, int verify, int pwquality,
86                   struct crypt_device *cd);
87
88 /* Log */
89 #define log_dbg(x...) clogger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
90 #define log_std(x...) clogger(NULL, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x)
91 #define log_verbose(x...) clogger(NULL, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x)
92 #define log_err(x...) clogger(NULL, CRYPT_LOG_ERROR, __FILE__, __LINE__, x)
93
94 #endif /* CRYPTSETUP_H */