I would like a new C# class that relies on System.Security.Cryptography. The class will be used to generate public/private key pairs, generate random keys, generate digital signatures, calculate message digests, encrypt files, decrypt files, and create/extract envelopes containing encrypted files, random keys, message digests, and digital signatures. The code must work on files up to 30MB in size. There should be at least 13 methods in this class, as specified in the detailed requirements.
## Deliverables
I would like a new C# class that relies on System.Security.Cryptography. All methods should return 1 on success and negative values on error. You need to tell me what all possible negative values are when you are done coding. The code must work on files up to 30MB in size. The 13 methods in this class are: // Constructor to do any required initialization, if any. int MySecurityClass(); // Destructor to do any required cleanup, if any. int ~MySecurityClass(); // Creates a public key pair, storing into publicKey and privateKey. int GeneratePublicPrivateKeyPair(var publicKey, var privateKey, int keyLength); // Creates a random key, using TimeTimeTimeTime as seed. int GenerateRandomKey(var randomKey, int keyLength); // Calculates a message digest for the file indicated by normalFileName. int GenerateMessageDigest(normalFileName, var messageDigest); int EncryptRandomKey(randomKey, var encryptedRandomKey, publicKey); int DecryptRandomKey(var randomKey, encryptedRandomKey, privateKey); // Reads contents of file specified by normalFileName, encrypts file using randomKey, // storing results into the file specified by encryptedFileName, int EncryptFile(normalFileName, encryptedFileName, randomKey); // Reads contents of file specified by encryptedFileName, decrypts // using randomKey, storing results into the file specified by normalFileName. int DecryptFile(normalFileName, encryptedFileName, randomKey); // generates a digital signature based on private key, stuffs generated // signature into var digitalSignature int GenerateDigitalSignature(privateKey, var digitalSignature); // validates a digital signature based on public key // returns 1 if the signature matches. negative value on mismatch/errors. int ValidateDigitalSignature(publicKey, digitalSignature); // Packages myID, the encryptedFileName, the encrypted randomKey, // the messageDigest, and the encryptedFile itself into the file // specified by envelopeFileName. int CreateEnvelope(envelopeFileName, myID, encryptedFileName, encryptedRandomKey, messageDigest, digitalSignature); // Opposite of CreateEnvelope; Extracts contents of the envelopeFile. // Extracts myID into var myID. // Extracts encrypted file name into var encryptedFileName. // Extracts random key into var randomKey. // Extracts message digest, populating var messageDigest. // Extracts the encryptedFile itself into file specified by encryptedFileName. int ProcessEnvelope(envelopeFileName, var myID, var encryptedFileName, var encryptedRandomKey, var messageDigest, var digitalSignature); Example usage of this class: { String randomKey; String publicKeyONE; String privateKeyONE; String publicKeyTWO; String privateKeyTWO; String messageDigest; String secondMessageDigest; String normalFileName; String encryptedFileName; String myID; int returnValue = 0; MySecurityClass msc = new MySecurityClass(); returnValue = [login to view URL](var publicKeyONE, var privateKeyONE); if(returnValue != 1) error processing returnValue = [login to view URL](var publicKeyTWO, var privateKeyTWO); if(returnValue != 1) error processing returnValue = [login to view URL](var randomKey); if(returnValue != 1) error processing returnValue = [login to view URL](normalFileName, var messageDigest); if(returnValue != 1) error processing returnValue = [login to view URL](normalFileName, encryptedFileName, randomKey); if(returnValue != 1) error processing returnValue = [login to view URL](randomKey, var encryptedRandomKey, publicKeyTWO); if(returnValue != 1) error processing returnValue = [login to view URL](privateKeyONE, var digitalSignature); if(returnValue != 1) error processing returnValue = [login to view URL](envelopeFileName, myID, encryptedFileName, encryptedRandomKey, messageDigest, digitalSignature); if(returnValue != 1) error processing ... returnValue = [login to view URL](envelopeFileName, var myID, var encryptedFileName, var encryptedRandomKey, var messageDigest, var digitalSignature); if(returnValue != 1) error processing returnValue = [login to view URL](publicKeyONE, digitalSignature); if(returnValue != 1) error processing returnValue = [login to view URL](encryptedRandomKey, var randomKey, privateKeyTWO); if(returnValue != 1) error processing returnValue = [login to view URL](normalFileName, encryptedFileName, randomKey); if(returnValue != 1) error processing returnValue = [login to view URL](normalFileName, var secondMessageDigest); if(returnValue != 1) error processing if([login to view URL](secondMessageDigest)) == 0) [login to view URL]("Error encountered. Message Digests do not match!!!"); IF WE GET TO HERE, ALL IS WELL. } // if my logic is wrong please feel free to correct me. // I am writing this from memory from a project I worked on in 1990. // If you cannot follow what I am doing in the example usage, you probably shouldn't bid on this project. // The fully functional working program should include the example usage as the "main" of the program. // You do not need to provide any sort of installation program. All I really need is the contents of the Visual Studio workspace and/or project so I can edit/compile/run the project in Visual Studio. I use Visual Studio 2010.