Java Code Examples for java.security.spec.PSSParameterSpec#getMGFAlgorithm()
The following examples show how to use
java.security.spec.PSSParameterSpec#getMGFAlgorithm() .
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: PSSParameters.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException { if (!(paramSpec instanceof PSSParameterSpec)) { throw new InvalidParameterSpecException ("Inappropriate parameter specification"); } PSSParameterSpec spec = (PSSParameterSpec) paramSpec; String mgfName = spec.getMGFAlgorithm(); if (!spec.getMGFAlgorithm().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.spec = spec; }
Example 2
Source File: PSSParameters.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException { if (!(paramSpec instanceof PSSParameterSpec)) { throw new InvalidParameterSpecException ("Inappropriate parameter specification"); } PSSParameterSpec spec = (PSSParameterSpec) paramSpec; String mgfName = spec.getMGFAlgorithm(); if (!spec.getMGFAlgorithm().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.spec = spec; }
Example 3
Source File: PSSParameters.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException { if (!(paramSpec instanceof PSSParameterSpec)) { throw new InvalidParameterSpecException ("Inappropriate parameter specification"); } PSSParameterSpec spec = (PSSParameterSpec) paramSpec; String mgfName = spec.getMGFAlgorithm(); if (!spec.getMGFAlgorithm().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.spec = spec; }
Example 4
Source File: RSAPSSSignature.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Utility method for checking the key PSS parameters against signature * PSS parameters. * Returns false if any of the digest/MGF algorithms and trailerField * values does not match or if the salt length in key parameters is * larger than the value in signature parameters. */ private static boolean isCompatible(AlgorithmParameterSpec keyParams, PSSParameterSpec sigParams) { if (keyParams == null) { // key with null PSS parameters means no restriction return true; } if (!(keyParams instanceof PSSParameterSpec)) { return false; } // nothing to compare yet, defer the check to when sigParams is set if (sigParams == null) { return true; } PSSParameterSpec pssKeyParams = (PSSParameterSpec) keyParams; // first check the salt length requirement if (pssKeyParams.getSaltLength() > sigParams.getSaltLength()) { return false; } // compare equality of the rest of fields based on DER encoding PSSParameterSpec keyParams2 = new PSSParameterSpec(pssKeyParams.getDigestAlgorithm(), pssKeyParams.getMGFAlgorithm(), pssKeyParams.getMGFParameters(), sigParams.getSaltLength(), pssKeyParams.getTrailerField()); PSSParameters ap = new PSSParameters(); // skip the JCA overhead try { ap.engineInit(keyParams2); byte[] encoded = ap.engineGetEncoded(); ap.engineInit(sigParams); byte[] encoded2 = ap.engineGetEncoded(); return Arrays.equals(encoded, encoded2); } catch (Exception e) { if (DEBUG) { e.printStackTrace(); } return false; } }
Example 5
Source File: RSAPSSSignature.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Utility method for checking the key PSS parameters against signature * PSS parameters. * Returns false if any of the digest/MGF algorithms and trailerField * values does not match or if the salt length in key parameters is * larger than the value in signature parameters. */ private static boolean isCompatible(AlgorithmParameterSpec keyParams, PSSParameterSpec sigParams) { if (keyParams == null) { // key with null PSS parameters means no restriction return true; } if (!(keyParams instanceof PSSParameterSpec)) { return false; } // nothing to compare yet, defer the check to when sigParams is set if (sigParams == null) { return true; } PSSParameterSpec pssKeyParams = (PSSParameterSpec) keyParams; // first check the salt length requirement if (pssKeyParams.getSaltLength() > sigParams.getSaltLength()) { return false; } // compare equality of the rest of fields based on DER encoding PSSParameterSpec keyParams2 = new PSSParameterSpec(pssKeyParams.getDigestAlgorithm(), pssKeyParams.getMGFAlgorithm(), pssKeyParams.getMGFParameters(), sigParams.getSaltLength(), pssKeyParams.getTrailerField()); PSSParameters ap = new PSSParameters(); // skip the JCA overhead try { ap.engineInit(keyParams2); byte[] encoded = ap.engineGetEncoded(); ap.engineInit(sigParams); byte[] encoded2 = ap.engineGetEncoded(); return Arrays.equals(encoded, encoded2); } catch (Exception e) { if (DEBUG) { e.printStackTrace(); } return false; } }
Example 6
Source File: RSAPSSSignature.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Utility method for checking the key PSS parameters against signature * PSS parameters. * Returns false if any of the digest/MGF algorithms and trailerField * values does not match or if the salt length in key parameters is * larger than the value in signature parameters. */ private static boolean isCompatible(AlgorithmParameterSpec keyParams, PSSParameterSpec sigParams) { if (keyParams == null) { // key with null PSS parameters means no restriction return true; } if (!(keyParams instanceof PSSParameterSpec)) { return false; } // nothing to compare yet, defer the check to when sigParams is set if (sigParams == null) { return true; } PSSParameterSpec pssKeyParams = (PSSParameterSpec) keyParams; // first check the salt length requirement if (pssKeyParams.getSaltLength() > sigParams.getSaltLength()) { return false; } // compare equality of the rest of fields based on DER encoding PSSParameterSpec keyParams2 = new PSSParameterSpec(pssKeyParams.getDigestAlgorithm(), pssKeyParams.getMGFAlgorithm(), pssKeyParams.getMGFParameters(), sigParams.getSaltLength(), pssKeyParams.getTrailerField()); PSSParameters ap = new PSSParameters(); // skip the JCA overhead try { ap.engineInit(keyParams2); byte[] encoded = ap.engineGetEncoded(); ap.engineInit(sigParams); byte[] encoded2 = ap.engineGetEncoded(); return Arrays.equals(encoded, encoded2); } catch (Exception e) { if (DEBUG) { e.printStackTrace(); } return false; } }