public CertificateOutputViewModel(byte[] signature, byte[] data, byte[] key, HashAlgorithmName hash, SymmetricAlgorithmName sym, SymmetricAlgorithmKey symKey, AsymmetricAlgorithmName alg, AsymmetricAlgorithmKey algKey, string file) { this.Description = "Certificate"; this.EnvelopeData = Convert.ToBase64String(data); this.EnvelopeCryptKey = key.ConvertToHex(); this.Signature = signature.ConvertToHex(); this.Methods = new List <string>() { hash.ToString(), sym.ToString(), alg.ToString() }; this.Method = string.Join("\n", Methods); this.KeyLengths = new List <string>() { "", ((int)symKey).ToString("X"), // hex ((int)algKey).ToString("X") // hex }; this.KeyLength = string.Join("\n", KeyLengths); this.FileName = file; }
private static ISymmetricCryptoAlgorithm GetSymmetricAlgorithm(this SymmetricAlgorithmName name, SymmetricAlgorithmKey keySize, System.Security.Cryptography.CipherMode mode) { switch (name) { case SymmetricAlgorithmName.TripleDES: return(new TripleDES(keySize: (int)keySize, mode: mode)); break; case SymmetricAlgorithmName.AES: default: return(new AES(keySize: (int)keySize, mode: mode)); break; } }