コード例 #1
0
 //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));
 }
コード例 #2
0
 //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));
 }
コード例 #3
0
 //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;
 }
コード例 #4
0
 //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);
 }
コード例 #5
0
 //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);
 }