File: includes.h

package info (click to toggle)
zulucrypt 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,596 kB
  • sloc: cpp: 25,623; ansic: 23,788; makefile: 24; xml: 10; sh: 2
file content (577 lines) | stat: -rw-r--r-- 14,462 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
/*
 *
 *  Copyright (c) 2011-2015
 *  name : Francis Banyikwa
 *  email: mhogomchungu@gmail.com
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef ZULUCRYPT_LIB
#define ZULUCRYPT_LIB

#include "../utility/string/String.h"
#include "../utility/string/StringList.h"
#include "../utility/process/process.h"
#include "../constants.h"
#include "libzuluCrypt.h"
#include "../bin/bash_special_chars.h"

#include <gcrypt.h>

#include "support_whirlpool.h"

/*
 * below header is created at build time,it is set by CMakeLists.txt located in the root folder
 */
#include "version.h"

typedef struct{
	const char * device ;
	const char * m_point ;
	const char * fs ;
	const char * opts ;
	uid_t uid ;
	unsigned long m_flags ;
	const char * fs_flags ;
}m_struct;

typedef struct{
	const char * device ;
	const char * header_source ;
	const char * tmp_path ;
	const char * opt ;
	const char * key ;
	const char * rng ;
	const char * header_key ;
	const char * header_key_source ;
	const char * header_new_key ;
	const char * header_new_key_source ;
	uid_t uid ;
	int veraCrypt_volume ;
	int iteration_count ;
	string_t ( *getKey )( int * ) ;
}info_t ;

typedef struct{
	const char * device ;
	const char * plain_dm_properties ;
	const char * mapper_name ;
	const char * key ;
	const char * m_point ;
	const char * fs_opts ;
	const char * m_opts ;
	size_t       key_len ;
	uid_t        uid ;
	int          volume_type ;
	int          key_source ;
	int iteration_count ;
	int luks_detached_header ;
	int general_detached_header ;
	int tcrypt_keyfiles_count ;
	int veraCrypt_volume ;
	int trueCrypt_volume ;
	int tcrypt_system ;
	const char * const * tcrypt_keyfiles ;
	unsigned long m_flags ;
	int use_backup_header ;
	void * variables ;
}open_struct_t ;

typedef struct{
	const char * device ;
	const char * passphrase ;
	size_t       passphrase_size ;
	const char * const * keyfiles ;
	size_t       keyfiles_number ;
	const char * passphrase_h ;
	size_t       passphrase_h_size ;
	const char * const * keyfiles_h ;
	size_t       keyfiles_h_number ;
	const char *  encryption_options ;
	u_int64_t    hidden_volume_size ;
	const char * fs ;
	const char * fs_h ;
	int veraCrypt_volume ;
}create_tcrypt_t ;

typedef struct{
	const char * device ;
	int          error_value ;
	char       * error_value_1 ;
	int          open_mode ;
	const void * args ;
}resolve_path_t ;

/*
 * we only support whirlpool with cryptsetup >= 1.6.4 and libgcrypt >= 1.6.1
 *
 * read section 8.3  of cryptsetup FAQ for more info.
 */

static inline int zuluCryptWhirlpoolIsSupported()
{
#ifdef GCRYPT_VERSION_NUMBER
	return GCRYPT_VERSION_NUMBER >= 0x010601 && SUPPORT_WHIRLPOOL ;
#else
	return SUPPORT_WHIRLPOOL ;
#endif
}

/*
 * zuluCryptVeraCryptPIM() is defined in create_tcrypt.c
 */
int zuluCryptVeraCryptPIM( int e ) ;

/*
 * zuluCryptSystemVeraCryptPIM() is defined in create_tcrypt.c
 */
int zuluCryptSystemVeraCryptPIM( int e ) ;

/*
 * zuluCryptResolveDevicePath() is defined in resolve_path.c
 */
int zuluCryptResolveDevicePath( int( * )( const char *,const resolve_path_t * ),
				const resolve_path_t * ) ;

/*
 * zuluCryptResolveDevicePath_1() is defined in resolve_path.c
 */
char * zuluCryptResolveDevicePath_1( char *( * )( const char *,const resolve_path_t * ),
				     const resolve_path_t * ) ;
/*
 * zuluCryptResolveDevicePath_0() is defined in resolve_path.c
 */
int zuluCryptResolveDevicePath_0( int( * )( const char *,const resolve_path_t * ),
				  const open_struct_t *,int ) ;

/*
 * zuluCryptCreateTCryptVolume() is defined in create_tcrypt.c
 */
int zuluCryptCreateTCryptVolume( const create_tcrypt_t * ) ;

/*
 * zuluCryptOpenVolume_1() is defined in open_volume.c
 */
int zuluCryptOpenVolume_1( const open_struct_t * ) ;

/*
 * zuluCryptOpenVolume_1() is defined in open_volume.c
 */
int zuluCryptOpenVolume_2( const open_struct_t * ) ;

/*
 * zuluCryptOpenPlain_1() is defined in open_plain.c
 */
int zuluCryptOpenPlain_1( const open_struct_t * ) ;

/*
 * zuluCryptOpenLuks_1() is defined in open_luks.c
 */
int zuluCryptOpenLuks_1( const open_struct_t * ) ;

/*
 * zuluCryptOpenLuks_2() is defined in open_luks.c
 */
int zuluCryptOpenLuks_2( const open_struct_t * ) ;

/*
 * zuluCryptOpenTcrypt_1() is defined in open_tcrypt.c
 */
int zuluCryptOpenTcrypt_1( const open_struct_t * ) ;

/*
 * zuluCryptOpenVolume_0() is defined in open_volume.c
 */
int zuluCryptOpenVolume_0( int( *function )( const open_struct_t * ),const open_struct_t * ) ;

/*
 * this function is defined in create_loop_device.c
 */
int zuluCryptAttachLoopDeviceToFileUsingFileDescriptor( int fd_path,int * fd_loop,int mode,string_t * loop_device ) ;

/*
 * this function is defined in status.c
 */
int zuluCryptTrueCryptOrVeraCryptVolume( const char * mapper ) ;

/*
 * this function is defined in status.c
 */
void zuluCryptFileSystemProperties( string_t p,const char * mapper,const char * m_point ) ;

/*
 * this function is defined in create_mapper_name.c
 */
const char * zuluCryptMapperPrefix( void ) ;

/*
 * zuluCryptConvertCipher() is defined in create_tcrypt.c
 */
const char * zuluCryptConvertCipher( const char * ) ;

/*
 * this function is defined in create_mapper_name.c
 */
string_t zuluCryptCreateMapperName( const char * device,const char * mapping_name,uid_t uid,int i ) ;

/*
 * this function checks if path exists or not.
 * return 1 if the path exists
 * return 0 if it does not
 */
int zuluCryptPathIsValid( const char * path ) ;

/*
 * this function checks if a path exists or not
 * return 1 if the path does not exists
 * return 0 if the path exist
 */
int zuluCryptPathIsNotValid( const char * path ) ;

/*
 * this function checks if a path exists or not
 * return 1 if the path does not exists
 * return 0 if the path exist
 */
int zuluCryptPathIsNotValid_0( string_t path ) ;

/*
 * zuluCryptDecodeMountEntry() is defined in mount_volume.c
 */
const char * zuluCryptDecodeMountEntry( string_t ) ;

/*
 * zuluCryptDecodeMountEntry() is defined in mount_volume.c
 */
const char * zuluCryptEncodeMountEntry( string_t ) ;

/*
 *this function is deined in ../lib/process_mountinfo.c
 */
stringList_t zuluCryptOpenedVolumesList( uid_t ) ;

/*
 * this is defined in print_mounted_volumes.c
 */
int zuluCryptPartitionIsMounted( const char * device ) ;

/*
 *  parse "/etc/fstab" and return a field at position "pos" on a line
 *  that corresponds to device "device".
 */
#define MOUNTPOINT   1
#define FILESYSTEM   2
#define MOUNTOPTIONS 3
#define DUMPOPTION   4
#define FSCKOPTION   5

string_t zuluCryptGetMountOptionsFromFstab( const char * device,int pos,uid_t uid ) ;

/*
 * this function is defined in process_mountinfo.c
 */

string_t zuluCryptGetMountEntry( const char * path ) ;

/*
 * this function is defined in process_mountinfo.c
 */
string_t zuluCryptGetMountEntry_1( stringList_t stl,const char * path ) ;

/*
 * this function is defined in is_luks.c
 */
int zuluCryptVolumeIsNotLuks( const char * dev ) ;

/*
 * this function is defined in ./create_loop_device.c
 */
int zuluCryptAttachLoopDeviceToFile( const char * path,int mode,int * fd,string_t * loop_device ) ;

/*
 * this function is defined in ./blkid_evaluate_tag.c
 */
string_t zuluCryptGetFileSystemFromDevice( const char * device ) ;

/*
 * this function is defined in ./blkid_evaluate_tag.c
 */
int zuluCryptDeviceHasEncryptedFileSystem( const char * device ) ;

/*
 * this function is defined in ./blkid_evaluate_tag.c
 */
int zuluCryptDeviceHasAgivenFileSystem( const char * device,const char * fs ) ;

/*
 * this function is defined in ./create_loop_device.c
 */
char * zuluCryptLoopDeviceAddress( const char * device ) ;

/*
 * this function is defined in ./create_loop_device.c
 */
char * zuluCryptLoopDeviceAddress_1( const char * device ) ;

/*
 * this function is defined in ./create_luks.c
 */
void zuluCryptDisableMetadataLocking( void ) ;

/*
 * this function is defined in ./create_luks.c
 */
void zuluCryptPrintLogOutPut( void * ) ;

/*
 * this function is defined in ./create_loop_device.c
 */
string_t zuluCryptLoopDeviceAddress_2( const char * device ) ;

/*
 * this function is defined in ./create_loop_device.c
 */
char * zuluCryptGetLoopDeviceAddress( const char * device ) ;

/*
 * this function is defined in ./process_mountinfo.c
 */
char * zuluCryptGetMountPointFromPath( const char * path ) ;

/*
 * this function is defined in ./process_mountinfo.c
 */
char * zuluCryptGetMountPointFromPath_1( const char * path ) ;

/*
 * this function is defined in ./process_mountinfo.c
 */
char * zuluCryptResolveDevRoot( void ) ;

/*
 * this function is defined in ./process_mountinfo.c
 */
stringList_t zuluCryptGetFstabEntryList( const char * device,uid_t uid ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
char * zuluCryptDeviceFromUUID( const char * uuid ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
char * zuluCryptDeviceFromLabel( const char * label ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
char * zuluCryptDeviceFromPARTUUID( const char * p_uuid ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
char * zuluCryptDeviceFromPARTLABEL( const char * p_label ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
char * zuluCryptUUIDFromPath_1( const char * device ) ;

/*
 * this function is defined in volume_types.c
 */
int zuluCryptGetVolumeType( const char * device,const char * pass,size_t pass_size ) ;

/*
 * this function is defined in open_tcrypt.c
 */
int zuluCryptVolumeIsTcrypt( const char * device,const char * key,int key_source ) ;

/*
 * this function is defined in mount_fs_options.c
 */
int zuluCryptMountHasNotAllowedFileSystemOptions( uid_t uid,const char * fs_opts,string_t s ) ;

/*
 * this functioon is defined in ./real_path.c
 */
int zuluCryptPathDidNotChange( const char * path ) ;

/*
 * this functioon is defined in ./real_path.c
 */
int zuluCryptPathDeviceIsBlockDevice( const char * device ) ;

/*
 * this function is defined in mount_fs_options
 */
int zulucryptFileSystemIsSupported( const char * fs ) ;

/*
 * this function is defined in user_home_path.c
 */
string_t zuluCryptGetUserName( uid_t uid ) ;

/*
 * this function is defined in real_path.c
 */
char * zuluCryptRealPath( const char * path ) ;

/*
 * this function is defined in create_loop_device.c
 */
char * zuluCryptGetFileNameFromFileDescriptor( int fd ) ;

/*
 * this function is defined in file_path_security.c
 */
int zuluCryptGetDeviceFileProperties( const char * file,int * fd_path,int * fd_loop,char ** dev,uid_t uid ) ;

/*
 * this function is defined in file_path_security.c
 */
int zuluCryptSecureOpenFile( const char * path,int * fd_path,string_t * file,uid_t uid ) ;

/*
 * this function is defined in mount_volume.c
 */
stringList_t zuluCryptGetFstabList( uid_t ) ;

/*
 * this function is defined in process_mountinfo.c
 */
stringList_t zuluCryptGetMountInfoList( void ) ;

/*
 * this function is defined in process_mountinfo.c
 */
stringList_t zuluCryptGetMountInfoList_1( void ) ;

/*
 * this function is defined in status.c
 */
char * zuluCryptGetVolumeTypeFromMapperPath( const char * mapper ) ;

/*
 * this function is defined in create_volume.c
 */
int zuluCryptCreateFileSystemInAVolume( const char * fs,const char * device_mapper ) ;

/*
 * this function is defined in resolve_paths.c
 */
string_t zuluCryptConvertIfPathIsLVM( const char * path ) ;

/*
 * this function is defined in resolve_paths.c
 */
char * zuluCryptResolveMDPath( const char * path ) ;

/*
 * this function is defined in resolve_paths.c
 */
string_t zuluCryptResolveMDPath_1( const char * path ) ;

/*
 * this function is defined in file_path_security.c
 */
void zuluCryptDeleteFile( const char * file ) ;

/*
 * this function is defined in file_path_security.c
 */
void zuluCryptDeleteFile_1( string_t file ) ;

/*
 * this function is defined in blkid_evaluate_tag.c
 */
int zuluCryptFileSystemIsFUSEbased( const char * device ) ;

/*
 * this function is defined in status.c
 */
void zuluCryptFormatSize( u_int64_t number,char * buffer,size_t buffer_size ) ;

/*
 * zuluCryptCreateKeyFile() is defined in open_tcrypt.c
 */
string_t zuluCryptCreateKeyFile( const char * key,size_t key_len,const char * fileName ) ;

/*
 * zuluCryptCreateKeyFile_1() is defined in open_tcrypt.c
 */
string_t zuluCryptCreateKeyFile_1( string_t key,const char * fileName ) ;

/*
 * zuluCryptResolvePath_2() is defined in resolve_paths.c
 */
string_t zuluCryptResolvePath_2( const char * path ) ;

/*
 * zuluCryptResolvePath_1() is defined in resolve_paths.c
 */
string_t zuluCryptResolvePath_1( const char * path ) ;

/*
 * zuluCryptResolvePath_3() is defined in resolve_paths.c
 */
char * zuluCryptResolvePath_3( const char * path ) ;

/*
 * zuluCryptResolvePath_4() is defined in resolve_paths.c
 */
char * zuluCryptResolvePath_4( const char * path ) ;

/*
 * zuluCryptResolvePath() is defined in resolve_paths.c
 */
char * zuluCryptResolvePath( const char * path ) ;

/*
 * zuluCryptGetMoutedList_1() is defined in process_mountinfo.c
 */
stringList_t zuluCryptGetMoutedList_1( void ) ;

/*
 * zuluCryptGetMoutedList() is defined in process_mountinfo.c
 */
stringList_t zuluCryptGetMoutedList( void ) ;

/*
 * zuluCryptMountPointIsActive() is defined in process_mountinfo.c
 */
int zuluCryptMountPointIsActive( const char * ) ;

/*
 * zuluCryptGetALoopDeviceAssociatedWithAnImageFile() is defined in create_loop_device.c
 */
char * zuluCryptGetALoopDeviceAssociatedWithAnImageFile( const char * path ) ;

/*
 * zuluCryptGetAListOfMountedVolumes() is defined in process_mountinfo.c
 */
stringList_t zuluCryptGetAListOfMountedVolumes( void ) ;

/*
 * zuluCryptModifyTcryptHeader() is defined in create_tcplay.c
 */
int zuluCryptModifyTcryptHeader( const info_t * info ) ;

/*
 * this function is defined in mount_fs_options.c
 */
int zuluCryptUserIsAMemberOfAGroup( uid_t uid,const char * groupname ) ;

#endif