* Run performance check for PBKDF2 from LUKS code, do not mix hash algoritms results.
[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 struct crypt_device; /* crypt device handle */
10
11 #define CRYPT_ANY_SLOT  -1
12
13 typedef enum { SLOT_INVALID, SLOT_INACTIVE, SLOT_ACTIVE, SLOT_ACTIVE_LAST } crypt_keyslot_info;
14
15 #define CRYPT_LOG_NORMAL 0
16 #define CRYPT_LOG_ERROR  1
17 #define CRYPT_LOG_DEBUG  -1 /* always on stdout */
18
19 struct interface_callbacks { 
20     int (*yesDialog)(char *msg);
21     void (*log)(int class, char *msg);
22 };
23
24 #define CRYPT_FLAG_VERIFY               (1 << 0)
25 #define CRYPT_FLAG_READONLY             (1 << 1)
26 #define CRYPT_FLAG_VERIFY_IF_POSSIBLE   (1 << 2)
27 #define CRYPT_FLAG_VERIFY_ON_DELKEY     (1 << 3)
28 #define CRYPT_FLAG_NON_EXCLUSIVE_ACCESS (1 << 4)
29
30 struct crypt_options {
31         const char      *name;
32         const char      *device;
33
34         const char      *cipher;
35         const char      *hash;
36
37         const char      *passphrase;
38         int             passphrase_fd;
39         const char      *key_file;
40         const char      *new_key_file;
41         int             key_size;
42
43         unsigned int    flags;
44         int             key_slot;
45
46         uint64_t        size;
47         uint64_t        offset;
48         uint64_t        skip;
49         uint64_t        iteration_time;
50         uint64_t        timeout;
51
52         uint64_t        align_payload;
53         int             tries;
54
55         struct interface_callbacks *icb;
56 };
57
58 int crypt_create_device(struct crypt_options *options);
59 int crypt_update_device(struct crypt_options *options);
60 int crypt_resize_device(struct crypt_options *options);
61 int crypt_query_device(struct crypt_options *options);
62 int crypt_remove_device(struct crypt_options *options);
63 int crypt_luksFormat(struct crypt_options *options);
64 int crypt_luksOpen(struct crypt_options *options);
65 int crypt_luksKillSlot(struct crypt_options *options);
66 int crypt_luksRemoveKey(struct crypt_options *options);
67 int crypt_luksAddKey(struct crypt_options *options);
68 int crypt_luksUUID(struct crypt_options *options);
69 int crypt_isLuks(struct crypt_options *options);
70 int crypt_luksDump(struct crypt_options *options);
71
72 void crypt_get_error(char *buf, size_t size);
73 void crypt_put_options(struct crypt_options *options);
74 const char *crypt_get_dir(void);
75
76 #ifdef __cplusplus
77 }
78 #endif
79 #endif /* _LIBCRYPTSETUP_H */