Game Development Community

Protecting Art Assets With Encryption by Pat Wilson

by Carpenter Software · in Torque Game Builder · 04/19/2007 (1:09 pm) · 10 replies

I am testing the algorithms by Pat Wilson titled "Protecting Art Assets With Encryption". I am using TGB 1.1.3 and a MacPro with MacOS 10.4.9.

I got the new code working using the xor stream: I encoded the png files using a command line program that came with the zip file and replaced the old png files with the encoded files into the same data folder. I did a file.cs.dso clean. Uploaded the project with the encoded files and then uploaded the level.

(Edited the following)

Everything works fine.

What algorithm can I use to replace the XOR method in order to make it little bit more difficult to BREAK?
(added the following)
I was thinking of using an array of keys that would loop with the data stream!?

Carpenter Software

#1
04/23/2007 (8:47 am)
How would I encode sound ogg files using the method above?
#2
04/23/2007 (8:56 am)
I am not sure about streamed files but you may want to take a look at my encryption resource based on Pat Wilson's resource.
#3
04/24/2007 (10:32 am)
Thanks Michael for the info. I went over the different algorithms to see where it left off from Pat Wilson's algorithms but I may have missed it. Pat Wilson added a few lines to bitmapPNG.cpp for example so that it did testing to determine if it was a PNG or not, etc. Do you have a zip file that has your code files. If not, would you send me any info to further help me.

Thanks
Carpenter Software
#4
04/24/2007 (10:38 am)
Here is the link the actual resource (as opposed to just the documentation for it):

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9757
#5
04/24/2007 (11:12 am)
Thanks again...

There is a note on the above URL about "ResourceManager->registerExtension(".xpng", constructCipherBitmapPNG);" causing an error. Would you know if this remains a problem? With Pat Wilson's XOR, I had to set the key to the same value in the tool to the value in the source code. How are the keys set or used with the CipherLib?

Thanks
Carpenter Software
#6
04/24/2007 (12:04 pm)
The key for image-files is set in CipherBitmap.h if I remember it correctly. The problem you mentioned resolved itself mysteriosly after typing the code passage by hand instead of copying it from the website.
#7
04/24/2007 (3:02 pm)
I tried compiling CipherLib on a MacPro MacOS 10.4.9 with TGB 1.1.3. I get the following error:

/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OpenTransport.h:4253: error: declaration of 'operator new' as non-function
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OpenTransport.h:4253: error: expected ';' before '(' token

The bug is in the header file OpenTransport.h in the folder FlatCarbon.

The error is a declaration of "operator new" as non-function at line 4253. The code reads as:
void* operator new(size_t);

Anyway is there a workaround for this?

Thanks
Carpenter Software

(Edited out two lines.)
#8
04/24/2007 (5:34 pm)
It seems that GarageGames has had this problem before...

// Many OSX frameworks include OpenTransport, and OT's new operator conflicts
// with our redefinition of 'new', so we have to pre-include platformMacCarb.h,
// which contains the workaround.

(Edited out line.)

Thanks
Carpenter Software
#9
04/24/2007 (6:21 pm)
In platformMacCarb.h I found a comment:

/// NOTE: Placing system headers before Torque's platform.h will work around the Torque-Redefines-New problems.
#include
#include
#include
#include "platform/platform.h"

In the source code Twofish.cc, there is an include to "platform/platform.h", so I placed the system headers before "platform/platform.h" as shown above....

After compiling with this work around, I no longer get the fatal error. BUT I do get other errors - Multiple definitions.

/usr/bin/ld: multiple definitions of symbol _NESSIEdecrypt
/usr/bin/ld: multiple definitions of symbol _NESSIEencrypt
/usr/bin/ld: multiple definitions of symbol _NESSIEkeysetup
collect2: ld returned 1 exit status

(edited following line)
By the way, I believe that ld above is the linker program.

Carpenter Software
#10
04/24/2007 (8:56 pm)
Well I solved the multiple definitions....

Finally I have CipherLib Compiled.... Whew that was a lot of work (9 hours).... I have yet to run the app. I am just sitting here looking at it. I feel a little dizzy.

Will test tomorrow....

Carpenter Software