2 * @mainpage Cryptsetup API
4 * The documentation covers public parts of cryptsetup API. In the following sections you'll find
5 * the examples that describe some features of cryptsetup API.
6 * For more info about libcryptsetup API versions see
7 * <a href="http://upstream-tracker.org/versions/libcryptsetup.html">Upstream Tracker</a>.
10 * <LI>@ref cexamples "Cryptsetup API examples"</LI>
12 * <LI>@ref cluks "crypt_luks_usage" - cryptsetup LUKS device type usage examples</LI>
14 * <LI>@ref cinit "crypt_init()"</LI>
15 * <LI>@ref cformat "crypt_format()" - header and payload on mutual device</LI>
16 * <LI>@ref ckeys "Keyslot operations" </LI>
18 * <LI>@ref ckeyslot_vol "crypt_keyslot_add_by_volume_key()"</LI>
19 * <LI>@ref ckeyslot_pass "crypt_keyslot_add_by_passphrase()"</LI>
21 * <LI>@ref cload "crypt_load()"
22 * <LI>@ref cactivate "crypt_activate_by_passphrase()"</LI>
23 * <LI>@ref cactive_pars "crypt_get_active_device()"</LI>
24 * <LI>@ref cinit_by_name "crypt_init_by_name()"</LI>
25 * <LI>@ref cdeactivate "crypt_deactivate()"</LI>
26 * <LI>@ref cluks_ex "crypt_luks_usage.c"</LI>
28 * <LI>@ref clog "crypt_log_usage" - cryptsetup logging API examples</LI>
32 * @section cexamples Cryptsetup API examples
33 * @section cluks crypt_luks_usage - cryptsetup LUKS device type usage
34 * @subsection cinit crypt_init()
36 * Every time you need to do something with cryptsetup or dmcrypt device
37 * you need a valid context. The first step to start your work is
38 * @ref crypt_init call. You can call it either with path
39 * to the block device or path to the regular file. If you don't supply the path,
40 * empty context is initialized.
42 * @subsection cformat crypt_format() - header and payload on mutual device
44 * This section covers basic use cases for formatting LUKS devices. Format operation
45 * sets device type in context and in case of LUKS header is written at the beginning
46 * of block device. In the example bellow we use the scenario where LUKS header and data
47 * are both stored on the same device. There's also a possibility to store header and
50 * <B>Bear in mind</B> that @ref crypt_format() is destructive operation and it
51 * overwrites part of the backing block device.
53 * @subsection ckeys Keyslot operations examples
55 * After successful @ref crypt_format of LUKS device, volume key is not stored
56 * in a persistent way on the device. Keyslot area is an array beyond LUKS header, where
57 * volume key is stored in the encrypted form using user input passphrase. For more info about
58 * LUKS keyslots and how it's actually protected, please look at
59 * <A HREF="http://code.google.com/p/cryptsetup/wiki/Specification">LUKS specification</A>.
60 * There are two basic methods to create a new keyslot:
62 * @subsection ckeyslot_vol crypt_keyslot_add_by_volume_key()
64 * Creates a new keyslot directly by encrypting volume_key stored in the device
65 * context. Passphrase should be supplied or user is prompted if passphrase param is
68 * @subsection ckeyslot_pass crypt_keyslot_add_by_passphrase()
70 * Creates a new keyslot for the volume key by opening existing active keyslot,
71 * extracting volume key from it and storing it into a new keyslot
72 * protected by a new passphrase
74 * @subsection cload crypt_load()
76 * Function loads header from backing block device into device context.
78 * @subsection cactivate crypt_activate_by_passphrase()
80 * Activates crypt device by user supplied password for keyslot containing the volume_key.
81 * If <I>keyslot</I> parameter is set to <I>CRYPT_ANY_SLOT</I> then all active keyslots
82 * are tried one by one until the volume key is found.
84 * @subsection cactive_pars crypt_get_active_device()
86 * This call returns structure containing runtime attributes of active device.
88 * @subsection cinit_by_name crypt_init_by_name()
90 * In case you need to do operations with active device (device which already
91 * has its corresponding mapping) and you miss valid device context stored in
92 * *crypt_device reference, you should use this call. Function tries to
93 * get path to backing device from DM, initializes context for it and loads LUKS
96 * @subsection cdeactivate crypt_deactivate()
98 * Deactivates crypt device (removes DM mapping and safely erases volume key from kernel).
100 * @subsection cluks_ex crypt_luks_usage.c - Complex example
102 * To compile and run use following commands in examples directory:
106 * ./crypt_luks_usage _path_to_[block_device]_file
109 * Note that you need to have the cryptsetup library compiled. @include crypt_luks_usage.c
111 * @section clog crypt_log_usage - cryptsetup logging API example
113 * Example describes basic use case for cryptsetup logging. To compile and run
114 * use following commands in examples directory:
121 * Note that you need to have the cryptsetup library compiled. @include crypt_log_usage.c
123 * @example crypt_luks_usage.c
124 * @example crypt_log_usage.c