Securing Data

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
skumar
Posts: 201
Joined: Thu Feb 14, 2008 6:24 pm
Location: kerala state india
Contact:

Securing Data

Post by skumar »

Is there any way we can secure data of an irrlicht application?

I know irrlicht can support zip archives....but can we encrypt and give the password in the app in hardcoded form..?

Any other external free solutions.....?

please help
skumar
SirSami
Posts: 20
Joined: Mon Mar 24, 2008 2:18 pm
Location: Finland

Post by SirSami »

You can make it by changing bytes of the file. The logic is like: if encryption key is "3" then incrase every byte by 3 and when you are decrypting it decrase 3.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

[quote]You can make it by changing bytes of the file. The logic is like: if encryption key is "3" then incrase every byte by 3 and when you are decrypting it decrase 3.]
Yeah, that is an excellent encryption scheme. :P

There are many threads about this. You can find them with a simple search. The bottom line is that if you are trying to secure the mesh and texture data, you're out of luck. The data has to be sent to the GPU at some point, and that data can be intercepted and read using freely available tools.

Travis
Gogolian
Posts: 32
Joined: Sat May 17, 2008 10:49 pm

Post by Gogolian »

try searching for encryptors outside irrlicht
type in google:
RSA, DES or simply 'file encryption'/'file encryption c++' ;)
SirSami encryption sure is simple and fast but can be very siply broken.

Personally i would recomend you "shortcut function" (or you can say "hash func")

Try searching and learning a little bit about it it is can be very secure.

Mostly it does something like this:
if you have file:
plepleplepleplepleplepleple (27 bytes)
it merges (add or divide or multiply or whatever i can't remember)
1st and 2nd byte, 3 with 4th, 5th with 6th ect.
so you get something like this:
65dfg1vcb4df6e (14 bytes)
and one more time mearging:
sdfvf5v (7 bytes)
and over...
421v ( 4 bytes)

when you run the program you are just checking if "hash" which have you done before letting it enyone use is similar with hash done by your program every time it starts.
if they are similar, it means that the files are the same files you put in (not any other modified files)

That works because if you modify 1 single bit of your original file the hash returned from hash func. (which can be realy short instead of an file ;) ) will be whole different!

Hope it helps ;)
And the darkness begun...
hessiess
Posts: 47
Joined: Wed Mar 12, 2008 8:39 pm

Post by hessiess »

there isn't much point encrypting the files, programs exist that will extract 3d models and textures from API calls.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Well there might be point. Its like with locking your house: No matter what lock you will use there, it always can be picked. Its just matter of skill and tools. The point is to make it as hard as to prevent any looser around to breaking in and discourage rest of intruders to the point when they choose to break in to your neighbors house witch is not protected as well as yours.

Or would you say that there isn't much point locking your house? ;)
skumar
Posts: 201
Joined: Thu Feb 14, 2008 6:24 pm
Location: kerala state india
Contact:

Post by skumar »

i have no problem if the acess from the gpu....

i should prevent other type of hacking

i got a commercial solution....MoleBox pro....it can neatly pack everything into one exe....

do you know any free library which can pack all images ,meshes to a single exe....?
skumar
Gogolian
Posts: 32
Joined: Sat May 17, 2008 10:49 pm

Post by Gogolian »

to exe? for what?
And the darkness begun...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

you can pack all your stuff into your exe by turning the file into a header containing a data array and including that in your project and then reading it from memory. That also speeds up loading times a lot.

for that i use a program called dattoh, no idea if it's something that someone at work made or whether you can download it. there's also bin2h which i believe does the same trick and is something you can download from somewhere.
Image Image Image
skumar
Posts: 201
Joined: Thu Feb 14, 2008 6:24 pm
Location: kerala state india
Contact:

Post by skumar »

Thanks i start my search for such thins
skumar
skumar
Posts: 201
Joined: Thu Feb 14, 2008 6:24 pm
Location: kerala state india
Contact:

Post by skumar »

i got bin2h

One question JP .....

How we can tell the app to take image data from header rather than the file specified in the model?

please give a brief idea to use it.....
skumar
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Use IFileSystem::createMemoryReadFile() to create a pseudo-file from the data. Then pass that around to functions that expect an IReadFile*.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Maybe that would help, I use it in my engine:

1. A header file created with bin2h of a mesh.3ds file:
http://nusoftwarege.svn.sourceforge.net ... iew=markup

This file has:
A. BuiltInNUSoftwareIntroMeshData == An array of the file (created with bin2h).
B. BuiltInNUSoftwareIntroMeshDataSize == The size of the array.

2. A code to load it:

Code: Select all

   21 			IReadFile* memoryFile = m_pGUIEnv->getFileSystem()->createMemoryReadFile(
   22 				BuiltInNUSoftwareIntroMeshData,
   23 				BuiltInNUSoftwareIntroMeshDataSize,
   24 				"#NUSoftware.3ds");
   25 
   26 			IMesh* mesh = createMeshFromFile(SceneManager, memoryFile);
   27 			memoryFile->drop();
   28 
   29 			if(mesh)
   30 			{
   31 				m_pSceneNode = SceneManager->addMeshSceneNode(mesh);
   32 				mesh->drop(); // Ref count should be 3 Before dropping: created, cache and in node
   33 
   34 				m_pSceneNode->setID(id);
   35 				m_pSceneNode->setParent(parent);
   36 				m_pSceneNode->setPosition(pos);
   37 				m_pSceneNode->setRotation(rot);
   38 				m_pSceneNode->setScale(scale);
   39 			}
Lines 21 to 24 creates an IReadFile object (memoryFile) that you later use to load that mesh (with createMeshFromFile() function).

3. That uses this function (by vitek):

Code: Select all

  345 		IAnimatedMesh* createMeshFromFile(ISceneManager* smgr, IReadFile* file)
  346 		{
  347 			const c8* fileName = file->getFileName();
  348 
  349 			for(u32 n = 0; n < smgr->getMeshLoaderCount(); ++n)
  350 			{
  351 				IMeshLoader* loader = smgr->getMeshLoader(n);
  352 				if(loader && loader->isALoadableFileExtension(fileName))
  353 				{
  354 					IAnimatedMesh* mesh = loader->createMesh(file);
  355 					if(mesh)
  356 					{
  357 						// Putting the mesh into the mesh cache...
  358 						// this would allow a call to smgr->getMesh() to find the mesh
  359 						IMeshCache* cache = smgr->getMeshCache();
  360 						if(cache)
  361 							cache->addMesh(fileName, mesh);
  362 
  363 						return mesh;
  364 					}
  365 				}
  366 			}
  367 
  368 			return 0;
  369 		}
Edit:
I've just remembered that recently a new getMesh() was added that gets an IReadFile object so maybe it would be wiser to use that instead of the custom function (line 26):
Irrlicht API wrote:virtual IAnimatedMesh* irr::scene::ISceneManager::getMesh ( io::IReadFile * file ) [pure virtual]

Returns pointer to an animateable mesh. Loads the file if not loaded already.

Works just as getMesh(const char* filename) If you want to remove a loaded mesh from the cache again, use removeMesh().

Parameters:
file,: File handle of the mesh to load.

Returns:
Returns NULL if failed and the pointer to the mesh if successful. This pointer should not be dropped. See IReferenceCounted::drop() for more information.
And the Irrlicht implementation of it:

Code: Select all

//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file)
{
	if (!file)
		return 0;

	core::stringc name = file->getFileName();
	IAnimatedMesh* msh = MeshCache->getMeshByFilename(file->getFileName());
	if (msh)
		return msh;

	name.make_lower();
	s32 count = MeshLoaderList.size();
	for (s32 i=count-1; i>=0; --i)
	{
		if (MeshLoaderList[i]->isALoadableFileExtension(name.c_str()))
		{
			// reset file to avoid side effects of previous calls to createMesh
			file->seek(0);
			msh = MeshLoaderList[i]->createMesh(file);
			if (msh)
			{
				MeshCache->addMesh(file->getFileName(), msh);
				msh->drop();
				break;
			}
		}
	}

	if (!msh)
		os::Printer::log("Could not load mesh, file format seems to be unsupported", file->getFileName(), ELL_ERROR);
	else
		os::Printer::log("Loaded mesh", file->getFileName(), ELL_INFORMATION);

	return msh;
}
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JerryM
Posts: 5
Joined: Thu Jun 19, 2008 9:51 pm

Post by JerryM »

MasterGod, I really appreciate your sample. What if we have textures in our own "archive" as well?
bull
Posts: 36
Joined: Wed Sep 12, 2007 8:49 am
Location: s1Ng4p0R3

Post by bull »

MasterGod, I really appreciate your sample. What if we have textures in our own "archive" as well?
Irrlicht cache textures so you just have to load all the texture before you load the mesh. This is of course, not very nice since you need to know what textures the mesh use.

The best way I can think of is to patch CFileSystem to add your own custom filesystem that has encryption, then recompile Irrlicht.
There was something called SqlLite filesystem patch somewhere in this forum.
My name is bull, for we are many ...
Post Reply