Exemplo n.º 1
0
        private static bool KeyIsVulnerable(StringReader pem_stream)
        {
            var pemReader = new Org.BouncyCastle.OpenSsl.PemReader(pem_stream);
            RsaKeyParameters rsaKeyParameters = (RsaKeyParameters)pemReader.ReadObject();

            if (rsaKeyParameters == null)
            {
                throw new InvalidOperationException("Incorrect PEM data processed");
            }
            return(RocaCmTest.IsVulnerable(rsaKeyParameters));
        }
Exemplo n.º 2
0
        private static bool CertIsVulnerable(X509Certificate2 cert)
        {
            X509CertificateParser x509CertificateParser = new X509CertificateParser();

            Org.BouncyCastle.X509.X509Certificate x509Certificate = DotNetUtilities.FromX509Certificate(cert);
            RsaKeyParameters rsaKeyParameters = x509Certificate.GetPublicKey() as RsaKeyParameters;

            if (rsaKeyParameters == null)
            {
                throw new InvalidOperationException("not valid RSA certificate");
            }
            return(RocaCmTest.IsVulnerable(rsaKeyParameters));
        }
Exemplo n.º 3
0
        private static bool CertIsVulnerable(string certFile)
        {
            X509CertificateParser x509CertificateParser = new X509CertificateParser();

            Org.BouncyCastle.X509.X509Certificate x509Certificate = x509CertificateParser.ReadCertificate(File.ReadAllBytes(certFile));
            RsaKeyParameters rsaKeyParameters = x509Certificate.GetPublicKey() as RsaKeyParameters;

            if (rsaKeyParameters == null)
            {
                throw new InvalidOperationException(certFile + " is not valid RSA certificate or key");
            }
            return(RocaCmTest.IsVulnerable(rsaKeyParameters));
        }