diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-11-28 11:22:12 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2013-11-28 11:22:12 +0100 |
commit | 7fdb06e32c43e99ec3599639348a3d758b9914a7 (patch) | |
tree | 0bb89aacb9039c871f17b457f77468b39c05cc47 /pdf-as-lib/src/main/java/at | |
parent | b7a47b0feebd402d9a14d3f6d43ac6576c753367 (diff) | |
download | pdf-as-4-7fdb06e32c43e99ec3599639348a3d758b9914a7.tar.gz pdf-as-4-7fdb06e32c43e99ec3599639348a3d758b9914a7.tar.bz2 pdf-as-4-7fdb06e32c43e99ec3599639348a3d758b9914a7.zip |
+ PKCS7 Signature fixed
+ BKU SL Wrapper fixed
+ Working with MOCCA
Diffstat (limited to 'pdf-as-lib/src/main/java/at')
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java | 11 | ||||
-rw-r--r-- | pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java | 10 |
2 files changed, 17 insertions, 4 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java index 5a03bbef..c32a4c32 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java @@ -1,11 +1,13 @@ package at.gv.egiz.sl.util; import java.math.BigInteger; +import java.security.MessageDigest; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.pdfas.common.utils.StringUtils; import at.gv.egiz.sl.Base64OptRefContentType; import at.gv.egiz.sl.CMSDataObjectRequiredMetaType; import at.gv.egiz.sl.CreateCMSSignatureRequestType; @@ -69,10 +71,11 @@ public abstract class BaseSLConnector implements ISLConnector { currentdataOff++; } if(i + 2 < byteRange.length) { - exclude_range[i] = offset + size; // exclude offset - exclude_range[i+1] = byteRange[i+2]; // exclude size + exclude_range[i] = offset + size; // exclude start + exclude_range[i+1] = byteRange[i+2] - 1; // exclude end } } + logger.info("Exclude Byte Range: " + exclude_range[0] + " " + exclude_range[1]); // == MetaInfoType MetaInfoType metaInfoType = new MetaInfoType(); @@ -89,8 +92,8 @@ public abstract class BaseSLConnector implements ISLConnector { cmsDataObjectRequiredMetaType.setContent(base64OptRefContentType); if(byteRange.length > 0) { ExcludedByteRangeType excludeByteRange = new ExcludedByteRangeType(); - excludeByteRange.setFrom(new BigInteger(String.valueOf(byteRange[0]))); - excludeByteRange.setTo(new BigInteger(String.valueOf(byteRange[0]+byteRange[1]))); + excludeByteRange.setFrom(new BigInteger(String.valueOf(exclude_range[0]))); + excludeByteRange.setTo(new BigInteger(String.valueOf(exclude_range[1]))); cmsDataObjectRequiredMetaType.setExcludedByteRange(excludeByteRange); } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java index 3a998816..6781f898 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java @@ -1,6 +1,7 @@ package at.gv.egiz.sl.util; import java.io.ByteArrayInputStream; +import java.security.MessageDigest; import java.security.SignatureException; import java.security.cert.CertificateException; import java.util.Iterator; @@ -12,6 +13,7 @@ import iaik.cms.SignedData; import iaik.cms.SignerInfo; import iaik.x509.X509Certificate; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.common.utils.StringUtils; import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner; import at.gv.egiz.pdfas.lib.impl.verify.VerifyResultImpl; import at.gv.egiz.sl.CreateCMSSignatureRequestType; @@ -58,6 +60,14 @@ public class ISignatureConnectorSLWrapper implements ISignatureConnector { } public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException { + try { + MessageDigest md = MessageDigest.getInstance("SHA256", "IAIK"); + md.update(input); + byte[] sha256 = md.digest(); + logger.info("Message digest should be: " + StringUtils.bytesToHexString(sha256) + " Size: " + input.length); + } catch (Exception e) { + e.printStackTrace(); + } CreateCMSSignatureRequestType request = connector.createCMSRequest( input, byteRange); CreateCMSSignatureResponseType response = connector |