Examples of PSSParameterSpec


Examples of java.security.spec.PSSParameterSpec

    static public class SHA384withRSA
        extends JDKPSSSigner
    {
        public SHA384withRSA()
        {
            super(new RSABlindedEngine(), new PSSParameterSpec("SHA-384", "MGF1", new MGF1ParameterSpec("SHA-384"), 48, 1));
        }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

    static public class SHA512withRSA
        extends JDKPSSSigner
    {
        public SHA512withRSA()
        {
            super(new RSABlindedEngine(), new PSSParameterSpec("SHA-512", "MGF1", new MGF1ParameterSpec("SHA-512"), 64, 1));
        }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

         * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
         */
        protected byte[] engineGetEncoded()
            throws IOException
        {
            PSSParameterSpec    pssSpec = currentSpec;
            AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
                                                JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()),
                                                new DERNull());
            MGF1ParameterSpec   mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
            AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                PKCSObjectIdentifiers.id_mgf1,
                                                new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull()));
            RSASSAPSSparams     pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField()));
           
            return pssP.getEncoded("DER");
        }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

        {
            try
            {
                RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params));

                currentSpec = new PSSParameterSpec(
                                       pssP.getHashAlgorithm().getObjectId().getId(),
                                       pssP.getMaskGenAlgorithm().getObjectId().getId(),
                                       new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()),
                                       pssP.getSaltLength().getValue().intValue(),
                                       pssP.getTrailerField().getValue().intValue());
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

                return new SimpleTestResult(false, "SHA1 signature verification failed");
            }

            s = Signature.getInstance("SHA1withRSAandMGF1", "BC");
           
            s.setParameter(new PSSParameterSpec(20));
           
            s.initVerify(pubKey);
            s.update(msg1a);
            if (!s.verify(sig1a))
            {
                return new SimpleTestResult(false, "SHA1 signature verification with default parameters failed");
            }
           
            AlgorithmParameters pss = s.getParameters();
            if (!arrayEquals(pss.getEncoded(), new byte[] { 0x30, 0x00 }))
            {
                return new SimpleTestResult(false, "failed default encoding test.");
            }
           
            s = Signature.getInstance("SHA256withRSA/PSS", "BC");

            s.initSign(privKey, new FixedRandom(slt1a));
            s.update(msg1a);
            sig = s.sign();

            pss = s.getParameters();
           
            if (!arrayEquals(sig1b, sig))
            {
                return new SimpleTestResult(false, "PSS Sign test expected " + new String(Hex.encode(sig1b)) + " got " + new String(Hex.encode(sig)));
            }

            s = Signature.getInstance("SHA256withRSAandMGF1", "BC");
           
            s.setParameter(pss.getParameterSpec(PSSParameterSpec.class));
           
            s.initVerify(pubKey);
            s.update(msg1a);
            if (!s.verify(sig1b))
            {
                return new SimpleTestResult(false, "SHA256 signature verification failed");
            }

            //
            // 512 test -with zero salt length
            //
            s = Signature.getInstance("SHA512withRSAandMGF1", "BC");
           
            s.setParameter(new PSSParameterSpec(0));
            s.initSign(privKey);

            s.update(msg1a);
            sig = s.sign();
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

        if (engineParams == null)
        {
            try
            {
                engineParams = AlgorithmParameters.getInstance("PSS", "BC");
                engineParams.init(new PSSParameterSpec(saltLength));
            }
            catch (Exception e)
            {
                throw new RuntimeException(e.toString());
            }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

     * 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) {
        }
    }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

     * </code> ctor<br>
     * Assertion: constructs using valid parameters
     * <code>PSSParameterSpec<code> object
     */
    public final void testPSSParameterSpec0201() {
        AlgorithmParameterSpec aps = new PSSParameterSpec("SHA-1", "MGF1",
                MGF1ParameterSpec.SHA1, 20, 1);
        assertTrue(aps instanceof PSSParameterSpec);
    }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

     * throws <code>NullPointerException</code>
     * if <code>mdName</code> is null
     */
    public final void testPSSParameterSpec0202() {
        try {
            new PSSParameterSpec(null, "MGF1", MGF1ParameterSpec.SHA1, 20, 1);
            fail("Expected NPE not thrown");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

Examples of java.security.spec.PSSParameterSpec

     * throws <code>NullPointerException</code>
     * if <code>mgfName</code> is null
     */
    public final void testPSSParameterSpec0203() {
        try {
            new PSSParameterSpec("SHA-1", null, MGF1ParameterSpec.SHA1, 20, 1);
            fail("Expected NPE not thrown");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.