< prev index next >

src/java.base/share/classes/sun/security/x509/X509CertImpl.java

Print this page

        

*** 420,439 **** if (signedCert == null) { throw new CertificateEncodingException("Uninitialized certificate"); } // Verify the signature ... Signature sigVerf = null; - String sigName = algId.getName(); if (sigProvider.isEmpty()) { ! sigVerf = Signature.getInstance(sigName); } else { ! sigVerf = Signature.getInstance(sigName, sigProvider); } try { ! SignatureUtil.initVerifyWithParam(sigVerf, key, ! SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { throw new CertificateException(e); } --- 420,441 ---- if (signedCert == null) { throw new CertificateEncodingException("Uninitialized certificate"); } // Verify the signature ... Signature sigVerf = null; if (sigProvider.isEmpty()) { ! sigVerf = Signature.getInstance(algId.getName()); } else { ! sigVerf = Signature.getInstance(algId.getName(), sigProvider); } + sigVerf.initVerify(key); + + // set parameters after Signature.initSign/initVerify call, + // so the deferred provider selection happens when key is set try { ! SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { throw new CertificateException(e); }
*** 474,493 **** if (signedCert == null) { throw new CertificateEncodingException("Uninitialized certificate"); } // Verify the signature ... Signature sigVerf = null; - String sigName = algId.getName(); if (sigProvider == null) { ! sigVerf = Signature.getInstance(sigName); } else { ! sigVerf = Signature.getInstance(sigName, sigProvider); } try { ! SignatureUtil.initVerifyWithParam(sigVerf, key, ! SignatureUtil.getParamSpec(sigName, getSigAlgParams())); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { throw new CertificateException(e); } --- 476,497 ---- if (signedCert == null) { throw new CertificateEncodingException("Uninitialized certificate"); } // Verify the signature ... Signature sigVerf = null; if (sigProvider == null) { ! sigVerf = Signature.getInstance(algId.getName()); } else { ! sigVerf = Signature.getInstance(algId.getName(), sigProvider); } + sigVerf.initVerify(key); + + // set parameters after Signature.initSign/initVerify call, + // so the deferred provider selection happens when key is set try { ! SignatureUtil.specialSetParameter(sigVerf, getSigAlgParams()); } catch (ProviderException e) { throw new CertificateException(e.getMessage(), e.getCause()); } catch (InvalidAlgorithmParameterException e) { throw new CertificateException(e); }
*** 581,603 **** String algorithm, String provider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchProviderException, SignatureException { try { ! if (readOnly) { throw new CertificateEncodingException( ! "cannot over-write existing certificate"); ! } Signature sigEngine = null; ! if (provider == null || provider.isEmpty()) { sigEngine = Signature.getInstance(algorithm); ! } else { sigEngine = Signature.getInstance(algorithm, provider); - } ! SignatureUtil.initSignWithParam(sigEngine, key, signingParams, ! null); // in case the name is reset if (signingParams != null) { algId = AlgorithmId.get(sigEngine.getParameters()); } else { --- 585,610 ---- String algorithm, String provider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchProviderException, SignatureException { try { ! if (readOnly) throw new CertificateEncodingException( ! "cannot over-write existing certificate"); Signature sigEngine = null; ! if (provider == null || provider.isEmpty()) sigEngine = Signature.getInstance(algorithm); ! else sigEngine = Signature.getInstance(algorithm, provider); ! sigEngine.initSign(key); ! ! if (signingParams != null) { ! // set parameters after Signature.initSign/initVerify call, so ! // the deferred provider selection happens when the key is set ! sigEngine.setParameter(signingParams); ! } // in case the name is reset if (signingParams != null) { algId = AlgorithmId.get(sigEngine.getParameters()); } else {
< prev index next >