//Decrypt the envelope and return the output array. public byte[] DecryptEnvelope() { //Create the RSAWrapper from a string representation of its name. rsaAlgorithm = new RSAWrapper(rsaName); //Initialize the RSA algorithm key. rsaAlgorithm.RSAalg.FromXmlString(rsaKey); //Create the CipherMode from a string representation of its name. cipherMode = HelperExtensions.StringToCipherMode(cipherName); symmetricAlgorithm = HelperExtensions.StringToSymAlg(symmetricAlgorithmName, cipherMode, cipherName); symmetricAlgorithm.algorithm.IV = initializationVector; symmetricAlgorithm.algorithm.Key = rsaAlgorithm.RSADecrypt(DigitalEnvelopeEncrypted.EncryptedSymmetricKey, true); return(symmetricAlgorithm.Decrypt(DigitalEnvelopeEncrypted.EncryptedMessage)); }
//Validate the digital signature and return true if was authenticated successfully. public bool AuthenticateSignature() { rsaAlgorithm = new RSAWrapper(rsaName, hashAlgorithmName); rsaAlgorithm.RSAalg.FromXmlString(rsaKey); return(rsaAlgorithm.VerifySignedHash(input, signature)); }
//Constructor for the purpose of signing files. The input is given as a byte array. public DigitalSignature(RSAWrapper rsaAlgorithm, byte[] input) { this.rsaAlgorithm = rsaAlgorithm; this.input = input; }
//Constructor for the purpose of signing files. The input is given as a file path. public DigitalSignature(RSAWrapper rsaAlgorithm, string inputFilePath) { this.rsaAlgorithm = rsaAlgorithm; LoadInputFile(inputFilePath); }
//Create a DigitalEnvelope instance which will be used to create an envelope. public DigitalEnvelope(SymmetricAlgorithmWrapper SYMAlgorithm, RSAWrapper rsaAlgorithm, string inputFilePath) { this.symmetricAlgorithm = SYMAlgorithm; this.rsaAlgorithm = rsaAlgorithm; LoadInputFile(inputFilePath); }