Skip to content

Commit

Permalink
Support full key revocations
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 21, 2015
1 parent 5e5baa9 commit 0d62799
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 16 additions & 4 deletions framework/Pgp/lib/Horde/Pgp/Element/Key.php
Expand Up @@ -170,7 +170,7 @@ public function getEncryptPackets()
return $this->_cache['getEncryptPackets'];
}

$fallback = $topkey = null;
$fallback = $p = $topkey = null;
$out = array();
$sub = false;

Expand Down Expand Up @@ -231,6 +231,14 @@ public function getEncryptPackets()
$sub = true;
}
break;

case 0x20:
if ($this->_verifyKeyData($topkey, false, $val)) {
$out = array();
$fallback = null;
break 2;
}
break;
}
}
}
Expand Down Expand Up @@ -262,19 +270,23 @@ abstract public function getPublicKey();
*/
protected function _verifyKeyData($topkey, $data, $sig)
{
if (!$topkey || !$data) {
if (is_null($topkey) || is_null($data)) {
return false;
}

$pgp = new Horde_Pgp_Backend_Openpgp();
$v = $pgp->verify(
new Horde_Pgp_Element_Message(
new OpenPGP_Message(array($topkey, $data, $sig))
new OpenPGP_Message(
($data === false)
? array($topkey, $sig)
: array($topkey, $data, $sig)
)
),
$this
);

return isset($v[0][2][0]);
return isset($v[0][($data === false) ? 1 : 2][0]);
}

}
4 changes: 4 additions & 0 deletions framework/Pgp/test/Horde/Pgp/KeyTest.php
Expand Up @@ -348,6 +348,10 @@ public function getEncryptPacketsProvider()
array(
$this->_getKey('pgp_private_rsa.txt', 'private'),
1
),
array(
$this->_getKey('pgp_public_revoked.txt', 'public'),
0
)
);
}
Expand Down

0 comments on commit 0d62799

Please sign in to comment.