public static CertificateOutputViewModel GenerateCertificate(this CertificateInputViewModel vm)
        {
            var inputBytes = Encoding.ASCII.GetBytes(vm.InputText); // new byte[] { };

            ISymmetricCryptoAlgorithm symmetric = GetSymmetricAlgorithm(vm.SelectedSymmetricAlgorithmName,
                                                                        vm.SelectedSymmetricAlgorithmKey, vm.SelectedSymmetricAlgorithmMode);

            IAsymmetricCryptoAlgorithm asymmetric =
                GetAsymmetricAlgorithm(vm.SelectedAsymmetricAlgorithmName, vm.SelectedAsymmetricAlgorithmKey);

            var envelope = new DigitalEnvelope(symmetric: symmetric, asymmetric: asymmetric);

            IHashAlgorithm hash = GetHashAlgorithm(vm.SelectedHashAlgorithmName);

            var signature = new Core.Signature.DigitalSignature(hash: hash, algorithm: asymmetric);

            var certificate = new DigitalCertificate(
                envelope: envelope,
                signature: signature
                );

            byte[] _gen = certificate.Create(input: inputBytes);

            (bool, byte[])_degen = certificate.Check();

            var model = new CertificateOutputViewModel(_gen, envelope.Data, envelope.Key, hash.AlgorithmName,
                                                       vm.SelectedSymmetricAlgorithmName, vm.SelectedSymmetricAlgorithmKey,
                                                       vm.SelectedAsymmetricAlgorithmName, vm.SelectedAsymmetricAlgorithmKey,
                                                       file: Constants.File.Name.CERTIFICATE)
            {
                InputText = vm.InputText
            };

            return(model);
        }
Пример #2
0
 // GET: Certificate
 public ActionResult Index(CertificateOutputViewModel vm)
 {
     return(View(vm));
 }