user1343318
user1343318

Reputation: 2141

DSA and Public Key Exchange

I am trying to implement a licensing solution with DSA Algorithms for my application. Now here is what I have done:

  1. Generated a hardware key, taken its hash.
  2. Generated public and private keys. And encrypted my hash function with private key.
  3. I forward this encrypted value back to client along with the public key.
  4. At client's system, I use the DSASignatureDeformatter's VerifySignature function to validate my encrypted key, and my hardware key. If equal I validate the client.

Now my problem is that how to send the public key over the network. I tried to store and forward various DSAParameters values e.g., J, G, P in a file but since the sizes of keys change, that is not viable. Please see if anyone can guide.

Updated: When I try to do this at the client's machine

    DSAParameters KeyInfo;
    using (DSACryptoServiceProvider DSA = new DSACryptoServiceProvider())
    {

        // Import the key information.
        KeyInfo = DSA.ExportParameters(false);
    }

The key size it generates for its various members is different from the public key parameters I have sent it back from server.

Upvotes: 0

Views: 1578

Answers (1)

myst3rium
myst3rium

Reputation: 156

Okay. A bit late. But maybe other ones will have the same question.

You should just export your key like this:

string publicKey = DSA.ToXmlString(false);

so you can import it like this:

using (DSACryptoServiceProvider dsa = new DSACryptoServiceProvider())
{
    dsa.FromXmlString(publicKey);
    return dsa.VerifySignature()
}

Upvotes: 1

Related Questions