Example usage for org.bouncycastle.asn1.pkcs RSASSAPSSparams RSASSAPSSparams

List of usage examples for org.bouncycastle.asn1.pkcs RSASSAPSSparams RSASSAPSSparams

Introduction

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

Prototype

public RSASSAPSSparams(AlgorithmIdentifier hashAlgorithm, AlgorithmIdentifier maskGenAlgorithm,
            ASN1Integer saltLength, ASN1Integer trailerField) 

Source Link

Usage

From source file:org.xipki.common.util.AlgorithmUtil.java

License:Open Source License

static public RSASSAPSSparams createPSSRSAParams(final ASN1ObjectIdentifier digestAlgOID)
        throws NoSuchAlgorithmException {
    int saltSize;
    if (X509ObjectIdentifiers.id_SHA1.equals(digestAlgOID)) {
        saltSize = 20;//from   w  w  w .  ja va2s  .c o  m
    } 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 NoSuchAlgorithmException("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);
}

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

License:Open Source License

public static RSASSAPSSparams createPSSRSAParams(final HashAlgoType digestAlg) throws NoSuchAlgorithmException {
    ParamUtil.requireNonNull("digestAlg", digestAlg);
    int saltSize = digestAlg.getLength();
    AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(digestAlg.getOid(), DERNull.INSTANCE);
    return new RSASSAPSSparams(digAlgId, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, digAlgId),
            new ASN1Integer(saltSize), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
}

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

License:Open Source License

static public RSASSAPSSparams createPSSRSAParams(final ASN1ObjectIdentifier digestAlgOID) {
    int saltSize;
    if (X509ObjectIdentifiers.id_SHA1.equals(digestAlgOID)) {
        saltSize = 20;/*ww  w.j a v a  2s .  c  o m*/
    } 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);
}

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

License:Open Source License

public static RSASSAPSSparams createPSSRSAParams(final ASN1ObjectIdentifier digestAlgOid) {
    int saltSize;
    if (X509ObjectIdentifiers.id_SHA1.equals(digestAlgOid)) {
        saltSize = 20;//w  w  w  . j a v  a 2  s  . c o m
    } 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);
}

From source file:org.xwiki.crypto.signer.internal.factory.BcRsaSsaPssSignerFactory.java

License:Open Source License

@Override
protected AlgorithmIdentifier getSignerAlgorithmIdentifier(AsymmetricCipherParameters parameters) {
    if (parameters instanceof AsymmetricKeyParameters) {
        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(X509ObjectIdentifiers.id_SHA1);
        return new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSASSA_PSS, DERNull.INSTANCE);
    } else if (parameters instanceof PssSignerParameters) {
        PssParameters pssParams = ((PssSignerParameters) parameters).getPssParameters();
        BcDigestFactory factory = getDigestFactory(pssParams.getHashAlgorithm());

        return new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSASSA_PSS, new RSASSAPSSparams(
                factory.getAlgorithmIdentifier(),
                new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1,
                        getDigestFactory(pssParams.getMaskGenAlgorithm()).getAlgorithmIdentifier()),
                new ASN1Integer(
                        pssParams.getSaltLength() >= 0 ? pssParams.getSaltLength() : factory.getDigestSize()),
                new ASN1Integer(pssParams.getTrailerField())));
    }//from   w ww . j  av a  2  s. c o  m

    throw new UnsupportedOperationException(PSS_PARAMS_ERROR + parameters.getClass().getName());
}