Refine search
private static Map<SignatureAlgorithm, PSSParameterSpec> createPssParameterSpecs() { Map<SignatureAlgorithm, PSSParameterSpec> m = new HashMap<SignatureAlgorithm, PSSParameterSpec>(); MGF1ParameterSpec ps = MGF1ParameterSpec.SHA256; PSSParameterSpec spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 32, 1); m.put(SignatureAlgorithm.PS256, spec); ps = MGF1ParameterSpec.SHA384; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 48, 1); m.put(SignatureAlgorithm.PS384, spec); ps = MGF1ParameterSpec.SHA512; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 64, 1); m.put(SignatureAlgorithm.PS512, spec); return m; }
public SHA512withRSA() { super(new PSSParameterSpec("SHA-512", "MGF1", new MGF1ParameterSpec("SHA-512"), 64, 1)); }
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId())) { throw new InvalidParameterException("unknown mask generation function specified"); if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) { throw new InvalidParameterException("unkown MGF parameters"); MGF1ParameterSpec mgfParams = (MGF1ParameterSpec) newParamSpec.getMGFParameters(); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters."); Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm()); "no match on MGF digest algorithm: " + mgfParams.getDigestAlgorithm()); this.paramSpec = newParamSpec; this.mgfDigest = newDigest; this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField());
protected P11RSAPSSSignatureSpi(final PSSParameterSpec baseParamSpec, final boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
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."); } }
@Override protected byte[] engineGetEncoded() throws IOException { long cbbRef = 0; long seqRef = 0; try { cbbRef = NativeCrypto.asn1_write_init(); seqRef = NativeCrypto.asn1_write_sequence(cbbRef); OAEPParameters.writeHashAndMgfHash(seqRef, spec.getDigestAlgorithm(), (MGF1ParameterSpec) spec.getMGFParameters()); // Implementations are prohibited from writing the default value for any of the fields if (spec.getSaltLength() != 20) { long tagRef = 0; try { tagRef = NativeCrypto.asn1_write_tag(seqRef, 2); NativeCrypto.asn1_write_uint64(tagRef, spec.getSaltLength()); } finally { NativeCrypto.asn1_write_flush(seqRef); NativeCrypto.asn1_write_free(tagRef); } } // 1 is the only legal value for trailerField and the default, so ignore it return NativeCrypto.asn1_write_finish(cbbRef); } catch (IOException e) { NativeCrypto.asn1_write_cleanup(cbbRef); throw e; } finally { NativeCrypto.asn1_write_free(seqRef); NativeCrypto.asn1_write_free(cbbRef); } }
jcaAlg = "SHA256withRSAandMGF1"; pssSpec = new PSSParameterSpec("SHA256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1); } else if (alg.equals(JWSAlgorithm.PS384)) { jcaAlg = "SHA384withRSAandMGF1"; pssSpec = new PSSParameterSpec("SHA384", "MGF1", MGF1ParameterSpec.SHA384, 48, 1); } else if (alg.equals(JWSAlgorithm.PS512)) { jcaAlg = "SHA512withRSAandMGF1"; pssSpec = new PSSParameterSpec("SHA512", "MGF1", MGF1ParameterSpec.SHA512, 64, 1); } else { throw new JOSEException(AlgorithmSupportMessage.unsupportedJWSAlgorithm(alg, RSASSAProvider.SUPPORTED_ALGORITHMS));
public SHA3_256withRSA() { super(new PSSParameterSpec("SHA3-256", "MGF1", new MGF1ParameterSpec("SHA3-256"), 32, 1)); }
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId())) { throw new InvalidParameterException("unknown mask generation function specified"); if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) { throw new InvalidParameterException("unkown MGF parameters"); MGF1ParameterSpec mgfParams = (MGF1ParameterSpec) newParamSpec.getMGFParameters(); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters."); Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm()); "no match on MGF digest algorithm: " + mgfParams.getDigestAlgorithm()); this.paramSpec = newParamSpec; this.mgfDigest = newDigest; this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField());
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
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."); } }
@Override protected byte[] engineGetEncoded() throws IOException { long cbbRef = 0; long seqRef = 0; try { cbbRef = NativeCrypto.asn1_write_init(); seqRef = NativeCrypto.asn1_write_sequence(cbbRef); OAEPParameters.writeHashAndMgfHash(seqRef, spec.getDigestAlgorithm(), (MGF1ParameterSpec) spec.getMGFParameters()); // Implementations are prohibited from writing the default value for any of the fields if (spec.getSaltLength() != 20) { long tagRef = 0; try { tagRef = NativeCrypto.asn1_write_tag(seqRef, 2); NativeCrypto.asn1_write_uint64(tagRef, spec.getSaltLength()); } finally { NativeCrypto.asn1_write_flush(seqRef); NativeCrypto.asn1_write_free(tagRef); } } // 1 is the only legal value for trailerField and the default, so ignore it return NativeCrypto.asn1_write_finish(cbbRef); } catch (IOException e) { NativeCrypto.asn1_write_cleanup(cbbRef); throw e; } finally { NativeCrypto.asn1_write_free(seqRef); NativeCrypto.asn1_write_free(cbbRef); } }
public SHA384withRSA() { super(new PSSParameterSpec("SHA-384", "MGF1", new MGF1ParameterSpec("SHA-384"), 48, 1)); }
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals( PKCSObjectIdentifiers.id_mgf1.getId())) { throw new InvalidParameterException("unknown mask generation function specified"); if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) { throw new InvalidParameterException("unkown MGF parameters"); MGF1ParameterSpec mgfParams = (MGF1ParameterSpec) newParamSpec.getMGFParameters(); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) { throw new InvalidParameterException( "digest algorithm for MGF should be the same as for PSS parameters."); Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm()); "no match on MGF digest algorithm: " + mgfParams.getDigestAlgorithm()); this.paramSpec = newParamSpec; this.mgfDigest = newDigest; this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField());
protected P11RSAPSSSignatureSpi(PSSParameterSpec baseParamSpec, boolean isRaw) { this.originalSpec = baseParamSpec; this.paramSpec = (baseParamSpec == null) ? PSSParameterSpec.DEFAULT : baseParamSpec; this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
private static Map<SignatureAlgorithm, PSSParameterSpec> createPssParameterSpecs() { Map<SignatureAlgorithm, PSSParameterSpec> m = new HashMap<SignatureAlgorithm, PSSParameterSpec>(); MGF1ParameterSpec ps = MGF1ParameterSpec.SHA256; PSSParameterSpec spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 32, 1); m.put(SignatureAlgorithm.PS256, spec); ps = MGF1ParameterSpec.SHA384; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 48, 1); m.put(SignatureAlgorithm.PS384, spec); ps = MGF1ParameterSpec.SHA512; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 64, 1); m.put(SignatureAlgorithm.PS512, spec); return m; }
public SHA3_384withRSA() { super(new PSSParameterSpec("SHA3-384", "MGF1", new MGF1ParameterSpec("SHA3-384"), 48, 1)); }
if (!DigestFactory.isSameDigest(originalSpec.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm()); if (!newParamSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !newParamSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId())) if (!(newParamSpec.getMGFParameters() instanceof MGF1ParameterSpec)) MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)newParamSpec.getMGFParameters(); if (!DigestFactory.isSameDigest(mgfParams.getDigestAlgorithm(), newParamSpec.getDigestAlgorithm())) Digest newDigest = DigestFactory.getDigest(mgfParams.getDigestAlgorithm()); throw new InvalidParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm()); this.paramSpec = newParamSpec; this.mgfDigest = newDigest; this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField());
protected PSSSignatureSpi( AsymmetricBlockCipher signer, PSSParameterSpec baseParamSpec, boolean isRaw) { this.signer = signer; this.originalSpec = baseParamSpec; if (baseParamSpec == null) { this.paramSpec = PSSParameterSpec.DEFAULT; } else { this.paramSpec = baseParamSpec; } this.mgfDigest = DigestFactory.getDigest(paramSpec.getDigestAlgorithm()); this.saltLength = paramSpec.getSaltLength(); this.trailer = getTrailer(paramSpec.getTrailerField()); this.isRaw = isRaw; setupContentDigest(); }
private static Map<SignatureAlgorithm, PSSParameterSpec> createPssParameterSpecs() { Map<SignatureAlgorithm, PSSParameterSpec> m = new HashMap<SignatureAlgorithm, PSSParameterSpec>(); MGF1ParameterSpec ps = MGF1ParameterSpec.SHA256; PSSParameterSpec spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 32, 1); m.put(SignatureAlgorithm.PS256, spec); ps = MGF1ParameterSpec.SHA384; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 48, 1); m.put(SignatureAlgorithm.PS384, spec); ps = MGF1ParameterSpec.SHA512; spec = new PSSParameterSpec(ps.getDigestAlgorithm(), "MGF1", ps, 64, 1); m.put(SignatureAlgorithm.PS512, spec); return m; }