protected static function unserializeSub(\fpoirotte\Pssht\Wire\Decoder $decoder) { $signature = $decoder->decodeBoolean(); $algorithm = $decoder->decodeString(); $res = array($algorithm, $decoder->decodeString()); if ($signature === true) { $decoder2 = new \fpoirotte\Pssht\Wire\Decoder(new \fpoirotte\Pssht\Buffer($decoder->decodeString())); if ($decoder2->decodeString() !== $algorithm) { throw new \InvalidArgumentException(); } $res[] = $decoder2->decodeString(); } return $res; }
public static function loadPublic($b64) { $decoder = new \fpoirotte\Pssht\Wire\Decoder(); $decoder->getBuffer()->push(base64_decode($b64)); $type = $decoder->decodeString(); if ($type !== static::getName()) { throw new \InvalidArgumentException(); } $pk = $decoder->decodeString(); if ($pk === null) { throw new \InvalidArgumentException(); } return new static(gmp_init(bin2hex($pk), 16)); }
protected static function unserializeSub(\fpoirotte\Pssht\Wire\Decoder $decoder) { $algorithm = $decoder->decodeString(); $res = array($algorithm, $decoder->decodeString(), $decoder->decodeString(), $decoder->decodeString()); // Special handling for signature. $decoder2 = new \fpoirotte\Pssht\Wire\Decoder(new \fpoirotte\Pssht\Buffer($decoder->decodeString())); if ($decoder2->decodeString() !== $algorithm) { throw new \InvalidArgumentException(); } $res[] = $decoder2->decodeString(); return $res; }