当前位置: 首页>>代码示例>>C#>>正文


C# X509Certificate2.GetKey方法代码示例

本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.GetKey方法的具体用法?C# X509Certificate2.GetKey怎么用?C# X509Certificate2.GetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.X509Certificates.X509Certificate2的用法示例。


在下文中一共展示了X509Certificate2.GetKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: sign

        public byte[] sign(byte[] data, String algorithm, X509Certificate2 keyEntry)
        {
            if (algorithm == null)
            {
                throw new ArgumentNullException("El algoritmo de huella digital no puede ser nulo");
            }
            switch (algorithm)
            {
                /**
                 * ALGORITMOS COMPUESTOS
                 */
                /** Algoritmo de firma SHA1withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA1WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-1withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma MD5withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_MD5WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("MD5withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma MD2withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_MD2WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("MD2withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma SHA256withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA256WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-256withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma SHA384withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA384WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-384withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma SHA512withRSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA512WITHRSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-512withRSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma RSA que no incluye la generación de la huella
                 * digital (NONEwithRSA). */
                case AOSignConstants.SIGN_ALGORITHM_NONEWITHRSA:
                    {
                        throw new ArgumentNullException("El algoritmo SIGN_ALGORITHM_NONEWITHRSA no esta soportado");
                    }

                /** Algoritmo de firma SHA1withDSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA1WITHDSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-1withDSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma SHA1withECDSA. */
                case AOSignConstants.SIGN_ALGORITHM_SHA1WITHECDSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("SHA-1withECDSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

                /** Algoritmo de firma ECDSA que no incluye la generación de la huella
                 * digital (NONEwithEDSSA). */
                case AOSignConstants.SIGN_ALGORITHM_NONEWITHECDSA:
                    {
                        ISigner signer = SignerUtilities.GetSigner("NONEwithECDSA");
                        signer.Init(true, keyEntry.GetKey());
                        signer.BlockUpdate(data, 0, data.Length);
                        return signer.GenerateSignature();
                    }

//.........这里部分代码省略.........
开发者ID:bibou1324,项目名称:clienteafirma,代码行数:101,代码来源:AOPkcs1Signer.cs


注:本文中的System.Security.Cryptography.X509Certificates.X509Certificate2.GetKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。