Exemplo n.º 1
0
ResourceLoader* ResourceManager::findLoader(const String& extension)
{
	auto ext = StringToLowerCase(extension);
	auto key = MurmurHash64(ext.c_str(), ext.size(), 0);

	return resourceLoaders.get(key, nullptr).get();
}
Exemplo n.º 2
0
static string_t _get_type_from_udev_1( const char * mapper )
{
	string_t st = _get_mapper_property_from_udev( mapper,"dm-uuid-CRYPT-",TYPE ) ;

	if( st == StringVoid ){

		/*
		 * failed to discover volume type
		 */
		return String( "Nil" ) ;
	}else{
		StringToLowerCase( st ) ;

		return st ;
	}
}
Exemplo n.º 3
0
int GetMapType(std::string File)
{
    std::string tmpMapName;
    
    for (int i=File.length()-3; i<File.length(); i++)
    {
        tmpMapName = tmpMapName + File[i];
    }
    if (StringToLowerCase(tmpMapName) == "map")
    {
        return MAP_FILE_MAP;
    }
    else
    {
        return MAP_FILE_XSB;
    }
}
Exemplo n.º 4
0
static string_t _get_crypto_info_from_tcplay( const char * mapper )
{
	int key_size ;

	int ro ;

	int64_t offset ;

	tc_api_task task ;

	char buff[ SIZE ] ;
	char * buffer = buff ;

	const char * z ;

	string_t p = StringVoid ;

	string_t q ;

	if( tc_api_initialize() ){

		if( tc_api_task_initialize( &task,"info_mapped" ) ){

			p = String( mapper ) ;

			mapper = mapper + StringLastIndexOfChar_1( mapper,'/' ) + 1 ;

			tc_api_task_set( task,"map_name",mapper ) ;

			tc_api_task_do( task ) ;

			tc_api_task_info_get( task,"status",sizeof( buff ),buff ) ;

			StringMultipleAppend( p," is ",buff,".",NULL ) ;

			if( StringAtLeastOneMatch_1( buff,"active","active and is in use",NULL ) ){

				tc_api_task_info_get( task,"type",sizeof( buff ),buff ) ;

				q = String( buff ) ;

				StringMultipleAppend( p," \n type:   \t",StringToLowerCase( q ),NULL ) ;

				StringDelete( &q ) ;

				tc_api_task_info_get( task,"cipher",sizeof( buff ),buff ) ;

				/*
				 * zuluCryptConvertCipher() is defined in create_tcrypt.c
				 */
				StringMultipleAppend( p,"\n cipher:\t",zuluCryptConvertCipher( buff ),"-xts-plain64",NULL ) ;

				tc_api_task_info_get( task,"key_bits",sizeof( key_size ),&key_size ) ;

				z = StringIntToString_1( buffer,SIZE,key_size ) ;

				StringMultipleAppend( p,"\n keysize:\t",z," bits",NULL ) ;

				tc_api_task_info_get( task,"iv_offset",sizeof( offset ),&offset ) ;

				z = StringIntToString_1( buffer,SIZE,offset / 512 ) ;

				StringMultipleAppend( p,"\n offset:\t",z," sectors",NULL ) ;

				zuluCryptFormatSize( offset,buffer,SIZE ) ;

				StringMultipleAppend( p," / ",buffer,NULL ) ;

				tc_api_task_info_get( task,"device",sizeof( buff ),buff ) ;

				_device_info( p,buff ) ;

				tc_api_task_info_get( task,"mode",sizeof( ro ),&ro ) ;

				if( ro ){

					StringAppend( p,"\n mode:   \tread only" ) ;
				}else{
					StringAppend( p,"\n mode:   \tread and write" ) ;
				}

				StringAppend( p,"\n active slots:\tNil" ) ;
			}

			tc_api_task_uninit( task ) ;
		}

		tc_api_uninit() ;
	}

	return p ;
}
Exemplo n.º 5
0
static string_t _get_crypto_info_from_cryptsetup( const char * mapper )
{
	char buff[ SIZE ] ;
	char * buffer = buff ;

	const char * z ;
	const char * type ;

	uint64_t e ;

	string_t q ;
	string_t p ;

	int k ;
	int i = 0 ;
	int j ;

	crypt_status_info info ;

	struct crypt_device * cd ;

	struct crypt_active_device cad ;

	if( crypt_init_by_name( &cd,mapper ) != 0 ){

		return StringVoid ;
	}

	p = String( mapper ) ;

	info = crypt_status( cd,mapper ) ;

	switch( info ){
	case CRYPT_INACTIVE :
		StringAppend( p," is inactive.\n" ) ;
		break ;
	case CRYPT_INVALID  :
		StringAppend( p," is invalid.\n" ) ;
		break ;
	case CRYPT_ACTIVE   :
		StringAppend( p," is active.\n" ) ;
		break ;
	case CRYPT_BUSY     :
		StringAppend( p," is active and is in use.\n" ) ;
		break ;
	default :
		StringAppend( p," is invalid.\n" ) ;
	}

	if( info == CRYPT_ACTIVE || info == CRYPT_BUSY ){

		StringAppend( p," type:   \t" ) ;

		type = crypt_get_type( cd ) ;

		if( type != NULL ){

			q = String( type ) ;
			StringAppend( p,StringToLowerCase( q ) ) ;
			StringDelete( &q ) ;
		}else{
			q = _get_type_from_udev_1( mapper ) ;

			StringAppendString( p,q ) ;

			StringDelete( &q ) ;
		}

		z = crypt_get_cipher( cd ) ;

		if( z != NULL ){

			StringMultipleAppend( p,"\n cipher:\t",z,"-",NULL ) ;
		}else{
			StringAppend( p,"\n cipher:\tNil-" ) ;
		}

		z = crypt_get_cipher_mode( cd ) ;

		if( z != NULL ){

			StringAppend( p,z ) ;
		}else{
			StringAppend( p,"Nil" ) ;
		}

		z = StringIntToString_1( buffer,SIZE,8 * crypt_get_volume_key_size( cd ) ) ;
		StringMultipleAppend( p,"\n keysize:\t",z," bits",NULL ) ;

		e = crypt_get_data_offset( cd ) ;

		z = StringIntToString_1( buffer,SIZE,e ) ;
		StringMultipleAppend( p,"\n offset:\t",z," sectors",NULL ) ;

		zuluCryptFormatSize( e * 512,buffer,SIZE ) ;
		StringMultipleAppend( p," / ",buffer,NULL ) ;

		_device_info( p,crypt_get_device_name( cd ) ) ;

		crypt_get_active_device( NULL,mapper,&cad ) ;

		if( cad.flags == 1 ){

			StringAppend( p,"\n mode:   \tread only" ) ;
		}else{
			StringAppend( p,"\n mode:   \tread and write" ) ;
		}

		k = crypt_keyslot_max( crypt_get_type( cd ) ) ;

		if( k > 0 ){

			i = 0 ;

			for( j = 0 ; j < k ; j++ ){

				switch( crypt_keyslot_status( cd,j ) ){

					case CRYPT_SLOT_ACTIVE_LAST : i++ ; break ;
					case CRYPT_SLOT_ACTIVE      : i++ ; break ;
					default : ;
				}
			}

			StringMultipleAppend( p,"\n active slots:\t",StringIntToString_1( buffer,SIZE,i ),NULL ) ;

			StringMultipleAppend( p," / ",StringIntToString_1( buffer,SIZE,k ),NULL ) ;
		}else{
			StringAppend( p,"\n active slots:\tNil" ) ;
		}
	}

	crypt_free( cd ) ;

	return p ;
}