Remove to_bytes() methods

This commit is contained in:
Deon George 2020-06-24 22:46:20 +10:00
parent 9936e839a4
commit fc914b727d
6 changed files with 8 additions and 20 deletions

View File

@ -51,19 +51,19 @@ class CompressedDataPacket extends Packet implements \IteratorAggregate, \ArrayA
switch($this->algorithm) { switch($this->algorithm) {
case 0: case 0:
$body .= $this->data->to_bytes(); $body .= (string)$this->data;
break; break;
case 1: case 1:
$body .= gzdeflate($this->data->to_bytes()); $body .= gzdeflate((string)$this->data);
break; break;
case 2: case 2:
$body .= gzcompress($this->data->to_bytes()); $body .= gzcompress((string)$this->data);
break; break;
case 3: case 3:
$body .= bzcompress($this->data->to_bytes()); $body .= bzcompress((string)$this->data);
break; break;
default: default:

View File

@ -32,7 +32,7 @@ class Symmetric
$key = Random::string($key_bytes); $key = Random::string($key_bytes);
$cipher->setKey($key); $cipher->setKey($key);
$to_encrypt = $prefix.$message->to_bytes(); $to_encrypt = $prefix.$message;
$mdc = new OpenPGP\ModificationDetectionCodePacket(hash('sha1',$to_encrypt."\xD3\x14",true)); $mdc = new OpenPGP\ModificationDetectionCodePacket(hash('sha1',$to_encrypt."\xD3\x14",true));
$to_encrypt .= (string)$mdc; $to_encrypt .= (string)$mdc;

View File

@ -198,17 +198,6 @@ class Message implements \IteratorAggregate,\ArrayAccess
return $final_sigs; return $final_sigs;
} }
public function to_bytes(): string
{
$bytes = '';
foreach ($this as $p) {
$bytes .= (string)$p;
}
return $bytes;
}
/** /**
* Function to extract verified signatures * Function to extract verified signatures
* *

View File

@ -43,7 +43,7 @@ class S2K
return $s2k; return $s2k;
} }
function to_bytes() function __toString()
{ {
$bytes = chr($this->type); $bytes = chr($this->type);

View File

@ -29,7 +29,7 @@ class SecretKeyPacket extends PublicKeyPacket
$secret_material = NULL; $secret_material = NULL;
if($this->s2k_useage == 255 || $this->s2k_useage == 254) { if($this->s2k_useage == 255 || $this->s2k_useage == 254) {
$bytes .= chr($this->symmetric_algorithm); $bytes .= chr($this->symmetric_algorithm);
$bytes .= $this->s2k->to_bytes(); $bytes .= (string)$this->s2k;
} }
if($this->s2k_useage > 0) { if($this->s2k_useage > 0) {
$bytes .= $this->encrypted_data; $bytes .= $this->encrypted_data;

View File

@ -23,8 +23,7 @@ class SymmetricSessionKeyPacket extends Packet
function body() function body()
{ {
return chr($this->version) . chr($this->symmetric_algorithm) . return chr($this->version).chr($this->symmetric_algorithm).$this->s2k.$this->encrypted_data;
$this->s2k->to_bytes() . $this->encrypted_data;
} }
function read() function read()