Java 8 MGF1ParameterSpec - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MGF1ParameterSpec class.

This code example shows how to use the following methods:getDigestAlgorithm
     * Test for <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
    public final void testGetDigestAlgorithm() { 
        MGF1ParameterSpec aps = new MGF1ParameterSpec(testAlgName);
        assertTrue(testAlgName.equals(aps.getDigestAlgorithm()));
    } 
 
    /** 
     * Test for public static fields and <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
    public final void testFieldsGetDigestAlgorithm() { 
        assertEquals("SHA-1", MGF1ParameterSpec.SHA1.getDigestAlgorithm());
        assertEquals("SHA-256", MGF1ParameterSpec.SHA256.getDigestAlgorithm());
        assertEquals("SHA-384", MGF1ParameterSpec.SHA384.getDigestAlgorithm());
        assertEquals("SHA-512", MGF1ParameterSpec.SHA512.getDigestAlgorithm());
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
        String alg1 = s1.getMGFAlgorithm();
        String alg2 = s2.getMGFAlgorithm();
        if (alg1.equals(alg2)) {
            MGF1ParameterSpec mp1 = (MGF1ParameterSpec)s1.getMGFParameters();
            MGF1ParameterSpec mp2 = (MGF1ParameterSpec)s2.getMGFParameters();
            alg1 = mp1.getDigestAlgorithm();
            alg2 = mp2.getDigestAlgorithm();
            if (alg1.equals(alg2)) {
                return true; 
            } else { 
                System.out.println("MGF's MD algos: " + alg1 + " vs " + alg2);
                return false; 
            } 
        } else { 
            System.out.println("MGF algos: " + alg1 + " vs " + alg2);
            return false; 
        } 
    } 
 
    private static boolean comparePSource(OAEPParameterSpec s1,
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
     * Test for <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
    public final void testGetDigestAlgorithm() { 
        MGF1ParameterSpec aps = new MGF1ParameterSpec(testAlgName);
        assertTrue(testAlgName.equals(aps.getDigestAlgorithm()));
    } 
 
    /** 
     * Test for public static fields and <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
 
    public final void testFieldsGetDigestAlgorithm() { 
        assertEquals("SHA-1", MGF1ParameterSpec.SHA1.getDigestAlgorithm());
        assertEquals("SHA-256", MGF1ParameterSpec.SHA256.getDigestAlgorithm());
        assertEquals("SHA-384", MGF1ParameterSpec.SHA384.getDigestAlgorithm());
        assertEquals("SHA-512", MGF1ParameterSpec.SHA512.getDigestAlgorithm());
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
     * Test for <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
    public final void testGetDigestAlgorithm() { 
        MGF1ParameterSpec aps = new MGF1ParameterSpec(testAlgName);
        assertTrue(testAlgName.equals(aps.getDigestAlgorithm()));
    } 
 
    /** 
     * Test for public static fields and <code>getDigestAlgorithm</code> method<br> 
     * Assertion: returns the algorithm name of the message 
     * digest used by the mask generation function 
     */ 
    public final void testFieldsGetDigestAlgorithm() { 
        assertEquals("SHA-1", MGF1ParameterSpec.SHA1.getDigestAlgorithm());
        assertEquals("SHA-256", MGF1ParameterSpec.SHA256.getDigestAlgorithm());
        assertEquals("SHA-384", MGF1ParameterSpec.SHA384.getDigestAlgorithm());
        assertEquals("SHA-512", MGF1ParameterSpec.SHA512.getDigestAlgorithm());
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
                RSASSAPSSparams pssP = RSASSAPSSparams.getInstance(params);
 
                currentSpec = new PSSParameterSpec(
                                       pssP.getHashAlgorithm().getAlgorithm().getId(), 
                                       pssP.getMaskGenAlgorithm().getAlgorithm().getId(), 
                                       new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getAlgorithm().getId()),
                                       pssP.getSaltLength().intValue(),
                                       pssP.getTrailerField().intValue());
            } 
            catch (ClassCastException e)
            { 
                throw new IOException("Not a valid PSS Parameter encoding.");
            } 
            catch (ArrayIndexOutOfBoundsException e)
            { 
                throw new IOException("Not a valid PSS Parameter encoding.");
            } 
        } 
     
        protected void engineInit( 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
                                                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");
        } 
     
        protected byte[] engineGetEncoded( 
            String format)
            throws IOException 
        { 
            if (format.equalsIgnoreCase("X.509")
                    || format.equalsIgnoreCase("ASN.1"))
            { 
                return engineGetEncoded(); 
            } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
                                                            // END android-changed 
            MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
            AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_mgf1, 
                                                            // BEGIN android-changed 
                                                            new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
                                                            // END android-changed 
            PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
            AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
            RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
     
            try 
            { 
                return oaepP.getEncoded(ASN1Encoding.DER);
            } 
            catch (IOException e)
            { 
                throw new RuntimeException("Error encoding OAEPParameters");
            } 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
        String alg2 = s2.getMGFAlgorithm();
        if (alg1.equals(alg2)) {
            MGF1ParameterSpec mp1 = (MGF1ParameterSpec)s1.getMGFParameters();
            MGF1ParameterSpec mp2 = (MGF1ParameterSpec)s2.getMGFParameters();
            alg1 = mp1.getDigestAlgorithm();
            alg2 = mp2.getDigestAlgorithm();
            if (alg1.equals(alg2)) {
                return true; 
            } else { 
                System.out.println("MGF's MD algos: " + alg1 + " vs " + alg2);
                return false; 
            } 
        } else { 
            System.out.println("MGF algos: " + alg1 + " vs " + alg2);
            return false; 
        } 
    } 
 
    private static boolean comparePSource(OAEPParameterSpec s1,
        OAEPParameterSpec s2) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
                                                            // END android-changed 
            MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
            AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_mgf1, 
                                                            // BEGIN android-changed 
                                                            new AlgorithmIdentifier(DigestFactory.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
                                                            // END android-changed 
            PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
            AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
            RSAESOAEPparams oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
     
            try 
            { 
                return oaepP.getEncoded(ASN1Encoding.DER);
            } 
            catch (IOException e)
            { 
                throw new RuntimeException("Error encoding OAEPParameters");
            } 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getDigestAlgorithm
                                                            JCEDigestUtil.getOID(currentSpec.getDigestAlgorithm()),
                                                            DERNull.THE_ONE); 
            MGF1ParameterSpec       mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
            AlgorithmIdentifier     maskGenAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_mgf1,  
                                                            new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.THE_ONE));
            // END android-changed 
            PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
            AlgorithmIdentifier     pSourceAlgorithm = new AlgorithmIdentifier(
                                                            PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
            RSAESOAEPparams         oaepP = new RSAESOAEPparams(hashAlgorithm, maskGenAlgorithm, pSourceAlgorithm);
     
            try 
            { 
                dOut.writeObject(oaepP);
                dOut.close();
            } 
            catch (IOException e)
            { 
                throw new RuntimeException("Error encoding OAEPParameters");
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 MGF1ParameterSpec Methods: