// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.cert.cmp;

import org.bouncycastle.util.Arrays;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.asn1.cmp.CMPCertificate;
import org.bouncycastle.operator.DigestCalculatorProvider;
import org.bouncycastle.cert.X509CertificateHolder;
import java.math.BigInteger;
import org.bouncycastle.asn1.cmp.PKIStatusInfo;
import org.bouncycastle.asn1.cmp.CertStatus;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;

public class CertificateStatus
{
    private DigestAlgorithmIdentifierFinder digestAlgFinder;
    private CertStatus certStatus;
    
    CertificateStatus(final DigestAlgorithmIdentifierFinder digestAlgFinder, final CertStatus certStatus) {
        this.digestAlgFinder = digestAlgFinder;
        this.certStatus = certStatus;
    }
    
    public PKIStatusInfo getStatusInfo() {
        return this.certStatus.getStatusInfo();
    }
    
    public BigInteger getCertRequestID() {
        return this.certStatus.getCertReqId().getValue();
    }
    
    public boolean isVerified(final X509CertificateHolder x509CertificateHolder, final DigestCalculatorProvider digestCalculatorProvider) throws CMPException {
        return this.isVerified(new CMPCertificate(x509CertificateHolder.toASN1Structure()), x509CertificateHolder.getSignatureAlgorithm(), digestCalculatorProvider);
    }
    
    public boolean isVerified(final CMPCertificate cmpCertificate, final AlgorithmIdentifier algorithmIdentifier, final DigestCalculatorProvider digestCalculatorProvider) throws CMPException {
        return Arrays.constantTimeAreEqual(this.certStatus.getCertHash().getOctets(), CMPUtil.calculateCertHash(cmpCertificate, algorithmIdentifier, digestCalculatorProvider, this.digestAlgFinder));
    }
}
