Example usage for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers md5

List of usage examples for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers md5

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers md5.

Prototype

ASN1ObjectIdentifier md5

To view the source code for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers md5.

Click Source Link

Document

1.2.840.113549.2.5

Usage

From source file:TSAClient.java

License:Apache License

private ASN1ObjectIdentifier getHashObjectIdentifier(String algorithm) {
    if (algorithm.equals("MD2")) {
        return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md2.getId());
    } else if (algorithm.equals("MD5")) {
        return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md5.getId());
    } else if (algorithm.equals("SHA-1")) {
        return new ASN1ObjectIdentifier(OIWObjectIdentifiers.idSHA1.getId());
    } else if (algorithm.equals("SHA-224")) {
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha224.getId());
    } else if (algorithm.equals("SHA-256")) {
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha256.getId());
    } else if (algorithm.equals("SHA-384")) {
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha384.getId());
    } else if (algorithm.equals("SHA-512")) {
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha512.getId());
    } else {//from   w  w  w  .j  ava 2  s .  c  o  m
        return new ASN1ObjectIdentifier(algorithm);
    }
}

From source file:com.modemo.javase.signature.TSAClient.java

License:Apache License

private ASN1ObjectIdentifier getHashObjectIdentifier(String algorithm) {
    switch (algorithm) {
    case "MD2":
        return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md2.getId());
    case "MD5":
        return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md5.getId());
    case "SHA-1":
        return new ASN1ObjectIdentifier(OIWObjectIdentifiers.idSHA1.getId());
    case "SHA-224":
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha224.getId());
    case "SHA-256":
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha256.getId());
    case "SHA-384":
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha384.getId());
    case "SHA-512":
        return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha512.getId());
    default:/*from  w  ww  . ja va  2s.  co m*/
        return new ASN1ObjectIdentifier(algorithm);
    }
}

From source file:org.candlepin.util.X509CRLStreamWriter.java

License:Open Source License

protected static Digest createDigest(AlgorithmIdentifier digAlg) throws CryptoException {
    Digest dig;/*from  w  w w . java  2 s .  c om*/

    if (digAlg.getAlgorithm().equals(OIWObjectIdentifiers.idSHA1)) {
        dig = new SHA1Digest();
    } else if (digAlg.getAlgorithm().equals(NISTObjectIdentifiers.id_sha224)) {
        dig = new SHA224Digest();
    } else if (digAlg.getAlgorithm().equals(NISTObjectIdentifiers.id_sha256)) {
        dig = new SHA256Digest();
    } else if (digAlg.getAlgorithm().equals(NISTObjectIdentifiers.id_sha384)) {
        dig = new SHA384Digest();
    } else if (digAlg.getAlgorithm().equals(NISTObjectIdentifiers.id_sha512)) {
        dig = new SHA384Digest();
    } else if (digAlg.getAlgorithm().equals(PKCSObjectIdentifiers.md5)) {
        dig = new MD5Digest();
    } else if (digAlg.getAlgorithm().equals(PKCSObjectIdentifiers.md4)) {
        dig = new MD4Digest();
    } else {
        throw new CryptoException("Cannot recognize digest.");
    }

    return dig;
}

From source file:org.xipki.pki.scep.util.ScepUtil.java

License:Open Source License

public static ASN1ObjectIdentifier extractDigesetAlgorithmIdentifier(final String sigOid,
        final byte[] sigParams) throws NoSuchAlgorithmException {
    ParamUtil.requireNonBlank("sigOid", sigOid);

    ASN1ObjectIdentifier algOid = new ASN1ObjectIdentifier(sigOid);

    ASN1ObjectIdentifier digestAlgOid;/*from  w w  w .  jav  a 2  s  . c om*/
    if (PKCSObjectIdentifiers.md5WithRSAEncryption.equals(algOid)) {
        digestAlgOid = PKCSObjectIdentifiers.md5;
    } else if (PKCSObjectIdentifiers.sha1WithRSAEncryption.equals(algOid)) {
        digestAlgOid = X509ObjectIdentifiers.id_SHA1;
    } else if (PKCSObjectIdentifiers.sha224WithRSAEncryption.equals(algOid)) {
        digestAlgOid = NISTObjectIdentifiers.id_sha224;
    } else if (PKCSObjectIdentifiers.sha256WithRSAEncryption.equals(algOid)) {
        digestAlgOid = NISTObjectIdentifiers.id_sha256;
    } else if (PKCSObjectIdentifiers.sha384WithRSAEncryption.equals(algOid)) {
        digestAlgOid = NISTObjectIdentifiers.id_sha384;
    } else if (PKCSObjectIdentifiers.sha512WithRSAEncryption.equals(algOid)) {
        digestAlgOid = NISTObjectIdentifiers.id_sha512;
    } else if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigParams);
        digestAlgOid = param.getHashAlgorithm().getAlgorithm();
    } else {
        throw new NoSuchAlgorithmException("unknown signature algorithm" + algOid.getId());
    }

    return digestAlgOid;
}