Exemplo n.º 1
0
        public static FormsAuthenticationTicket Decrypt(string encryptedTicket, string decryptionKey, string validationType, string validationKey)
        {
            var section = MachineKeySection.GetApplicationConfig();

            section.DecryptionKey     = decryptionKey;
            section.Validation        = (MachineKeyValidation)Enum.Parse(typeof(MachineKeyValidation), validationType);
            section.ValidationKey     = validationKey;
            section.CompatibilityMode = MachineKeyCompatibilityMode.Framework20SP2;
            return(Decrypt(encryptedTicket));
        }
Exemplo n.º 2
0
        private static AspNetCryptoServiceProvider GetSingletonCryptoServiceProvider()
        {
            // Provides all of the necessary dependencies for an application-level
            // AspNetCryptoServiceProvider.

            MachineKeySection machineKeySection = MachineKeySection.GetApplicationConfig();

            return(new AspNetCryptoServiceProvider(
                       machineKeySection: machineKeySection,
                       cryptoAlgorithmFactory: new MachineKeyCryptoAlgorithmFactory(machineKeySection),
                       masterKeyProvider: new MachineKeyMasterKeyProvider(machineKeySection),
                       dataProtectorFactory: new MachineKeyDataProtectorFactory(machineKeySection),
                       keyDerivationFunction: SP800_108.DeriveKey));
        }