コード例 #1
0
            public void NoPublicKeyThrowsError()
            {
                Assert.Throws(typeof(InvalidOperationException), () =>
                {
                    var cert       = RSACertificateBuilder.CreateNewCertificate("Test");
                    var data       = cert.Export(X509ContentType.Cert);
                    var publicCert = new X509Certificate2(data);

                    RSACertificateParser.ParsePrivateCertificate(publicCert);
                });
            }
コード例 #2
0
            public void KeySize7168CertificateCorrectlyParses()
            {
                var options = new RSACertificateBuilderOptions
                {
                    FullSubjectName = "CN=Test",
                    KeySize         = 7168
                };

                var cert = RSACertificateBuilder.CreateNewCertificate(options);
                var cng  = RSACertificateParser.ParsePrivateCertificate(cert);

                Assert.IsNotNull(cng);
            }
コード例 #3
0
        /// <summary>
        /// Create an AES encryptor from an encrypted AES key, you can use the encryptor to create
        /// </summary>
        /// <param name="blob">AES data created from the <see cref="CreateBlob(AESKeySize, X509Certificate2)"/> or <see cref="CreateBlob(AESKeySize, RSAServiceProvider)"/> method</param>
        /// <param name="rsaPrivateCert">RSA certificate to decrypt data, must have a private key</param>
        /// <returns>Encryptor that can be used to encrypt/decrypt any number of documents</returns>
        public static AESEncryptor CreateEncryptor(byte[] blob, X509Certificate2 rsaPrivateCert)
        {
            var cert = RSACertificateParser.ParsePrivateCertificate(rsaPrivateCert);

            return(CreateEncryptor(blob, cert));
        }