zuluCrypt  5.7.1
About: zuluCrypt is a simple but feature rich solution for hard drives encryption. It can manage PLAIN dm-crypt, LUKS, TrueCrypt and VeraCrypt encrypted volumes.
  Fossies Dox: zuluCrypt-5.7.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

libzuluCrypt.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2011-2015
4  * name : Francis Banyikwa
5  * email: mhogomchungu@gmail.com
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http:/www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ZULUCRYPT
21 #define ZULUCRYPT
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <sys/types.h>
28 
29 /*
30  * version 3.1.0
31  */
32 #define ZULUCRYPT310
33 
34 /*
35  * This version adds zuluCryptCreateTCrypt() and zuluCryptOpenTcrypt() function
36  * These function are used specifically to handle truecrypt volumes since their functionality
37  * is too different from cryptsetup volumes necessitating different APIs
38  */
39 #define ZULUCRYPT320
40 
44 const char * zuluCryptVersion( void ) ;
45 
54 int zuluCryptVolumeIsLuks( const char * device ) ;
55 
56 
71 int zuluCryptOpenVolume( const char * device, /* path to a file/partition to be opened */
72  const char * mapper, /* mapper name( will show up in /dev/mapper/ ) */
73  const char * m_point,/* mount point path, opened volume will be mounted on this path */
74  uid_t id, /* owner of the mount point will have this id with rwx------ permissions */
75  unsigned long m_opts, /* option as expected by the second from last argument of mount() command */
76  const char * fs_opts, /* options as expected by the last command ofr mount() */
77  const char * pass, /* encrypted volume passphrase to be used to open the volume */
78  size_t pass_size /* passphrase size */
79  ) ;
80 
96 int zuluCryptCloseVolume(const char * mapper, /* mapper is the full address of the volume as it appears at /dev/mapper */
97  char ** mount_point ) ; /* returned pointer to mount point */
98 
99 
107 int zuluCryptCloseMapper( const char * mapper ) ;/* mapper is the full address of the volume as it */
108  /* appears at /dev/mapper */
109 
120 int zuluCryptUnmountVolume( const char * mapper, /*mapper is the full address of the volume as it appears at /dev/mapper */
121  char ** m_point ) ; /*mount point will be returned on this variable if closing succeeded.useful for deleting */
122  /*mount point folder.Its the caller's responsibility to free() this return value */
123 
133 int zuluCryptMountVolume( const char * mapper, /* path to a file or partition to mount */
134  const char * m_point,/* mount point */
135  unsigned long fs_opts,/* file system option as expected by the second from last argument of mount()*/
136  const char * m_opts, /* file system option as expected by the last command of mount() */
137  uid_t id ) ; /* user id the mount point should use */
138 
159 char * zuluCryptVolumeStatus( const char * mapper ); /* mapper is the full address of the volume as it */
160  /* appears at /dev/mapper */
161 
162 
184 int zuluCryptCreateVolume( const char * device, /* path to a file or partition */
185  const char * fs, /* file system to use in the volume(ext2,ext3.ext4,vfat etc) */
186  const char * type, /* type of volume to create( luks or plain ) */
187  const char * passphrase,/* passphrase to use to create the volume */
188  size_t passphrase_size, /* passphrase size */
189  const char * opts ); /* volume creation options */
190  /*mrequired when creating luks volume, just pick one if you */
191  /* creating a plain device, it will be ignored */
192 
202 int zuluCryptAddKey( const char * device, /* path to an encrypted file or partition */
203  const char * existingkey,/* a key that already exist in the encrypted volume */
204  size_t existingkey_size, /* size of existingkey */
205  const char * newkey, /* new key to be added to the volume */
206  size_t newkey_size ); /* size of the new key */
207 
217 int zuluCryptRemoveKey( const char * device , /* path to an encrypted device */
218  const char * passphrase, /* a key already in the volume to be removed */
219  size_t passphrase_size ) ; /* passphrase size */
220 
239 char * zuluCryptEmptySlots( const char * device ) ;
240 
251 int zuluCryptOpenLuks( const char * device, /* path to encrypted file or partition */
252  const char * mapping_name,/* mapper name to use */
253  const char * mode, /* "ro" or "rw" for opening in read only or read and write */
254  const char * passphrase, /* passphrase to use to open the volume */
255  size_t passphrase_size ); /* the length of the passphrase */
267 int zuluCryptCreateLuks( const char * device, /* path to a file or partition to create a volume in */
268  const char * passphrase,/* passphrase to use to create a volume */
269  size_t passphrase_size, /* size of the passphrase */
270  const char * rng ) ; /*random number generator( /dev/random or /dev/urandom) */
271 
272 int zuluCryptCreateLuks2( const char * device, /* path to a file or partition to create a volume in */
273  const char * passphrase,/* passphrase to use to create a volume */
274  size_t passphrase_size, /* size of the passphrase */
275  const char * rng ) ; /*random number generator( /dev/random or /dev/urandom)*/
276 
285 int zuluCryptOpenPlain( const char * device, /* path to encrypted file or partition */
286  const char * mapping_name,/* mapper name to use */
287  const char * mode, /* "ro" or "rw" for opening in read only or read and write */
288  const char * passphrase, /* passphrase to use to open the volume */
289  size_t passphrase_size ); /* passphrase length */
290 
291 /*
292  * truecrypt treats passphrases differently from keyfiles.
293  *
294  * Below 3 constants are used in the "key_source" source argument below.
295  *
296  * TCRYPT_KEYFILE_FILE option means the "key" argument is a path to a key file,if this option is used,then
297  * use "0" for "key_len" argument,the argument is not used.
298  *
299  * TCRYPT_KEYFILE option means the "key" argument is a memory buffer containing the content of a keyfile.This is useful
300  * if you want the API to treat the content of a buffer as if they are a keyfile.
301  *
302  * TCRYPT_PASSPHRASE option means the "key" argument is a pointer to a memory buffer containing the passphrase.
303  *
304  */
305 #define TCRYPT_PASSPHRASE 0
306 #define TCRYPT_KEYFILE 1
307 #define TCRYPT_KEYFILE_FILE 2
308 
309 #define TCRYPT_NORMAL 1
310 #define TCRYPT_HIDDEN 0
311 
318 int zuluCryptOpenTcrypt( const char * device, /* path to an encrypted file or partition */
319  const char * mapper, /* mapper name to use */
320  const char * key, /* key material */
321  size_t key_len, /* length of key */
322  int key_source, /* source of key material,options explained above */
323  int volume_type,/* option could be TCRYPT_NORMAL or TCRYPT_HIDDEN */
324  const char * m_point, /* mount point to mount the file system,if NULL,mapper will be opened onlu */
325  uid_t uid, /* uid of the person to associate the mount point with,not necessary if m_point == NULL */
326  unsigned long m_opts, /* mount points,option is passed to second from last argument of mount() */
327  const char * fs_opts /* passed to last argument of mount() */
328  ) ;
329 
347 int zuluCryptCreateTCrypt( const char * device, /* path a device or file to put an encrypted volume */
348  const char * file_system, /* file system to use in the volume */
349  const char * opts, /* volume creation options */
350  const char * key, /* key material to use */
351  size_t key_len, /* length of key */
352  int key_source, /* key material source,either pass TCRYPT_KEYFILE or TCRYPT_PASSPHRASE */
353  u_int64_t hidden_volume_size, /* pass "0" if a volume without a hidden volume is to be created or */
354  /* a non negative number to represent the size of the hidden volume to be created */
355  const char * file_system_h, /* file system of the hidden volume,pass NULL if no hidden volume will be created */
356  const char * key_h, /* key material to use for creation of hidden volume */
357  size_t key_len_h, /* length of hidden key */
358  int key_source_h /* hidden key source material,either pass TCRYPT_KEYFILE or TCRYPT_PASSPHRASE */
359  );
360 
376 char * zuluCryptVolumeDeviceName( const char * mapper ) ;
377 
386 int zuluCryptEncryptFile( const char * source,const char * dest,const char * key,u_int64_t key_len ) ;
387 
397 int zuluCryptDecryptFile( const char * source,const char * dest,const char * key,u_int64_t key_len ) ;
398 
399 #ifdef __cplusplus
400 }
401 #endif
402 
403 #endif
zuluCryptOpenLuks
int zuluCryptOpenLuks(const char *device, const char *mapping_name, const char *mode, const char *passphrase, size_t passphrase_size)
Definition: open_luks.c:104
zuluCryptOpenVolume
int zuluCryptOpenVolume(const char *device, const char *mapper, const char *m_point, uid_t id, unsigned long m_opts, const char *fs_opts, const char *pass, size_t pass_size)
Definition: open_volume.c:95
zuluCryptOpenTcrypt
int zuluCryptOpenTcrypt(const char *device, const char *mapper, const char *key, size_t key_len, int key_source, int volume_type, const char *m_point, uid_t uid, unsigned long m_opts, const char *fs_opts)
Definition: open_tcrypt.c:382
zuluCryptDecryptFile
int zuluCryptDecryptFile(const char *source, const char *dest, const char *key, u_int64_t key_len)
Definition: file_encryption.c:126
zuluCryptVolumeStatus
char * zuluCryptVolumeStatus(const char *mapper)
Definition: status.c:849
zuluCryptOpenPlain
int zuluCryptOpenPlain(const char *device, const char *mapping_name, const char *mode, const char *passphrase, size_t passphrase_size)
Definition: open_plain.c:222
zuluCryptCreateTCrypt
int zuluCryptCreateTCrypt(const char *device, const char *file_system, const char *opts, const char *key, size_t key_len, int key_source, u_int64_t hidden_volume_size, const char *file_system_h, const char *key_h, size_t key_len_h, int key_source_h)
Definition: create_tcrypt.c:445
zuluCryptEmptySlots
char * zuluCryptEmptySlots(const char *device)
Definition: empty_slots.c:86
zuluCryptCreateLuks2
int zuluCryptCreateLuks2(const char *device, const char *passphrase, size_t passphrase_size, const char *rng)
Definition: create_luks.c:427
zuluCryptVolumeIsLuks
int zuluCryptVolumeIsLuks(const char *device)
Definition: is_luks.c:45
zuluCryptVersion
const char * zuluCryptVersion(void)
Definition: version.c:22
zuluCryptVolumeDeviceName
char * zuluCryptVolumeDeviceName(const char *mapper)
Definition: status.c:895
zuluCryptRemoveKey
int zuluCryptRemoveKey(const char *device, const char *passphrase, size_t passphrase_size)
Definition: remove_key.c:73
zuluCryptCreateVolume
int zuluCryptCreateVolume(const char *device, const char *fs, const char *type, const char *passphrase, size_t passphrase_size, const char *opts)
Definition: create_volume.c:183
zuluCryptEncryptFile
int zuluCryptEncryptFile(const char *source, const char *dest, const char *key, u_int64_t key_len)
Definition: file_encryption.c:207
zuluCryptAddKey
int zuluCryptAddKey(const char *device, const char *existingkey, size_t existingkey_size, const char *newkey, size_t newkey_size)
Definition: add_key.c:67
zuluCryptCreateLuks
int zuluCryptCreateLuks(const char *device, const char *passphrase, size_t passphrase_size, const char *rng)
Definition: create_luks.c:285
zuluCryptCloseMapper
int zuluCryptCloseMapper(const char *mapper)
Definition: close_mapper.c:84
zuluCryptCloseVolume
int zuluCryptCloseVolume(const char *mapper, char **mount_point)
Definition: close_volume.c:22
zuluCryptMountVolume
int zuluCryptMountVolume(const char *mapper, const char *m_point, unsigned long fs_opts, const char *m_opts, uid_t id)
Definition: mount_volume.c:433
zuluCryptUnmountVolume
int zuluCryptUnmountVolume(const char *mapper, char **m_point)
Definition: unmount_volume.c:134