Late, I'm tired and probably pretty tight ....
I wrote an application that I need to protect, so it will only work on the machines for which I create the key. What I am doing now is to get the BIOS serial number and generate a hash from this, I then encrypt it using the RSA RSA private key. Then I sign the XML to make sure it is not tampered with. I try to pack the public key to decrypt and verify the signature, but every time I try to execute the code as a different user than the one that generated the signature, I get a signature failure.
Most of my code is modified from the sample code I found, as I am not so familiar with the RSA encryption that I would like to be. Below is the code I used and the code I thought I needed to use in order to get the right work ...
Any feedback would be greatly appreciated since I was completely lost at this point the source code that I worked with was like this, this code works fine as long as the user running the program is the same who originally signed the document ...
CspParameters cspParams = new CspParameters();
cspParams.KeyContainerName = "XML_DSIG_RSA_KEY";
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
// Create a new RSA signing key and save it in the container.
RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider(cspParams)
{
PersistKeyInCsp = true,
};
This code is what I believe I should do, but it cannot verify the signature no matter what I do, regardless of whether it is the same user or another ...
RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();
//Load the private key from xml file
XmlDocument xmlPrivateKey = new XmlDocument();
xmlPrivateKey.Load("KeyPriv.xml");
rsaKey.FromXmlString(xmlPrivateKey.InnerXml);
, - ( , , ). , , ....
cspParams.KeyContainerName = "XML_DSIG_RSA_KEY";
/ XML , / ? , , . , , .
?
?
, .