blah blah blah is here! blah blah » Close

up0down
link

Hi all,

In my project on cryptography, I am using DLL to hold all the crypto related functions and then calling these dll functions from my asp.net pages.

The encrypt and decrypt functions are separate and can be called by users as per their needs.
Sine this is a public key cryptography, the decrypt function needs the original private key in order to process the cipher text.

As of now, the key is hard coded in the dll itsef but it shouldn't be, as different users will have different keys. I am saving the keys in the database and want to pass them along with the Decrypt function, like Decrypt(ciphertext, private key)

The problem is that, although, Decrypt function is defined in the main class of the DLL, it does not actually do the processing. In turn, it calls another function called "ProcessBlock" from a class called "ElGamalEngine", and this function actually works on the keys.

I can access ElGamalEngine through dll, but get only two of it's properties, "Equals" and "ReferenceEquals".

Is the only way, of setting a variable defined in a dll, is through passing it as a parameter to a function or can I also do it externally through the C# code.

say, the key being used is 'x', then is it possible to do say,

BigInteger x = myviewReader["priv"]

where priv would contain the key retrieved from the database.

Many thanks and apologies for a confusing post.

Best,
Abhi

last answered 2 years ago

1 answers

link

Hi,

I was able to solve this by declaring the key as public static in the dll. Then I was able to directly access it through the dll and change it's value.

public static BigInteger temp; // Class elgamal


BigInteger pv = new BigInteger(myviewReader["priv"].ToString());   // retrieved by query
elgamal.temp = pv;


Regards,

Abhi

Feedback