public function getGenerator($bytearray = false) { if ($bytearray) { return BigInteger::toByteArray($this->generator); } return $this->generator->toString(); }
private function pkcs1unpad($d, $n, $type) { $b = BigInteger::toByteArray($d); $i = 0; while ($i < count($b) && $b[$i] == 0) { ++$i; } if (count($b) - $i != $n - 1 || $b[$i] != 2) { return null; } ++$i; while ($b[$i] != 0) { if (++$i >= count($b)) { return null; } } $result = ""; while (++$i < count($b)) { $c = $b[$i] & 255; if ($c < 128) { $result .= chr($c); } else { if ($c > 191 && $c < 224) { $result .= chr(($c & 31) << 6 | $b[$i + 1] & 63); ++$i; } else { $result .= chr(($c & 15) << 12 | ($b[$i + 1] & 63) << 6 | $b[$i + 2] & 63); $i += 2; } } } return $result; }