org.bouncycastle.crypto.Signer Java Examples

The following examples show how to use org.bouncycastle.crypto.Signer. 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: P12ContentSignerBuilder.java    From xipki with Apache License 2.0 6 votes vote down vote up
protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId)
    throws OperatorCreationException {
  if (!AlgorithmUtil.isRSASigAlgId(sigAlgId)) {
    throw new OperatorCreationException("the given algorithm is not a valid RSA signature "
        + "algirthm '" + sigAlgId.getAlgorithm().getId() + "'");
  }

  if (!PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
    Digest dig = digestProvider.get(digAlgId);
    return new RSADigestSigner(dig);
  }

  try {
    return SignerUtil.createPSSRSASigner(sigAlgId);
  } catch (XiSecurityException ex) {
    throw new OperatorCreationException(ex.getMessage(), ex);
  }
}
 
Example #2
Source File: XiRSAContentVerifierProviderBuilder.java    From xipki with Apache License 2.0 5 votes vote down vote up
@Override
protected Signer createSigner(AlgorithmIdentifier sigAlgId) throws OperatorCreationException {
  if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
    try {
      return SignerUtil.createPSSRSASigner(sigAlgId);
    } catch (XiSecurityException ex) {
      throw new OperatorCreationException(ex.getMessage(), ex);
    }
  } else {
    AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId);
    return new RSADigestSigner(digestProvider.get(digAlg));
  }
}
 
Example #3
Source File: P12ContentSignerBuilder.java    From xipki with Apache License 2.0 5 votes vote down vote up
protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId)
    throws OperatorCreationException {
  if (!AlgorithmUtil.isDSASigAlg(sigAlgId)) {
    throw new OperatorCreationException("the given algorithm is not a valid DSA signature "
        + "algirthm '" + sigAlgId.getAlgorithm().getId() + "'");
  }

  Digest dig = digestProvider.get(digAlgId);
  DSASigner dsaSigner = new DSASigner();
  return plain ? new DSAPlainDigestSigner(dsaSigner, dig) : new DSADigestSigner(dsaSigner, dig);
}
 
Example #4
Source File: P12ContentSignerBuilder.java    From xipki with Apache License 2.0 5 votes vote down vote up
protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId)
    throws OperatorCreationException {
  if (!AlgorithmUtil.isECSigAlg(sigAlgId)) {
    throw new OperatorCreationException("the given algorithm is not a valid EC signature "
        + "algorithm '" + sigAlgId.getAlgorithm().getId() + "'");
  }

  Digest dig = digestProvider.get(digAlgId);
  ECDSASigner dsaSigner = new ECDSASigner();

  return plain ? new DSAPlainDigestSigner(dsaSigner, dig) : new DSADigestSigner(dsaSigner, dig);
}
 
Example #5
Source File: P12ContentSignerBuilder.java    From xipki with Apache License 2.0 5 votes vote down vote up
protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId)
        throws OperatorCreationException {
  if (!AlgorithmUtil.isSM2SigAlg(sigAlgId)) {
    throw new OperatorCreationException("the given algorithm is not a valid EC signature "
        + "algorithm '" + sigAlgId.getAlgorithm().getId() + "'");
  }

  return new SM2Signer();
}