Encryption Plugin attempt

Discuss questions about plugin development with the Hollywood SDK here

Encryption Plugin attempt

Postby SamuraiCrow » Wed Apr 13, 2016 1:52 pm

Hello,

I'm going to try to make a File Adapter plugin that will use the simple, famous, byte-cycling encryption algorithm but I've run into a problem. How do I add a tag to the FOpen tag-list so that I can input the password. I'd really rather not have it global to every file handle in case I need to copy from one encrypted file to another encrypted file using a different password. I think most of the other methods other than FSeek, FRead and FWrite should be pretty straightforward pass-through methods.

While I'm asking, is there a list of which loaders and savers work with a File Adapter plugin or do they all universally?

Thanks in advance!
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby airsoftsoftwair » Wed Apr 13, 2016 10:05 pm

It's currently not possible for plugins to define additional file adapter tags although it would be a nice addition for a future version. But it's not quite trivial since these tags would have to be supported by all functions that open files for reading or writing. It's possible to implement this transparently for Hollywood's inbuilt libraries but plugins dealing with files definitely would have to be adapted to support such a new functionality.

Currently, if you write a file adapter, all functions dealing with files (inbuilt & plugin functions) will automatically use your file adapter if it decides to handle a certain file. This means in practice that commands like LoadBrush(), OpenMusic(), OpenVideo() etc. will be able to open encrypted files as well using your file adapter. I think this should answer your second question.
User avatar
airsoftsoftwair
 
Posts: 2025
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Encryption Plugin attempt

Postby SamuraiCrow » Thu Apr 14, 2016 6:16 am

Ok, if I can't pass the password in as a parameter, how hard is it to declare a global table in a plugin and access two members as strings?

Code: Select all
password.in="pass1"
password.out="pass2"
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby SamuraiCrow » Thu Apr 14, 2016 1:02 pm

Update: After having looked at the Library plugin example, it looks like it will be easier to add setter methods as commands than to read in table entries.

Code: Select all
bytecycle.SetPasswords("pass1","pass2")
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby airsoftsoftwair » Sat Apr 16, 2016 2:47 pm

Yes, the library plugin API is your friend. The HTTP Streamer plugin also exposes a http.SetConfig() function on top of its file adapter capabilities.
User avatar
airsoftsoftwair
 
Posts: 2025
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Encryption Plugin attempt

Postby SamuraiCrow » Wed Apr 20, 2016 6:05 pm

Ok. It's almost finished. Since the Stat and FStat functions should be unaffected by the encryption and decryption, is there a way to just do a pass-through to the default implementations of these functions in my File Adapter plugin?
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby airsoftsoftwair » Thu Apr 21, 2016 5:11 pm

No, that's not possible. It wouldn't be possible on FStat() anyway because this one operates on a handle only your plugin knows about. But you can easily implement dummy FStat() and Stat() functions which just call into Hollywood: Just store the full path to the file somewhere in your plugin's file handle and then pass this file to DOSBase.hw_Stat() and you should be done. But read the documentation first, I don't remember if there are any pitfalls because it has been a while since I last touched this :)
User avatar
airsoftsoftwair
 
Posts: 2025
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Encryption Plugin attempt

Postby SamuraiCrow » Tue Apr 26, 2016 1:01 pm

It compiles now. I'll have to test it next. Thanks for the help, airsoftsoftwair.
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby SamuraiCrow » Sat Jul 30, 2016 4:40 am

I have my Linux plugin compiling but even though I have FOpen defined, the plugin won't load and complains that FOpen cannot be found.
SamuraiCrow
 
Posts: 46
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: Encryption Plugin attempt

Postby airsoftsoftwair » Sat Jul 30, 2016 5:00 am

You need to make sure that the FOpen() symbol is explicitly declared visible and you also need to tell the linker which symbols should be exported. See the example projects in the SDK. There is a file named plugin_linux.def. You need to add the FOpen symbol (and all other symbols your plugin needs to export) there. Then it should work.
User avatar
airsoftsoftwair
 
Posts: 2025
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany


Return to SDK

Who is online

Users browsing this forum: No registered users and 1 guest

cron