openpgp-php/lib/OpenPgP/SymmetricSessionKeyPacket.php

37 lines
908 B
PHP
Raw Permalink Normal View History

2020-06-07 06:25:59 +00:00
<?php
namespace Leenooks\OpenPGP;
/**
* OpenPGP Symmetric-Key Encrypted Session Key packet (tag 3).
*
* @see http://tools.ietf.org/html/rfc4880#section-5.3
*/
class SymmetricSessionKeyPacket extends Packet
{
protected $tag = 3;
public $version, $symmetric_algorithm, $s2k, $encrypted_data;
function __construct($s2k=NULL,$encrypted_data='',$symmetric_algorithm=9,$version=3)
{
parent::__construct();
$this->version = $version;
$this->symmetric_algorithm = $symmetric_algorithm;
$this->s2k = $s2k;
$this->encrypted_data = $encrypted_data;
}
function body()
{
return chr($this->version) . chr($this->symmetric_algorithm) .
$this->s2k->to_bytes() . $this->encrypted_data;
}
function read()
{
$this->version = ord($this->read_byte());
$this->symmetric_algorithm = ord($this->read_byte());
2020-06-18 12:03:56 +00:00
$this->s2k = S2k::parse($this->input);
2020-06-07 06:25:59 +00:00
$this->encrypted_data = $this->input;
}
}