use of com.github.zhenwei.pkix.util.asn1.cmp.PKIHeader in project LinLong-Java by zhenwei1108.
the class ProtectedPKIMessageBuilder method build.
/**
* Build a protected PKI message which has MAC based integrity protection.
*
* @param signer the ContentSigner to be used to calculate the signature.
* @return the resulting protected PKI message.
* @throws CMPException if the protection signature cannot be calculated.
*/
public ProtectedPKIMessage build(ContentSigner signer) throws CMPException {
if (null == body) {
throw new IllegalStateException("body must be set before building");
}
finaliseHeader(signer.getAlgorithmIdentifier());
PKIHeader header = hdrBuilder.build();
try {
DERBitString protection = new DERBitString(calculateSignature(signer, header, body));
return finaliseMessage(header, protection);
} catch (IOException e) {
throw new CMPException("unable to encode signature input: " + e.getMessage(), e);
}
}
Aggregations