aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-11-26 12:49:58 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-11-26 12:49:58 +0100
commitf5563ba4d17850fc98e4bf8c93b6141f3bef74f5 (patch)
tree1bb786f7bcc57bceb70ef1ee2b785738503c1a5f /pdf-as-lib/src/main
parent17ab0b758c9b106d2067ce168badeeaa5a5f1f30 (diff)
downloadpdf-as-3-f5563ba4d17850fc98e4bf8c93b6141f3bef74f5.tar.gz
pdf-as-3-f5563ba4d17850fc98e4bf8c93b6141f3bef74f5.tar.bz2
pdf-as-3-f5563ba4d17850fc98e4bf8c93b6141f3bef74f5.zip
MOA SPSS SHA512 verification fix
Diffstat (limited to 'pdf-as-lib/src/main')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java4
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java13
2 files changed, 15 insertions, 2 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
index 07e9ccd..83bf046 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/DetachedLocRefMOAConnector.java
@@ -259,7 +259,7 @@ public class DetachedLocRefMOAConnector implements Connector
// byte[] data_value = data.getData();
// byte[] data_value_hash = CodingHelper.buildDigest(data_value);
byte[] data_value_hash = CodingHelper.buildDigest(data.getDataSource(), algSuite.getDataDigestMethod());
- String object_data_hash = CodingHelper.encodeBase64(data_value_hash);
+ String object_data_hash = CodingHelper.encodeBase64PEM(data_value_hash);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_DATA_REPLACE, object_data_hash);
}
@@ -301,7 +301,7 @@ public class DetachedLocRefMOAConnector implements Connector
final byte[] bytes_to_be_hashed = string_to_be_hashed.getBytes("UTF-8"); //$NON-NLS-1$
byte[] sig_prop_code = CodingHelper.buildDigest(bytes_to_be_hashed, algSuite.getPropertiesDigestMethod());
- String sig_prop_hash = CodingHelper.encodeBase64(sig_prop_code);
+ String sig_prop_hash = CodingHelper.encodeBase64PEM(sig_prop_code);
verify_xml = verify_xml.replaceFirst(TemplateReplaces.DIGEST_VALUE_SIGNED_PROPERTIES_REPLACE, sig_prop_hash);
}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
index eebe127..1e22838 100644
--- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
@@ -203,6 +203,19 @@ public class CodingHelper
}
}
+ public static String encodeBase64PEM(byte[] plainString) {
+ String base64String = encodeBase64(plainString);
+ StringBuilder sb = new StringBuilder();
+ while(base64String.length() > 64) {
+ String part = base64String.substring(0, 64);
+ sb.append(part);
+ sb.append("\n");
+ base64String = base64String.substring(64);
+ }
+ sb.append(base64String);
+ return sb.toString();
+ }
+
// dferbas
/**
* This method builds an hash value of a given byte array.