Encryption Plugin attempt

Discuss questions about plugin development with the Hollywood SDK here
Post Reply
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Encryption Plugin attempt

Post by SamuraiCrow »

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!
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Encryption Plugin attempt

Post by airsoftsoftwair »

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.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Encryption Plugin attempt

Post by SamuraiCrow »

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"
I'm on registered MorphOS using FlowStudio.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Encryption Plugin attempt

Post by SamuraiCrow »

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")
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Encryption Plugin attempt

Post by airsoftsoftwair »

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.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Encryption Plugin attempt

Post by SamuraiCrow »

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?
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Encryption Plugin attempt

Post by airsoftsoftwair »

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 :)
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Encryption Plugin attempt

Post by SamuraiCrow »

It compiles now. I'll have to test it next. Thanks for the help, airsoftsoftwair.
I'm on registered MorphOS using FlowStudio.
SamuraiCrow
Posts: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: Encryption Plugin attempt

Post by SamuraiCrow »

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.
I'm on registered MorphOS using FlowStudio.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Encryption Plugin attempt

Post by airsoftsoftwair »

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.
Post Reply