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

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

Introduction

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

Prototype

ASN1ObjectIdentifier sha384WithRSAEncryption

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

Click Source Link

Document

PKCS#1: 1.2.840.113549.1.1.12

Usage

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

License:Open Source License

public static AlgorithmIdentifier getRSASigAlgId(final HashAlgoType hashAlgo, final boolean mgf1)
        throws NoSuchAlgorithmException {
    ParamUtil.requireNonNull("hashAlgo", hashAlgo);
    if (mgf1) {//from  w  w w  .  j a  va  2 s.com
        return buildRSAPSSAlgId(hashAlgo);
    }

    ASN1ObjectIdentifier sigAlgOid;
    switch (hashAlgo) {
    case SHA1:
        sigAlgOid = PKCSObjectIdentifiers.sha1WithRSAEncryption;
        break;
    case SHA224:
        sigAlgOid = PKCSObjectIdentifiers.sha224WithRSAEncryption;
        break;
    case SHA256:
        sigAlgOid = PKCSObjectIdentifiers.sha256WithRSAEncryption;
        break;
    case SHA384:
        sigAlgOid = PKCSObjectIdentifiers.sha384WithRSAEncryption;
        break;
    case SHA512:
        sigAlgOid = PKCSObjectIdentifiers.sha512WithRSAEncryption;
        break;
    case SHA3_224:
        sigAlgOid = NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_224;
        break;
    case SHA3_256:
        sigAlgOid = NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_256;
        break;
    case SHA3_384:
        sigAlgOid = NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_384;
        break;
    case SHA3_512:
        sigAlgOid = NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_512;
        break;
    default:
        throw new RuntimeException("unknown HashAlgoType: " + hashAlgo);
    }

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

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;// w  w  w . j a v a 2  s.  c om
    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.ocsp.client.api.RequestOptions.java

License:Open Source License

private static AlgorithmIdentifier createAlgId(final String algoName) {
    ASN1ObjectIdentifier algOid = null;//  w  w w  .ja  v  a2s . c  o m
    if ("SHA1withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha1WithRSAEncryption;
    } else if ("SHA256withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha256WithRSAEncryption;
    } else if ("SHA384withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha384WithRSAEncryption;
    } else if ("SHA512withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha512WithRSAEncryption;
    } else if ("SHA1withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA1;
    } else if ("SHA256withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA256;
    } else if ("SHA384withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA384;
    } else if ("SHA512withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA512;
    } else if ("SHA1withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA256withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA384withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA512withRSAandMGF1".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.id_RSASSA_PSS;
    } else {
        throw new RuntimeException("Unsupported algorithm " + algoName); // should not happen
    }

    ASN1Encodable params;
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        ASN1ObjectIdentifier digestAlgOid = null;
        if ("SHA1withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = X509ObjectIdentifiers.id_SHA1;
        } else if ("SHA256withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = NISTObjectIdentifiers.id_sha256;
        } else if ("SHA384withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = NISTObjectIdentifiers.id_sha384;
        } else // if("SHA512withRSAandMGF1".equalsIgnoreCase(algoName))
        {
            digestAlgOid = NISTObjectIdentifiers.id_sha512;
        }
        params = createPSSRSAParams(digestAlgOid);
    } else {
        params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(algOid, params);

}

From source file:org.xipki.pki.ocsp.client.api.RequestOptions.java

License:Open Source License

private static AlgorithmIdentifier createAlgId(final String algoName) {
    ASN1ObjectIdentifier algOid = null;//  w ww.  j a  v  a  2  s  .c  o m
    if ("SHA1withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha1WithRSAEncryption;
    } else if ("SHA256withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha256WithRSAEncryption;
    } else if ("SHA384withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha384WithRSAEncryption;
    } else if ("SHA512withRSA".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.sha512WithRSAEncryption;
    } else if ("SHA1withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA1;
    } else if ("SHA256withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA256;
    } else if ("SHA384withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA384;
    } else if ("SHA512withECDSA".equalsIgnoreCase(algoName)) {
        algOid = X9ObjectIdentifiers.ecdsa_with_SHA512;
    } else if ("SHA1withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA256withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA384withRSAandMGF1".equalsIgnoreCase(algoName)
            || "SHA512withRSAandMGF1".equalsIgnoreCase(algoName)) {
        algOid = PKCSObjectIdentifiers.id_RSASSA_PSS;
    } else {
        throw new RuntimeException("Unsupported algorithm " + algoName); // should not happen
    }

    ASN1Encodable params;
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
        ASN1ObjectIdentifier digestAlgOid = null;
        if ("SHA1withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = X509ObjectIdentifiers.id_SHA1;
        } else if ("SHA256withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = NISTObjectIdentifiers.id_sha256;
        } else if ("SHA384withRSAandMGF1".equalsIgnoreCase(algoName)) {
            digestAlgOid = NISTObjectIdentifiers.id_sha384;
        } else { // if ("SHA512withRSAandMGF1".equalsIgnoreCase(algoName))
            digestAlgOid = NISTObjectIdentifiers.id_sha512;
        }
        params = createPSSRSAParams(digestAlgOid);
    } else {
        params = DERNull.INSTANCE;
    }

    return new AlgorithmIdentifier(algOid, params);
}

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  .  j ava2s . 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;
}