* Add log macros and make logging modre consitent.
[platform/upstream/cryptsetup.git] / lib / libcryptsetup.h
1 #ifndef _LIBCRYPTSETUP_H
2 #define _LIBCRYPTSETUP_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #include <stdint.h>
8
9
10 #define CRYPT_LOG_NORMAL 0
11 #define CRYPT_LOG_ERROR  1
12 #define CRYPT_LOG_DEBUG  -1 /* always on stdout */
13
14 struct interface_callbacks { 
15     int (*yesDialog)(char *msg);
16     void (*log)(int class, char *msg);
17 };
18
19
20 #define CRYPT_FLAG_VERIFY               (1 << 0)
21 #define CRYPT_FLAG_READONLY             (1 << 1)
22 #define CRYPT_FLAG_VERIFY_IF_POSSIBLE   (1 << 2)
23 #define CRYPT_FLAG_VERIFY_ON_DELKEY     (1 << 3)
24 #define CRYPT_FLAG_NON_EXCLUSIVE_ACCESS (1 << 4)
25
26 struct crypt_options {
27         const char      *name;
28         const char      *device;
29
30         const char      *cipher;
31         const char      *hash;
32
33         const char      *passphrase;
34         int             passphrase_fd;
35         const char      *key_file;
36         const char      *new_key_file;  
37         int             key_size;
38         
39         unsigned int    flags;
40         int             key_slot;
41
42         uint64_t        size;
43         uint64_t        offset;
44         uint64_t        skip;
45         uint64_t        iteration_time;
46         uint64_t        timeout;
47
48         uint64_t        align_payload;
49         int             tries;
50
51         struct interface_callbacks *icb;
52 };
53
54 int crypt_create_device(struct crypt_options *options);
55 int crypt_update_device(struct crypt_options *options);
56 int crypt_resize_device(struct crypt_options *options);
57 int crypt_query_device(struct crypt_options *options);
58 int crypt_remove_device(struct crypt_options *options);
59 int crypt_luksFormat(struct crypt_options *options);
60 int crypt_luksOpen(struct crypt_options *options);
61 int crypt_luksKillSlot(struct crypt_options *options);
62 int crypt_luksRemoveKey(struct crypt_options *options);
63 int crypt_luksAddKey(struct crypt_options *options);
64 int crypt_luksUUID(struct crypt_options *options);
65 int crypt_isLuks(struct crypt_options *options);
66 int crypt_luksFormat(struct crypt_options *options);
67 int crypt_luksDump(struct crypt_options *options);
68
69 void crypt_get_error(char *buf, size_t size);
70 void crypt_put_options(struct crypt_options *options);
71 const char *crypt_get_dir(void);
72
73 #ifdef __cplusplus
74 }
75 #endif
76 #endif /* _LIBCRYPTSETUP_H */