简体   繁体   中英

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 eg, 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.

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()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM