use of org.xipki.security.exception.XiSecurityException in project xipki by xipki.
the class P11MacContentSignerBuilder method createSigner.
// constructor
public ConcurrentContentSigner createSigner(AlgorithmIdentifier signatureAlgId, 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);
}
// end for
final boolean mac = true;
DfltConcurrentContentSigner concurrentSigner;
try {
concurrentSigner = new DfltConcurrentContentSigner(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;
}
Aggregations