Search in sources :

Example 1 with OtherHash

use of org.bouncycastle.asn1.esf.OtherHash in project signer by demoiselle.

the class RevocationRefs method makeCrlValidatedID.

/**
 * @param extract
 *            CrlValidatedID from X509CRL
 * @return a CrlValidatedID
 * @throws NoSuchAlgorithmException
 * @throws CRLException
 */
private CrlValidatedID makeCrlValidatedID(X509CRL crl) throws NoSuchAlgorithmException, CRLException {
    Digest digest = DigestFactory.getInstance().factoryDefault();
    digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
    OtherHashAlgAndValue otherHashAlgAndValue = new OtherHashAlgAndValue(new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256), new DEROctetString(digest.digest(crl.getEncoded())));
    OtherHash hash = new OtherHash(otherHashAlgAndValue);
    BigInteger crlnumber;
    CrlIdentifier crlid;
    if (crl.getExtensionValue("2.5.29.20") != null) {
        ASN1Integer varASN1Integer = new ASN1Integer(crl.getExtensionValue("2.5.29.20"));
        crlnumber = varASN1Integer.getPositiveValue();
        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate()), crlnumber);
    } else {
        crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate()));
    }
    CrlValidatedID crlvid = new CrlValidatedID(hash, crlid);
    return crlvid;
}
Also used : CrlValidatedID(org.bouncycastle.asn1.esf.CrlValidatedID) Digest(org.demoiselle.signer.cryptography.Digest) DERUTCTime(org.bouncycastle.asn1.DERUTCTime) BigInteger(java.math.BigInteger) CrlIdentifier(org.bouncycastle.asn1.esf.CrlIdentifier) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) X500Name(org.bouncycastle.asn1.x500.X500Name) OtherHashAlgAndValue(org.bouncycastle.asn1.esf.OtherHashAlgAndValue) DEROctetString(org.bouncycastle.asn1.DEROctetString) OtherHash(org.bouncycastle.asn1.esf.OtherHash) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Example 2 with OtherHash

use of org.bouncycastle.asn1.esf.OtherHash in project signer by demoiselle.

the class RevocationRefs method makeOcspResponsesID.

/**
 * make OcspResponsesID from BasicOCSPResp
 *
 * @param ocspResp
 * @return OcspResponsesID
 * @throws NoSuchAlgorithmException
 * @throws OCSPException
 * @throws IOException
 */
@SuppressWarnings("unused")
private OcspResponsesID makeOcspResponsesID(BasicOCSPResp ocspResp) throws NoSuchAlgorithmException, OCSPException, IOException {
    Digest digest = DigestFactory.getInstance().factoryDefault();
    digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
    byte[] digestValue = digest.digest(ocspResp.getEncoded());
    OtherHash hash = new OtherHash(digestValue);
    OcspResponsesID ocsprespid = new OcspResponsesID(new OcspIdentifier(ocspResp.getResponderId().toASN1Object(), new DERGeneralizedTime(ocspResp.getProducedAt())), hash);
    return ocsprespid;
}
Also used : OcspResponsesID(org.bouncycastle.asn1.esf.OcspResponsesID) DERGeneralizedTime(org.bouncycastle.asn1.DERGeneralizedTime) Digest(org.demoiselle.signer.cryptography.Digest) OcspIdentifier(org.bouncycastle.asn1.esf.OcspIdentifier) OtherHash(org.bouncycastle.asn1.esf.OtherHash)

Aggregations

OtherHash (org.bouncycastle.asn1.esf.OtherHash)2 Digest (org.demoiselle.signer.cryptography.Digest)2 BigInteger (java.math.BigInteger)1 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)1 DERGeneralizedTime (org.bouncycastle.asn1.DERGeneralizedTime)1 DEROctetString (org.bouncycastle.asn1.DEROctetString)1 DERUTCTime (org.bouncycastle.asn1.DERUTCTime)1 CrlIdentifier (org.bouncycastle.asn1.esf.CrlIdentifier)1 CrlValidatedID (org.bouncycastle.asn1.esf.CrlValidatedID)1 OcspIdentifier (org.bouncycastle.asn1.esf.OcspIdentifier)1 OcspResponsesID (org.bouncycastle.asn1.esf.OcspResponsesID)1 OtherHashAlgAndValue (org.bouncycastle.asn1.esf.OtherHashAlgAndValue)1 X500Name (org.bouncycastle.asn1.x500.X500Name)1 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)1