Пример #1
0
int zuluCryptModifyTcryptHeader( const info_t * info )
{
	tc_api_task task ;
	int r = !TC_OK ;
	const char * sys_device = NULL ;
	string_t st = StringVoid ;
	if( tc_api_init( 0 ) == TC_OK ){
		task = tc_api_task_init( "modify" ) ;
		if( task != 0 ){
			if( StringsAreEqual( info->opt,"sys" ) ){
				tc_api_task_set( task,"dev",info->device ) ;
				st = _root_device( info->device,&sys_device ) ;
				tc_api_task_set( task,"sys",sys_device ) ;
			}else if( StringsAreEqual( info->opt,"fde" ) ){
				st = _root_device( info->device,&sys_device ) ;
				tc_api_task_set( task,"dev",sys_device ) ;
				tc_api_task_set( task,"fde",TRUE ) ;
			}else{
				tc_api_task_set( task,"dev",info->device ) ;
			}
			tc_api_task_set( task,"hidden_size_bytes",( u_int64_t )0 ) ;
			/*
			 * below line may look like one of the following two lines:
			 * tc_api_task_set( task,"header_from_file","/home/ink/tc.headerbackup" ) ;
			 * tc_api_task_set( task,"save_header_to_file","/home/ink/tc.headerbackup" ) ;
			 */
			tc_api_task_set( task,info->header_source,info->tmp_path ) ;
			/*
			 * below line may look like one of the following two lines:
			 * tc_api_task_set( task,"passphrase","xxx" ) ;
			 * tc_api_task_set( task,"keyfiles","/home/ink/keyfile" ) ;
			 */
			tc_api_task_set( task,info->header_key_source,info->header_key ) ;
			/*
			 * below line may look like one of the following two lines:
			 * tc_api_task_set( task,"new_passphrase","xxx" ) ;
			 * tc_api_task_set( task,"new_keyfiles","/home/ink/keyfile" ) ;
			 */
			tc_api_task_set( task,info->header_new_key_source,info->header_key ) ;

			if( StringsAreEqual( info->rng,"/dev/urandom" ) ){
				tc_api_task_set( task,"weak_keys_and_salt",TRUE ) ;
			}else{
				tc_api_task_set( task,"weak_keys_and_salt",FALSE ) ;
			}

			r = tc_api_task_do( task ) ;
			tc_api_task_uninit( task ) ;
		}
		tc_api_uninit() ;
	}
	StringDelete( &st ) ;
	return r ;
}
Пример #2
0
static int _create_volume( const tcrypt_t * info )
{
	tc_api_task task ;
	int r = !TC_OK ;
	if( tc_api_init( 0 ) == TC_OK ){
		task = tc_api_task_init( "create" ) ;
		if( task != 0 ){

			tc_api_task_set( task,"dev",info->device ) ;
			tc_api_task_set( task,"secure_erase",FALSE ) ;
			tc_api_task_set( task,"prf_algo","RIPEMD160" ) ;
			tc_api_task_set( task,"cipher_chain","AES-256-XTS" ) ;
			tc_api_task_set( task,info->key_source_1,info->key ) ;

			if( info->weak_keys_and_salt ){
				tc_api_task_set( task,"weak_keys_and_salt",TRUE ) ;
			}else{
				tc_api_task_set( task,"weak_keys_and_salt",FALSE ) ;
			}

			if( info->hidden_volume_size > 0 ){

				tc_api_task_set( task,"hidden_size_bytes",info->hidden_volume_size ) ;
				tc_api_task_set( task,"h_prf_algo","RIPEMD160" ) ;
				tc_api_task_set( task,"h_cipher_chain","AES-256-XTS" ) ;
				tc_api_task_set( task,info->key_source_h_1,info->key_h ) ;
			}

			r = tc_api_task_do( task ) ;

			tc_api_task_uninit( task ) ;
		}

		tc_api_uninit() ;
	}

	return r ;
}
Пример #3
0
static int _open_tcrypt_volume( const char * device,const open_struct_t * opts )
{
	tc_api_task task ;
	int r = !TC_OK ;

	size_t i ;
	size_t k ;

	const char * const * z ;

	const char * e ;

	string_t st = StringVoid ;

	if( tc_api_initialize() ){

		task = tc_api_task_init( "map" ) ;

		if( tc_api_task_initialized( task ) ){

			tc_api_task_set( task,"veracrypt_mode",opts->veraCrypt_volume ) ;
			tc_api_task_set( task,"map_name",opts->mapper_name ) ;

			if( StringHasComponent( opts->m_opts,"ro" ) ){

				tc_api_task_set( task,"read_only" ) ;
			}

			if( opts->tcrypt_system ){

				if( StringPrefixEqual( device,"/dev/sd" ) ||
					StringPrefixEqual( device,"/dev/hd" ) ){

					st = String( device ) ;
					e = StringRemoveDigits( st ) ;
					tc_api_task_set( task,"dev",e ) ;
					tc_api_task_set( task,"sys",e ) ;
				}else{
					tc_api_task_set( task,"dev",device ) ;
					tc_api_task_set( task,"sys",device ) ;
				}
			}else{
				tc_api_task_set( task,"dev",device ) ;
			}

			k = opts->tcrypt_keyfiles_count ;
			z = opts->tcrypt_keyfiles ;

			tc_api_task_set( task,"passphrase",opts->key ) ;

			for( i = 0 ; i < k ; i++ ){
				tc_api_task_set( task,"keyfiles",*( z + i ) ) ;
			}

			r = tc_api_task_do( task ) ;

			tc_api_task_uninit( task ) ;

			StringDelete( &st ) ;
		}

		tc_api_uninit() ;
	}

	return r ;
}