public void Test_sha1_1024_PKCS12()
        {
            string            pathKey  = Path.Combine(path_RSA_sha1_1024, "sha1_cert.p12");
            string            pathCert = Path.Combine(path_RSA_sha1_1024, "sha1_cert.p12");
            PrivateKeyManager key      = new PrivateKeyManager();

            key.LoadPKCS12(pathKey, alias, password);
            CertificateX509 cert = new CertificateX509();

            cert.LoadPKCS12(pathCert, alias, password);
            runTestWithEncoding(key, cert, "SHA1");
        }
        public void Test_sha256_1024_PKCS12()
        {
            string            pathKey  = Path.Combine(path_RSA_sha256_1024, "sha256_cert.p12");
            string            pathCert = Path.Combine(path_RSA_sha256_1024, "sha256_cert.p12");
            PrivateKeyManager key      = new PrivateKeyManager();
            CertificateX509   cert     = new CertificateX509();

            key.LoadPKCS12(pathKey, alias, password);
            cert.LoadPKCS12(pathCert, alias, password);
            string alg = "RS256";

            bulkTest(key, cert, alg);
        }
Exemplo n.º 3
0
        private void bulkTest(string pathCert, string pathKey, string pathSigned, bool ispkcs12, bool encrypted)
        {
            for (int k = 0; k < arrayKeyInfoType.Length; k++)
            {
                options.KeyInfoType      = arrayKeyInfoType[k];
                optionsXPath.KeyInfoType = arrayKeyInfoType[k];
                optionsID.KeyInfoType    = arrayKeyInfoType[k];
                CertificateX509 cert = new CertificateX509();
                if (ispkcs12)
                {
                    cert.LoadPKCS12(pathCert, alias, password);
                }
                else
                {
                    cert.Load(pathCert);
                }
                PrivateKeyManager key = new PrivateKeyManager();

                if (ispkcs12)
                {
                    key.LoadPKCS12(pathKey, alias, password);
                }
                else
                {
                    key.Load(pathKey);
                }

                /*if (ispkcs12)
                 * {
                 *      key.LoadPKCS12(pathKey, alias, password);
                 * }
                 * else if(encrypted)
                 * {
                 *      key.LoadEncrypted(pathKey, password);
                 * }else
                 * {
                 *      key.Load(pathKey);
                 * }*/

                bulkTestWithKeyInfo(cert, key, pathSigned);
                bulkTestWithKeyInfoXPath(cert, key, pathSigned);
                bulkTestWithKeyInfoID(cert, key, pathSigned);
            }
        }