use of de.rub.nds.tlsattacker.core.constants.SignatureAlgorithm 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);
}
}
Aggregations