public function oneSerialization($path)
 {
     $in = \OpenPGP\Message::parse(file_get_contents(dirname(__FILE__) . '/data/' . $path));
     $mid = $in->to_bytes();
     $out = \OpenPGP\Message::parse($mid);
     $this->assertEquals($in, $out);
 }
 function read()
 {
     $this->algorithm = ord($this->read_byte());
     $this->data = $this->read_bytes($this->length);
     switch ($this->algorithm) {
         case 0:
             $this->data = \OpenPGP\Message::parse($this->data);
             break;
         case 1:
             $this->data = \OpenPGP\Message::parse(gzinflate($this->data));
             break;
         case 2:
             $this->data = \OpenPGP\Message::parse(gzuncompress($this->data));
             break;
         case 3:
             $this->data = \OpenPGP\Message::parse(bzdecompress($this->data));
             break;
         default:
             throw new Exception("Bad value for Compression Algorithm (decompress)");
     }
 }
 public function oneFingerprint($path, $kf)
 {
     $m = \OpenPGP\Message::parse(file_get_contents(dirname(__FILE__) . '/data/' . $path));
     $this->assertEquals($m[0]->fingerprint(), $kf);
 }
Beispiel #4
0
 static function convert_key($packet, $private = false)
 {
     if (!is_object($packet)) {
         $packet = \OpenPGP\Message::parse($packet);
     }
     if ($packet instanceof \OpenPGP\Message) {
         $packet = $packet[0];
     }
     $mod = $packet->key['n'];
     $exp = $packet->key['e'];
     if ($private) {
         $exp = $packet->key['d'];
     }
     if (!$exp) {
         return NULL;
     }
     // Packet doesn't have needed data
     $rsa = self::crypt_rsa_key($mod, $exp);
     if ($private) {
         if ($packet->key['p'] && $packet->key['q']) {
             $rsa->primes = array($packet->key['p'], $packet->key['q']);
         }
         if ($packet->key['u']) {
             $rsa->coefficients = array($packet->key['u']);
         }
     }
     return $rsa;
 }