Move to more PSR-4 standards.
This commit is contained in:
38
lib/OpenPgP/SignaturePacket/RevocationKeyPacket.php
Normal file
38
lib/OpenPgP/SignaturePacket/RevocationKeyPacket.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Leenooks\OpenPGP\SignaturePacket;
|
||||
|
||||
/**
|
||||
* @see http://tools.ietf.org/html/rfc4880#section-5.2.3.15
|
||||
*/
|
||||
class RevocationKeyPacket extends Subpacket
|
||||
{
|
||||
protected $tag = 12;
|
||||
public $key_algorithm, $fingerprint, $sensitive;
|
||||
|
||||
function body()
|
||||
{
|
||||
$bytes = '';
|
||||
$bytes .= chr(0x80 | ($this->sensitive ? 0x40 : 0x00));
|
||||
$bytes .= chr($this->key_algorithm);
|
||||
|
||||
for($i = 0; $i < strlen($this->fingerprint); $i += 2) {
|
||||
$bytes .= chr(hexdec($this->fingerprint{$i}.$this->fingerprint{$i+1}));
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
function read()
|
||||
{
|
||||
// bitfield must have bit 0x80 set, says the spec
|
||||
$bitfield = ord($this->read_byte());
|
||||
$this->sensitive = $bitfield & 0x40 == 0x40;
|
||||
$this->key_algorithm = ord($this->read_byte());
|
||||
|
||||
$this->fingerprint = '';
|
||||
while(strlen($this->input) > 0) {
|
||||
$this->fingerprint .= sprintf('%02X',ord($this->read_byte()));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user