Java 8 OAEPParameterSpec - 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 OAEPParameterSpec class.

This code example shows how to use the following methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getPSource
 
    private static Provider cp;
 
    private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec,
        byte[] p) throws Exception {
        OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1",
            mgfSpec, new PSource.PSpecified(p));
        cp = Security.getProvider("SunJCE");
        System.out.println("Testing provider " + cp.getName() + "...");
        AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp);
 
        ap.init(spec);
        byte[] encoding = ap.getEncoded();
 
        AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp);
        ap2.init(encoding);
 
        OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec
                (OAEPParameterSpec.class);
        return compareSpec(spec, spec2);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getPSource
 
    private static Provider cp;
 
    private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec,
        byte[] p) throws Exception {
        OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1",
            mgfSpec, new PSource.PSpecified(p));
        cp = Security.getProvider("SunJCE");
        System.out.println("Testing provider " + cp.getName() + "...");
        AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp);
 
        ap.init(spec);
        byte[] encoding = ap.getEncoded();
 
        AlgorithmParameters ap2 = AlgorithmParameters.getInstance("OAEP", cp);
        ap2.init(encoding);
 
        OAEPParameterSpec spec2 = (OAEPParameterSpec) ap2.getParameterSpec
                (OAEPParameterSpec.class);
        return compareSpec(spec, spec2);

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getPSource
OAEPParameterSpec spec = (OAEPParameterSpec)params;
                 
                paramSpec = params;
                 
                if (!spec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !spec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
                { 
                    throw new InvalidAlgorithmParameterException("unknown mask generation function specified");
                } 
                 
                if (!(spec.getMGFParameters() instanceof MGF1ParameterSpec))
                { 
                    throw new InvalidAlgorithmParameterException("unkown MGF parameters");
                } 
     
                Digest digest = DigestFactory.getDigest(spec.getDigestAlgorithm());
 
                if (digest == null)
                { 
                    throw new InvalidAlgorithmParameterException("no match on digest algorithm: "+ spec.getDigestAlgorithm());

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
import tests.security.AlgorithmParametersTest; 
 
public class AlgorithmParametersTestOAEP extends AlgorithmParametersTest { 
 
    public AlgorithmParametersTestOAEP() { 
        super("OAEP", new AlgorithmParameterAsymmetricHelper("RSA"), new OAEPParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT)); 
    } 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getDigestAlgorithm, getMGFAlgorithm, getMGFParameters, getPSource
OAEPParameterSpec   spec = (OAEPParameterSpec)params;
                 
                paramSpec = params;
                 
                if (!spec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !spec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
                { 
                    throw new InvalidAlgorithmParameterException("unknown mask generation function specified");
                } 
                 
                if (!(spec.getMGFParameters() instanceof MGF1ParameterSpec))
                { 
                    throw new InvalidAlgorithmParameterException("unkown MGF parameters");
                } 
     
                Digest digest = JCEDigestUtil.getDigest(spec.getDigestAlgorithm());
 
                if (digest == null)
                { 
                    throw new InvalidAlgorithmParameterException("no match on digest algorithm: "+ spec.getDigestAlgorithm());

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 OAEPParameterSpec Methods: