Example #1
0
void zuluCryptCheckInvalidKey( const char * device )
{
	char * d   ;
	const char * c ;
	int e = 0  ;

	zuluCryptSecurityGainElevatedPrivileges() ;
	/*
	 * zuluCryptEmptySlots() is defined in ../lib/empty_slots.c
	 */
	d = zuluCryptEmptySlots( device ) ;
	zuluCryptSecurityDropElevatedPrivileges() ;

	if( d == NULL ){
		/*
		 * we got here because the volume is either not luks based or the path is invalid
		 */
		;
	}else{
		c = d - 1 ;
		while( *++c ){
			if( *c == '2' ){
				fprintf( stderr,"WARNING: key slot number: %d is corrupted\n",e ) ;
			}
			e++ ;
		}
		free( d ) ;
	}
}
Example #2
0
/*
 * Its not possible to add more keys to a volume with no empty slots or to a non luks volume
 *
 * This function checks if a volume is luks and if it has atleast one empty slot.
 */
static int _zuluCryptCheckEmptySlots( const char * device )
{
	int status = 0 ;
	char * c  ;
	char * d  ;
	
	zuluCryptSecurityGainElevatedPrivileges() ;
	/*
	 * zuluCryptEmptySlots() is defined in ../lib/empty_slots.c
	 */
	c = zuluCryptEmptySlots( device ) ;
	
	zuluCryptSecurityDropElevatedPrivileges() ;
	
	if( c == NULL ){
		/*
		 * we got here because the volume is either not luks based or the path is invalid
		 */
		status = 1 ;
	}else{
		d = c - 1 ;
		while( *++d ){
			if( *d == '0' ){
				status = 2 ;
				break ;
			}
		}
		free( c ) ;
	}
	
	return status ;
}
Example #3
0
static int _zuluCryptExECheckEmptySlots( const char * device )
{
	int status = 0 ;
	char * c  ;
	char * d  ;

	zuluCryptSecurityGainElevatedPrivileges() ;

	c = zuluCryptEmptySlots( device ) ;

	zuluCryptSecurityDropElevatedPrivileges() ;

	if( c == NULL ){

		return 1 ;
	}

	d = c - 1 ;

	while( *++d ){

		if( *d == '3' ){

			status = 3 ;

			break ;
		}
	}

	StringFree( c ) ;

	return status ;
}
Example #4
0
/*
 * Its not possible to add more keys to a volume with no empty slots or to a non luks volume
 *
 * This function checks if a volume is luks and if it has atleast one empty slot.
 */
static int _zuluCryptCheckEmptySlots( const char * device )
{
	int r = 0 ;
	char * c ;
	char * d ;

	zuluCryptSecurityGainElevatedPrivileges() ;

	/*
	 * zuluCryptVolumeIsLuks() is defined in ../lib/is_luks.c
	 */
	if( zuluCryptVolumeIsLuks( device ) ){

		/*
		 * zuluCryptEmptySlots() is defined in ../lib/empty_slots.c
		 */
		c = zuluCryptEmptySlots( device ) ;

		if( c == NULL ){
			/*
			 * we shouldnt get here
			 */
			r = 1 ;
		}else{
			d = c - 1 ;

			while( *++d ){

				if( *d == '0' ){

					r = 2 ;

					break ;
				}
			}

			StringFree( c ) ;
		}
	}else{
		/*
		 * volume is not a LUKS volume,assuming its a TrueCrypt volume
		 */
		r = 2 ;
	}

	zuluCryptSecurityDropElevatedPrivileges() ;

	return r ;
}