Java 类java.security.spec.PSSParameterSpec 实例源码

项目:ipack    文件:OperatorHelper.java   
public Signature createRawSignature(AlgorithmIdentifier algorithm)
{
    Signature   sig;

    try
    {
        String algName = getSignatureName(algorithm);

        algName = "NONE" + algName.substring(algName.indexOf("WITH"));

        sig = helper.createSignature(algName);

        // RFC 4056
        // When the id-RSASSA-PSS algorithm identifier is used for a signature,
        // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params.
        if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            AlgorithmParameters params = helper.createAlgorithmParameters(algName);

            params.init(algorithm.getParameters().toASN1Primitive().getEncoded(), "ASN.1");

            PSSParameterSpec spec = (PSSParameterSpec)params.getParameterSpec(PSSParameterSpec.class);
            sig.setParameter(spec);
        }
    }
    catch (Exception e)
    {
        return null;
    }

    return sig;
}
项目:ipack    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:ipack    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:Aki-SSL    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:Aki-SSL    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:RipplePower    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:RipplePower    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:CryptMeme    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:CryptMeme    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:ripple-lib-java    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:ripple-lib-java    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:irma_future_id    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:irma_future_id    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:irma_future_id    文件:PSSSignatureSpi.java   
protected AlgorithmParameters engineGetParameters()
{
    if (engineParams == null)
    {
        try
        {
            engineParams = AlgorithmParameters.getInstance("PSS", BouncyCastleProvider.PROVIDER_NAME);
            engineParams.init(new PSSParameterSpec(saltLength));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.toString());
        }
    }

    return engineParams;
}
项目:bc-java    文件:AlgorithmParametersSpi.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded() 
    throws IOException
{
    PSSParameterSpec pssSpec = currentSpec;
    AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                        DigestFactory.getOID(pssSpec.getDigestAlgorithm()),
                                        DERNull.INSTANCE);
    MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
    AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                        PKCSObjectIdentifiers.id_mgf1,
                                        new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
    RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new ASN1Integer(pssSpec.getSaltLength()), new ASN1Integer(pssSpec.getTrailerField()));

    return pssP.getEncoded("DER");
}
项目:bc-java    文件:PSSSignatureSpi.java   
protected PSSSignatureSpi(
    AsymmetricBlockCipher signer,
    PSSParameterSpec baseParamSpec,
    boolean isRaw)
{
    this.signer = signer;
    this.originalSpec = baseParamSpec;

    if (baseParamSpec == null)
    {
        this.paramSpec = PSSParameterSpec.DEFAULT;
    }
    else
    {
        this.paramSpec = baseParamSpec;
    }

    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:bc-java    文件:PSSSignatureSpi.java   
protected AlgorithmParameters engineGetParameters()
{
    if (engineParams == null)
    {
        try
        {
            engineParams = AlgorithmParameters.getInstance("PSS", BouncyCastleProvider.PROVIDER_NAME);
            engineParams.init(new PSSParameterSpec(saltLength));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.toString());
        }
    }

    return engineParams;
}
项目:DroidText    文件:JDKPSSSigner.java   
protected AlgorithmParameters engineGetParameters() 
{
    if (engineParams == null)
    {
        try
        {
            engineParams = AlgorithmParameters.getInstance("PSS", "BC");
            engineParams.init(new PSSParameterSpec(saltLength));
        }
        catch (Exception e)
        {
            throw new RuntimeException(e.toString());
        }
    }

    return engineParams;
}
项目:DroidText    文件:JDKAlgorithmParameters.java   
/**
 * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
 */
protected byte[] engineGetEncoded()
{
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);
    PSSParameterSpec    pssSpec = (PSSParameterSpec)currentSpec;
    RSASSAPSSparams     pssP = new RSASSAPSSparams(RSASSAPSSparams.DEFAULT_HASH_ALGORITHM, RSASSAPSSparams.DEFAULT_MASK_GEN_FUNCTION, new DERInteger(pssSpec.getSaltLength()), RSASSAPSSparams.DEFAULT_TRAILER_FIELD);
    try
    {
        dOut.writeObject(pssP);
        dOut.close();
    }
    catch (IOException e)
    {
        throw new RuntimeException("Error encoding PSSParameters");
    }

    return bOut.toByteArray();
}
项目:ipack    文件:AlgorithmParametersSpi.java   
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == PSSParameterSpec.class && currentSpec != null)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
}
项目:ipack    文件:AlgorithmParametersSpi.java   
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PSSParameterSpec))
    {
        throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
    }

    this.currentSpec = (PSSParameterSpec)paramSpec;
}
项目:xitk    文件:P11RSAPSSSignatureSpi.java   
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) {
    this.originalSpec = baseParamSpec;
    this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec;
    this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm());
    this.saltLength = paramSpec.getSaltLength();
    this.trailer = getTrailer(paramSpec.getTrailerField());
    this.isRaw = isRaw;

    setupContentDigest();
}
项目:ReCRED_FIDO_UAF_OIDC    文件:RSA.java   
public static byte[] signPSS(PrivateKey privateKey,
        byte[] signedData) throws SignatureException,
        InvalidKeyException, NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException {
    Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
    signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
            new MGF1ParameterSpec("SHA-256"), 32, 1));
    signature.initSign(privateKey);
    signature.update(signedData);
    return signature.sign();
}
项目:ReCRED_FIDO_UAF_OIDC    文件:RSA.java   
public static boolean verifyPSS(PublicKey publicKey,
        byte[] signedData, byte[] sig) throws SignatureException,
        InvalidKeyException, NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeySpecException {
    Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
    signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
            new MGF1ParameterSpec("SHA-256"), 32, 1));
    signature.initVerify(publicKey);
    signature.update(signedData);
    return signature.verify(sig);
}
项目:Android-GetAPKInfo    文件:ApkSignatureSchemeV2Verifier.java   
private static Pair<String, ? extends AlgorithmParameterSpec>
        getSignatureAlgorithmJcaSignatureAlgorithm(int sigAlgorithm) {
    switch (sigAlgorithm) {
        case SIGNATURE_RSA_PSS_WITH_SHA256:
            return Pair.create(
                    "SHA256withRSA/PSS",
                    new PSSParameterSpec(
                            "SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 256 / 8, 1));
        case SIGNATURE_RSA_PSS_WITH_SHA512:
            return Pair.create(
                    "SHA512withRSA/PSS",
                    new PSSParameterSpec(
                            "SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 512 / 8, 1));
        case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256:
            return Pair.create("SHA256withRSA", null);
        case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512:
            return Pair.create("SHA512withRSA", null);
        case SIGNATURE_ECDSA_WITH_SHA256:
            return Pair.create("SHA256withECDSA", null);
        case SIGNATURE_ECDSA_WITH_SHA512:
            return Pair.create("SHA512withECDSA", null);
        case SIGNATURE_DSA_WITH_SHA256:
            return Pair.create("SHA256withDSA", null);
        default:
            throw new IllegalArgumentException(
                    "Unknown signature algorithm: 0x"
                            + Long.toHexString(sigAlgorithm & 0xffffffff));
    }
}
项目:Jose4j    文件:RsaUsingShaAlgorithm.java   
public RsaPssSha256()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA256, "SHA256withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA256;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 32, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
项目:Jose4j    文件:RsaUsingShaAlgorithm.java   
public RsaPssSha384()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA384, "SHA384withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA384;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 48, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
项目:Jose4j    文件:RsaUsingShaAlgorithm.java   
public RsaPssSha512()
{
    super(AlgorithmIdentifiers.RSA_PSS_USING_SHA512, "SHA512withRSAandMGF1");
    MGF1ParameterSpec mgf1pec = MGF1ParameterSpec.SHA512;
    PSSParameterSpec pssSpec = new PSSParameterSpec(mgf1pec.getDigestAlgorithm(), MGF1, mgf1pec, 64, TRAILER);
    setAlgorithmParameterSpec(pssSpec);
}
项目:Aki-SSL    文件:OperatorHelper.java   
public Signature createRawSignature(AlgorithmIdentifier algorithm)
{
    Signature   sig;

    try
    {
        String algName = getSignatureName(algorithm);

        algName = "NONE" + algName.substring(algName.indexOf("WITH"));

        sig = helper.createSignature(algName);

        // RFC 4056
        // When the id-RSASSA-PSS algorithm identifier is used for a signature,
        // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params.
        if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
        {
            AlgorithmParameters params = helper.createAlgorithmParameters(algName);

            AlgorithmParametersUtils.loadParameters(params, algorithm.getParameters());

            PSSParameterSpec spec = (PSSParameterSpec)params.getParameterSpec(PSSParameterSpec.class);
            sig.setParameter(spec);
        }
    }
    catch (Exception e)
    {
        return null;
    }

    return sig;
}
项目:Aki-SSL    文件:AlgorithmParametersSpi.java   
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == PSSParameterSpec.class && currentSpec != null)
    {
        return currentSpec;
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
}
项目:Aki-SSL    文件:AlgorithmParametersSpi.java   
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PSSParameterSpec))
    {
        throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
    }

    this.currentSpec = (PSSParameterSpec)paramSpec;
}
项目:UAF    文件:RSA.java   
public static byte[] signPSS(PrivateKey privateKey,
        byte[] signedData) throws SignatureException,
        InvalidKeyException, NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException {
    Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
    signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
            new MGF1ParameterSpec("SHA-256"), 32, 1));
    signature.initSign(privateKey);
    signature.update(signedData);
    return signature.sign();
}
项目:UAF    文件:RSA.java   
public static boolean verifyPSS(PublicKey publicKey,
        byte[] signedData, byte[] sig) throws SignatureException,
        InvalidKeyException, NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeySpecException {
    Signature signature = Signature.getInstance("SHA256withRSA/PSS", BC);
    signature.setParameter(new PSSParameterSpec("SHA-256", "MGF1",
            new MGF1ParameterSpec("SHA-256"), 32, 1));
    signature.initVerify(publicKey);
    signature.update(signedData);
    return signature.verify(sig);
}
项目:j2objc    文件:PSSParameterSpecTest.java   
/**
 * Test #2 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion:
 * throws <code>IllegalArgumentException</code>
 * if <code>saltLen</code> less than 0
 */
public final void testPSSParameterSpec0102() {
    try {
        new PSSParameterSpec(-1);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #1 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion: constructs using valid parameter
 * <code>PSSParameterSpec<code> object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies constructor with valid parameter.",
    method = "PSSParameterSpec",
    args = {int.class}
)
public final void testPSSParameterSpec0101() {
    AlgorithmParameterSpec aps = new PSSParameterSpec(20);
    assertTrue(aps instanceof PSSParameterSpec);
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #2 for <code>PSSParameterSpec(int)</code> ctor<br>
 * Assertion:
 * throws <code>IllegalArgumentException</code>
 * if <code>saltLen</code> less than 0
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies IllegalArgumentException.",
    method = "PSSParameterSpec",
    args = {int.class}
)
public final void testPSSParameterSpec0102() {
    try {
        new PSSParameterSpec(-1);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #1 for
 * <code>
 * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
 * </code> ctor<br>
 * Assertion: constructs using valid parameters
 * <code>PSSParameterSpec<code> object
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies constructor with valid parameters.",
    method = "PSSParameterSpec",
    args = {java.lang.String.class, java.lang.String.class, java.security.spec.AlgorithmParameterSpec.class, int.class, int.class}
)
public final void testPSSParameterSpec0201() {
    AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1",
            MGF1ParameterSpec.SHA1, 20, 1);
    assertTrue(aps instanceof PSSParameterSpec);
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #2 for
 * <code>
 * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
 * </code> ctor<br>
 * Assertion:
 * throws <code>NullPointerException</code>
 * if <code>mdName</code> is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies NullPointerException.",
    method = "PSSParameterSpec",
    args = {java.lang.String.class, java.lang.String.class, java.security.spec.AlgorithmParameterSpec.class, int.class, int.class}
)
public final void testPSSParameterSpec0202() {
    try {
        new PSSParameterSpec(null, "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #3 for
 * <code>
 * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
 * </code> ctor<br>
 * Assertion:
 * throws <code>NullPointerException</code>
 * if <code>mgfName</code> is null
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies NullPointerException.",
    method = "PSSParameterSpec",
    args = {java.lang.String.class, java.lang.String.class, java.security.spec.AlgorithmParameterSpec.class, int.class, int.class}
)
public final void testPSSParameterSpec0203() {
    try {
        new PSSParameterSpec("SHA-1", null, MGF1ParameterSpec.SHA1, 20, 1);
        fail("Expected NPE not thrown");
    } catch (NullPointerException e) {
    }
}
项目:In-the-Box-Fork    文件:PSSParameterSpecTest.java   
/**
 * Test #4 for
 * <code>
 * PSSParameterSpec(String,String,AlgorithmParameterSpec,int,int)
 * </code> ctor<br>
 * Assertion:
 * throws <code>IllegalArgumentException<code>
 * if <code>saltLen<code> less than 0
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies IllegalArgumentException.",
    method = "PSSParameterSpec",
    args = {java.lang.String.class, java.lang.String.class, java.security.spec.AlgorithmParameterSpec.class, int.class, int.class}
)
public final void testPSSParameterSpec0204() {
    try {
        new PSSParameterSpec("SHA-1", "MGF1",
                MGF1ParameterSpec.SHA1, -20, 1);
        fail("Expected IAE not thrown");
    } catch (IllegalArgumentException e) {
    }
}