use of org.bouncycastle.asn1.pkcs.RSASSAPSSparams in project xipki by xipki.
the class RequestOptions method createPSSRSAParams.
// method createAlgId
// CHECKSTYLE:SKIP
public static RSASSAPSSparams createPSSRSAParams(ASN1ObjectIdentifier digestAlgOid) {
int saltSize;
if (X509ObjectIdentifiers.id_SHA1.equals(digestAlgOid)) {
saltSize = 20;
} else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOid)) {
saltSize = 28;
} else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOid)) {
saltSize = 32;
} else if (NISTObjectIdentifiers.id_sha384.equals(digestAlgOid)) {
saltSize = 48;
} else if (NISTObjectIdentifiers.id_sha512.equals(digestAlgOid)) {
saltSize = 64;
} else {
throw new RuntimeException("unknown digest algorithm " + digestAlgOid);
}
AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE);
return new RSASSAPSSparams(digAlgId, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, digAlgId), new ASN1Integer(saltSize), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
}
use of org.bouncycastle.asn1.pkcs.RSASSAPSSparams in project xipki by xipki.
the class ResponderSigner method getSignatureAlgorithmName.
private static String getSignatureAlgorithmName(AlgorithmIdentifier sigAlgId) {
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
if (!PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
return algOid.getId();
}
ASN1Encodable asn1Encodable = sigAlgId.getParameters();
RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable);
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
return digestAlgOid.getId() + "WITHRSAANDMGF1";
}
use of org.bouncycastle.asn1.pkcs.RSASSAPSSparams in project xipki by xipki.
the class AlgorithmUtil method getSignatureAlgoName.
public static String getSignatureAlgoName(AlgorithmIdentifier sigAlgId) throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm();
String name = null;
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
name = digestOidToMgf1SigNameMap.get(digestAlgOid);
if (name == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
} else {
name = sigAlgOidToNameMap.get(algOid);
}
if (name == null) {
throw new NoSuchAlgorithmException("unsupported signature algorithm " + algOid.getId());
}
return name;
}
use of org.bouncycastle.asn1.pkcs.RSASSAPSSparams in project xipki by xipki.
the class ScepUtil method extractDigesetAlgorithmIdentifier.
public static ASN1ObjectIdentifier extractDigesetAlgorithmIdentifier(String sigOid, byte[] sigParams) throws NoSuchAlgorithmException {
requireNonBlank("sigOid", sigOid);
ASN1ObjectIdentifier algOid = new ASN1ObjectIdentifier(sigOid);
ASN1ObjectIdentifier digestAlgOid;
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;
}
Aggregations