protected void engineInit( byte[] params) throws IOException { try { RSASSAPSSparams pssP = RSASSAPSSparams.getInstance(params); if (!pssP.getMaskGenAlgorithm().getAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1)) { throw new IOException("unknown mask generation function: " + pssP.getMaskGenAlgorithm().getAlgorithm()); } currentSpec = new PSSParameterSpec( MessageDigestUtils.getDigestName(pssP.getHashAlgorithm().getAlgorithm()), PSSParameterSpec.DEFAULT.getMGFAlgorithm(), new MGF1ParameterSpec(MessageDigestUtils.getDigestName(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getAlgorithm())), 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( byte[] params) throws IOException { try { 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."); } }
private boolean notDefaultPSSParams(ASN1Sequence seq) throws GeneralSecurityException { if (seq == null || seq.size() == 0) { return false; } RSASSAPSSparams pssParams = RSASSAPSSparams.getInstance(seq); if (!pssParams.getMaskGenAlgorithm().getAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1)) { return true; } // same digest for sig and MGF1 if (!pssParams.getHashAlgorithm().equals(AlgorithmIdentifier.getInstance(pssParams.getMaskGenAlgorithm().getParameters()))) { return true; } MessageDigest digest = createDigest(pssParams.getHashAlgorithm()); return pssParams.getSaltLength().intValue() != digest.getDigestLength(); } }