2 * cryptsetup - setup cryptographic volumes for dm-crypt
4 * Copyright (C) 2004, Jana Saout <jana@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-2014, Milan Broz
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 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
42 #include "lib/utils_crypt.h"
43 #include "lib/utils_loop.h"
44 #include "lib/utils_fips.h"
46 #include "libcryptsetup.h"
48 #define CONST_CAST(x) (x)(uintptr_t)
49 #define DEFAULT_CIPHER(type) (DEFAULT_##type##_CIPHER "-" DEFAULT_##type##_MODE)
50 #define SECTOR_SIZE 512
51 #define ROUND_SECTOR(x) (((x) + SECTOR_SIZE - 1) / SECTOR_SIZE)
54 extern int opt_verbose;
55 extern int opt_batch_mode;
56 extern int opt_force_password;
59 void clogger(struct crypt_device *cd, int level, const char *file, int line,
60 const char *format, ...) __attribute__ ((format (printf, 5, 6)));
61 void tool_log(int level, const char *msg, void *usrptr __attribute__((unused)));
62 void quiet_log(int level, const char *msg, void *usrptr);
64 int yesDialog(const char *msg, void *usrptr __attribute__((unused)));
65 void show_status(int errcode);
66 const char *uuid_or_device(const char *spec);
67 __attribute__ ((noreturn)) \
68 void usage(poptContext popt_context, int exitcode, const char *error, const char *more);
69 void dbg_version_and_cmd(int argc, const char **argv);
70 int translate_errno(int r);
72 extern volatile int quit;
73 void set_int_block(int block);
74 void set_int_handler(int block);
75 void check_signal(int *r);
76 int tools_signals_blocked(void);
78 int tools_get_key(const char *prompt,
79 char **key, size_t *key_size,
80 size_t keyfile_offset, size_t keyfile_size_max,
82 int timeout, int verify, int pwquality,
83 struct crypt_device *cd);
86 #define log_dbg(x...) clogger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
87 #define log_std(x...) clogger(NULL, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x)
88 #define log_verbose(x...) clogger(NULL, CRYPT_LOG_VERBOSE, __FILE__, __LINE__, x)
89 #define log_err(x...) clogger(NULL, CRYPT_LOG_ERROR, __FILE__, __LINE__, x)
91 #endif /* CRYPTSETUP_H */