Encryption Plugin attempt
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Encryption Plugin attempt
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 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.
- airsoftsoftwair
- Posts: 5673
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Encryption Plugin attempt
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.
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.
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Encryption Plugin attempt
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.
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Encryption Plugin attempt
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.
- airsoftsoftwair
- Posts: 5673
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Encryption Plugin attempt
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.
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Encryption Plugin attempt
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.
- airsoftsoftwair
- Posts: 5673
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Encryption Plugin attempt
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 

-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Encryption Plugin attempt
It compiles now. I'll have to test it next. Thanks for the help, airsoftsoftwair.
I'm on registered MorphOS using FlowStudio.
-
- Posts: 475
- Joined: Fri May 15, 2015 5:15 pm
- Location: Waterville, Minnesota USA
Re: Encryption Plugin attempt
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.
- airsoftsoftwair
- Posts: 5673
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Encryption Plugin attempt
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.