From 573c971dd923aa5d11b613056af79d4be78d47eb Mon Sep 17 00:00:00 2001 From: Kristen Gilden Date: Sat, 8 Nov 2014 13:55:26 +0200 Subject: [PATCH] [#2] Reduce b64encoded hash length to 60 char/line --- src/Native/BDocView.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Native/BDocView.php b/src/Native/BDocView.php index ee53594..9bca89a 100644 --- a/src/Native/BDocView.php +++ b/src/Native/BDocView.php @@ -53,7 +53,7 @@ public function setSigner(Signer $signer) // 1) set the certificate // @todo what if none or too many nodes found? $element = $this->xpath->query(self::XPATH_SIGNER_CERT)->item(0); - $element->nodeValue = chunk_split(base64_encode($certInDer), 64, "\n"); + $element->nodeValue = chunk_split(base64_encode($certInDer), 60, "\n"); // 2) set the certificate digest // @todo what if none or too many nodes found? @@ -93,7 +93,7 @@ public function addSignature($signature) // @todo what if none or too many nodes found? // @todo algorithm is hard-coded $element = $this->xpath->query(self::XPATH_SIGNATURE)->item(0); - $element->nodeValue = chunk_split(base64_encode(hash('sha256', $signature, true)), 64, "\n"); + $element->nodeValue = chunk_split(base64_encode(hash('sha256', $signature, true)), 60, "\n"); $element->setAttribute('Id', $signatureId = uniqid()); return $signatureId; @@ -173,7 +173,7 @@ private function appendDigest(\DOMNode $parent, $algo, $digest) $digestMethod->setAttribute('Algorithm', $algoMap[$algo]); $parent->appendChild($digestMethod); - $digestValue = $this->createDsElement('DigestValue', chunk_split(base64_encode($digest), 64, "\n")); + $digestValue = $this->createDsElement('DigestValue', chunk_split(base64_encode($digest), 60, "\n")); $parent->appendChild($digestValue); }