14 #define _(String) gettext((String))
16 #define SECTOR_SHIFT 9
17 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
18 #define DEFAULT_ALIGNMENT 4096
20 #define MAX_TTY_PASSWORD_LEN 512
22 /* private struct crypt_options flags */
24 #define CRYPT_FLAG_FREE_DEVICE (1 << 24)
25 #define CRYPT_FLAG_FREE_CIPHER (1 << 25)
27 #define CRYPT_FLAG_PRIVATE_MASK ((unsigned int)-1 << 24)
32 int (*fn)(void *data, int size, char *key,
33 int sizep, const char *passphrase);
38 struct hash_type * (*get_hashes)(void);
39 void (*free_hashes)(struct hash_type *hashes);
44 void set_error_va(const char *fmt, va_list va);
45 void set_error(const char *fmt, ...);
46 const char *get_error(void);
47 void *safe_alloc(size_t size);
48 void safe_free(void *data);
49 void *safe_realloc(void *data, size_t size);
50 char *safe_strdup(const char *s);
51 void set_debug_level(int level);
53 struct hash_backend *get_hash_backend(const char *name);
54 void put_hash_backend(struct hash_backend *backend);
55 int hash(const char *backend_name, const char *hash_name,
56 char *result, size_t size,
57 const char *passphrase, size_t sizep);
59 void hexprint(char *d, int n);
61 /* Device mapper backend */
62 const char *dm_get_dir(void);
63 int dm_init(struct crypt_device *context, int check_kernel);
65 int dm_remove_device(const char *name, int force, uint64_t size);
66 int dm_status_device(const char *name);
67 int dm_query_device(const char *name,
76 int dm_create_device(const char *name, const char *device, const char *cipher, const char *uuid,
77 uint64_t size, uint64_t skip, uint64_t offset,
78 size_t key_size, const char *key,
79 int read_only, int reload);
81 int sector_size_for_device(const char *device);
82 ssize_t write_blockwise(int fd, const void *buf, size_t count);
83 ssize_t read_blockwise(int fd, void *_buf, size_t count);
84 ssize_t write_lseek_blockwise(int fd, const char *buf, size_t count, off_t offset);
87 int get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
88 const char *key_file, int passphrase_fd, int timeout, int how2verify, struct crypt_device *cd);
90 void set_default_log(void (*log)(int class, char *msg));
91 void logger(struct crypt_device *cd, int class, const char *file, int line, const char *format, ...);
92 #define log_dbg(x...) logger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x)
93 #define log_std(c, x...) logger(c, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x)
94 #define log_err(c, x...) do { \
95 logger(c, CRYPT_LOG_ERROR, __FILE__, __LINE__, x); \
96 set_error(x); } while(0)
98 int memlock_inc(struct crypt_device *ctx);
99 int memlock_dec(struct crypt_device *ctx);
101 #endif /* INTERNAL_H */