Skip to content

Commit

Permalink
return 0 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
antedebaas committed Nov 1, 2024
1 parent a3c3060 commit 188fb3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Twig/RSABits.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function getRsaKeyBitLengthFromDnsRecord($dkimKeyStr) {
$dkimKeyStr = str_replace(["\n", "\r", " "], "", $dkimKeyStr);
$binaryKey = base64_decode($dkimKeyStr);
if ($binaryKey === false) {
throw new Exception("Invalid base64 encoding in DKIM key.");
return array('bits' => 0);
}
$formattedKey = "-----BEGIN PUBLIC KEY-----\n" . chunk_split(base64_encode($binaryKey), 64, "\n") . "-----END PUBLIC KEY-----";
$publicKey = openssl_pkey_get_public($formattedKey);
if ($publicKey === false) {
throw new Exception("Failed to parse DKIM key.");
return array('bits' => 0);
}
$keyDetails = openssl_pkey_get_details($publicKey);
openssl_free_key($publicKey);
Expand Down

0 comments on commit 188fb3a

Please sign in to comment.