Search in sources :

Example 1 with HashAlgorithm

use of de.rub.nds.tlsattacker.core.constants.HashAlgorithm in project TLS-Scanner by RUB-NDS.

the class CertificateReportGenerator method setSignatureAndHashAlgorithm.

private static void setSignatureAndHashAlgorithm(CertificateReportImplementation report, org.bouncycastle.asn1.x509.Certificate cert) {
    String sigAndHashString = null;
    try {
        X509CertificateObject x509Cert = new X509CertificateObject(cert);
        sigAndHashString = x509Cert.getSigAlgName();
        if (sigAndHashString != null) {
            String[] algos = sigAndHashString.toUpperCase().split("WITH");
            if (algos.length != 2) {
                LOGGER.warn("Could not parse " + sigAndHashString + " into a reasonable SignatureAndHash algorithm");
                return;
            }
            SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.valueOf(algos[1]);
            HashAlgorithm hashAlgorithm = HashAlgorithm.valueOf(algos[0]);
            if (hashAlgorithm == null) {
                LOGGER.warn("Parsed an unknown HashAlgorithm");
                return;
            }
            if (signatureAlgorithm == null) {
                LOGGER.warn("Parsed an unknown SignatureAlgorithm");
                return;
            }
            SignatureAndHashAlgorithm sigHashAlgo = new SignatureAndHashAlgorithm(signatureAlgorithm, hashAlgorithm);
            report.setSignatureAndHashAlgorithm(sigHashAlgo);
        }
    } catch (Exception E) {
        LOGGER.debug("Could not extraxt SignatureAndHashAlgorithm from String:" + sigAndHashString, E);
    }
}
Also used : X509CertificateObject(org.bouncycastle.jce.provider.X509CertificateObject) SignatureAlgorithm(de.rub.nds.tlsattacker.core.constants.SignatureAlgorithm) CertificateParsingException(java.security.cert.CertificateParsingException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SignatureAndHashAlgorithm(de.rub.nds.tlsattacker.core.constants.SignatureAndHashAlgorithm) HashAlgorithm(de.rub.nds.tlsattacker.core.constants.HashAlgorithm) SignatureAndHashAlgorithm(de.rub.nds.tlsattacker.core.constants.SignatureAndHashAlgorithm)

Aggregations

HashAlgorithm (de.rub.nds.tlsattacker.core.constants.HashAlgorithm)1 SignatureAlgorithm (de.rub.nds.tlsattacker.core.constants.SignatureAlgorithm)1 SignatureAndHashAlgorithm (de.rub.nds.tlsattacker.core.constants.SignatureAndHashAlgorithm)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateParsingException (java.security.cert.CertificateParsingException)1 X509CertificateObject (org.bouncycastle.jce.provider.X509CertificateObject)1