List of usage examples for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers sha512WithRSAEncryption
ASN1ObjectIdentifier sha512WithRSAEncryption
To view the source code for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers sha512WithRSAEncryption.
Click Source Link
From source file:org.xipki.commons.security.util.AlgorithmUtil.java
License:Open Source License
public static boolean isRSASigAlgId(final AlgorithmIdentifier algId) { ParamUtil.requireNonNull("algId", algId); ASN1ObjectIdentifier oid = algId.getAlgorithm(); if (PKCSObjectIdentifiers.sha1WithRSAEncryption.equals(oid) || PKCSObjectIdentifiers.sha224WithRSAEncryption.equals(oid) || PKCSObjectIdentifiers.sha256WithRSAEncryption.equals(oid) || PKCSObjectIdentifiers.sha384WithRSAEncryption.equals(oid) || PKCSObjectIdentifiers.sha512WithRSAEncryption.equals(oid) || NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_224.equals(oid) || NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_256.equals(oid) || NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_384.equals(oid) || NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_512.equals(oid) || PKCSObjectIdentifiers.id_RSASSA_PSS.equals(oid)) { return true; }//from w ww.jav a2s . c o m return false; }
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 . jav a 2 s . c o m*/ 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;//from w w w. j a v a 2 s . 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.ocsp.client.api.RequestOptions.java
License:Open Source License
private static AlgorithmIdentifier createAlgId(final String algoName) { ASN1ObjectIdentifier algOid = null;//from w w w.java2 s. co 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;//from w w w . ja 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;/* w w w . j a v a 2 s . com*/ 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; }