Java Code Examples for javax.crypto.spec.OAEPParameterSpec#getMGFParameters()

The following examples show how to use javax.crypto.spec.OAEPParameterSpec#getMGFParameters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestOAEPParameterSpec.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 2
Source File: TestOAEPParameterSpec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 3
Source File: TestOAEPParameterSpec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 4
Source File: TestOAEPParameterSpec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 5
Source File: TestOAEPParameterSpec.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 6
Source File: TestOAEPParameterSpec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 7
Source File: TestOAEPParameterSpec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 8
Source File: TestOAEPParameterSpec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 9
Source File: TestOAEPParameterSpec.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 10
Source File: TestOAEPParameterSpec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean compareMGF(OAEPParameterSpec s1,
    OAEPParameterSpec s2) {
    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;
    }
}
 
Example 11
Source File: OAEPParameters.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 12
Source File: OAEPParameters.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 13
Source File: OAEPParameters.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 14
Source File: OAEPParameters.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 15
Source File: OAEPParameters.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 16
Source File: OAEPParameters.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 17
Source File: OAEPParameters.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 18
Source File: OAEPParameters.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 19
Source File: OAEPParameters.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}
 
Example 20
Source File: OAEPParameters.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {
    if (!(paramSpec instanceof OAEPParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    OAEPParameterSpec spec = (OAEPParameterSpec) paramSpec;
    mdName = spec.getDigestAlgorithm();
    String mgfName = spec.getMGFAlgorithm();
    if (!mgfName.equalsIgnoreCase("MGF1")) {
        throw new InvalidParameterSpecException("Unsupported mgf " +
            mgfName + "; MGF1 only");
    }
    AlgorithmParameterSpec mgfSpec = spec.getMGFParameters();
    if (!(mgfSpec instanceof MGF1ParameterSpec)) {
        throw new InvalidParameterSpecException("Inappropriate mgf " +
            "parameters; non-null MGF1ParameterSpec only");
    }
    this.mgfSpec = (MGF1ParameterSpec) mgfSpec;
    PSource pSrc = spec.getPSource();
    if (pSrc.getAlgorithm().equals("PSpecified")) {
        p = ((PSource.PSpecified) pSrc).getValue();
    } else {
        throw new InvalidParameterSpecException("Unsupported pSource " +
            pSrc.getAlgorithm() + "; PSpecified only");
    }
}