Skip to content

Commit

Permalink
[#2] Reduce b64encoded hash length to 60 char/line
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilden committed Nov 8, 2014
1 parent ceb0feb commit 573c971
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Native/BDocView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 573c971

Please sign in to comment.