public ConcurrentContentSigner createSigner(final AlgorithmIdentifier signatureAlgId,
final int parallelism) throws XiSecurityException, P11TokenException {
ParamUtil.requireMin("parallelism", parallelism, 1);
List<XiContentSigner> signers = new ArrayList<>(parallelism);
for (int i = 0; i < parallelism; i++) {
XiContentSigner signer = new P11MacContentSigner(
cryptService, identityId, signatureAlgId);
signers.add(signer);
}
final boolean mac = true;
DefaultConcurrentContentSigner concurrentSigner;
try {
concurrentSigner = new DefaultConcurrentContentSigner(mac, signers, null);
} catch (NoSuchAlgorithmException ex) {
throw new XiSecurityException(ex.getMessage(), ex);
}
try {
byte[] sha1HashOfKey = cryptService.getIdentity(identityId).digestSecretKey(
PKCS11Constants.CKM_SHA_1);
concurrentSigner.setSha1DigestOfMacKey(sha1HashOfKey);
} catch (P11TokenException | XiSecurityException ex) {
LogUtil.warn(LOG, ex, "could not compute the digest of secret key " + identityId);
}
return concurrentSigner;
}