views:

76

answers:

4

I need a way to transfer a compiled assembly from client to the server and be able to store that in the database or in a file in such a way that I can grab those bytes on the "to" side and re-load assembly. Is there a way to do it. To clarify, I have a winforms application that will generate code and compile it based on some metadata. Now I need to be able to transfer this to a web site and store it somehow, but I don't want a dll (because it can be de-compiled). I would then have a "server" program on the to side, that would load this in memory. I could just transfer encrypted source code, but I thought I could just transfer compiled assembly.

More info: Even on the "from" side, there is not file generated, it is compiled in memory, so physical dll is never created.

+1  A: 

How about you transfer an encrypted DLL?

ck
How would that work? Did you mean obfuscated?
epitka
+1  A: 

You could use public key cryptography.

The client side would use the public key to encrypt the bytes comprising the assembly. These bytes would be stored in the database - completely useless to anyone not in posession of the private key. The server can then read in these bytes, decrypt them with the private key, and reconstitute the assembly from the decrypted byte stream.

Since you're using public key cryptography, even if the client is compromised your secret (the private key) is safe because it is stored on the server.

To learn more about this technique, I would recommend reading this.

HTH, Kent

Kent Boogaart
Is there a link to more info on how to do this. I updated my question with some more info. I guess I would use MemoryStream to read bytes, encrypt them and then send them over the wire. On the "to" side, how would I reconstitute assembly. What about if there are multiple assemblies referencing each other.
epitka
I've added a link for you.
Kent Boogaart
My question was more about the mechanics of the whole process, not about Cryptography, but thanks for the link anyway.
epitka
+1  A: 

It sounds like you want to serialize your compiled assembly, from/to memory, and transfer that to the server, where it gets deserialized into an assembly again.

Wez
+1  A: 

I suggest you use a Binary Serializer and pipe that stream into a CryptoStream that can be setup to a particular encryption model. Then take the output stream and dump that to your location. On the running end of your process your Decrypt it and Deserialize it. If you wanted you could also use a DeflateStream if your Assembly is large enough, this will save some space.

Hope this helps. If you would like examples let me know.

Jimmie Clark