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

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

Introduction

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

Prototype

ASN1ObjectIdentifier sha224WithRSAEncryption

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

Click Source Link

Document

PKCS#1: 1.2.840.113549.1.1.14

Usage

From source file:org.xipki.commons.security.util.AlgorithmUtil.java

License:Open Source License

public static AlgorithmIdentifier extractDigesetAlgId(final AlgorithmIdentifier sigAlgId)
        throws NoSuchAlgorithmException {
    ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();

    ASN1ObjectIdentifier digestAlgOid;/*  www.java  2s  . co m*/
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        ASN1Encodable asn1Encodable = sigAlgId.getParameters();
        RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable);
        digestAlgOid = param.getHashAlgorithm().getAlgorithm();
    } else {
        HashAlgoType digestAlg;

        if (X9ObjectIdentifiers.ecdsa_with_SHA1.equals(algOid)) {
            digestAlg = HashAlgoType.SHA1;
        } else if (X9ObjectIdentifiers.ecdsa_with_SHA224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA224;
        } else if (X9ObjectIdentifiers.ecdsa_with_SHA256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA256;
        } else if (X9ObjectIdentifiers.ecdsa_with_SHA384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA384;
        } else if (X9ObjectIdentifiers.ecdsa_with_SHA512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA512;
        } else if (NISTObjectIdentifiers.id_ecdsa_with_sha3_224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_224;
        } else if (NISTObjectIdentifiers.id_ecdsa_with_sha3_256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_256;
        } else if (NISTObjectIdentifiers.id_ecdsa_with_sha3_384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_384;
        } else if (NISTObjectIdentifiers.id_ecdsa_with_sha3_512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_512;
        } else if (BSIObjectIdentifiers.ecdsa_plain_SHA1.equals(algOid)) {
            digestAlg = HashAlgoType.SHA1;
        } else if (BSIObjectIdentifiers.ecdsa_plain_SHA224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA224;
        } else if (BSIObjectIdentifiers.ecdsa_plain_SHA256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA256;
        } else if (BSIObjectIdentifiers.ecdsa_plain_SHA384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA384;
        } else if (BSIObjectIdentifiers.ecdsa_plain_SHA512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA512;
        } else if (X9ObjectIdentifiers.id_dsa_with_sha1.equals(algOid)) {
            digestAlg = HashAlgoType.SHA1;
        } else if (NISTObjectIdentifiers.dsa_with_sha224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA224;
        } else if (NISTObjectIdentifiers.dsa_with_sha256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA256;
        } else if (NISTObjectIdentifiers.dsa_with_sha384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA384;
        } else if (NISTObjectIdentifiers.dsa_with_sha512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA512;
        } else if (NISTObjectIdentifiers.id_dsa_with_sha3_224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_224;
        } else if (NISTObjectIdentifiers.id_dsa_with_sha3_256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_256;
        } else if (NISTObjectIdentifiers.id_dsa_with_sha3_384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_384;
        } else if (NISTObjectIdentifiers.id_dsa_with_sha3_512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_512;
        } else if (PKCSObjectIdentifiers.sha1WithRSAEncryption.equals(algOid)) {
            digestAlg = HashAlgoType.SHA1;
        } else if (PKCSObjectIdentifiers.sha224WithRSAEncryption.equals(algOid)) {
            digestAlg = HashAlgoType.SHA224;
        } else if (PKCSObjectIdentifiers.sha256WithRSAEncryption.equals(algOid)) {
            digestAlg = HashAlgoType.SHA256;
        } else if (PKCSObjectIdentifiers.sha384WithRSAEncryption.equals(algOid)) {
            digestAlg = HashAlgoType.SHA384;
        } else if (PKCSObjectIdentifiers.sha512WithRSAEncryption.equals(algOid)) {
            digestAlg = HashAlgoType.SHA512;
        } else if (NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_224.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_224;
        } else if (NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_256.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_256;
        } else if (NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_384.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_384;
        } else if (NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_512.equals(algOid)) {
            digestAlg = HashAlgoType.SHA3_512;
        } else {
            throw new NoSuchAlgorithmException("unknown signature algorithm" + algOid.getId());
        }

        digestAlgOid = digestAlg.getOid();
    }

    return new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE);
}

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;// w  w  w. j  a  v  a 2s . 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;
}