public Signature createRawSignature(AlgorithmIdentifier algorithm) { Signature sig; try { String algName = getSignatureName(algorithm); algName = "NONE" + algName.substring(algName.indexOf("WITH")); sig = helper.createSignature(algName); // RFC 4056 // When the id-RSASSA-PSS algorithm identifier is used for a signature, // the AlgorithmIdentifier parameters field MUST contain RSASSA-PSS-params. /* Can;t do this pre-jdk1.4 if (algorithm.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) { AlgorithmParameters params = helper.createAlgorithmParameters(algName); params.init(algorithm.getParameters().toASN1Primitive().getEncoded(), "ASN.1"); PSSParameterSpec spec = (PSSParameterSpec)params.getParameterSpec(PSSParameterSpec.class); sig.setParameter(spec); } */ } catch (Exception e) { return null; } return sig; }
Signature createSignature(AlgorithmIdentifier sigAlgId) throws GeneralSecurityException { Signature sig; try { sig = helper.createSignature(getSignatureName(sigAlgId)); } catch (NoSuchAlgorithmException e) { // // try an alternate // if (oids.get(sigAlgId.getAlgorithm()) != null) { String signatureAlgorithm = (String) oids.get(sigAlgId.getAlgorithm()); sig = helper.createSignature(signatureAlgorithm); } else { throw e; } } return sig; }