Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed coding style for parentheses in functions #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Keccak.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ final class Keccak
private static $keccakf_piln = [10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12,2, 20, 14, 22, 9, 6, 1];
private static $x64 = (PHP_INT_SIZE === 8);

private static function keccakf64(&$st, $rounds): void {
private static function keccakf64(&$st, $rounds): void
{
$keccakf_rndc = [
[0x00000000, 0x00000001], [0x00000000, 0x00008082], [0x80000000, 0x0000808a], [0x80000000, 0x80008000],
[0x00000000, 0x0000808b], [0x00000000, 0x80000001], [0x80000000, 0x80008081], [0x80000000, 0x00008009],
Expand Down Expand Up @@ -95,7 +96,8 @@ private static function keccakf64(&$st, $rounds): void {
}
}

private static function keccak64($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string {
private static function keccak64($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string
{
$capacity /= 8;

$inlen = mb_strlen($in_raw, self::ENCODING);
Expand Down Expand Up @@ -146,7 +148,8 @@ private static function keccak64($in_raw, int $capacity, int $outputlength, $suf
return $raw_output ? $r : bin2hex($r);
}

private static function keccakf32(&$st, $rounds): void {
private static function keccakf32(&$st, $rounds): void
{
$keccakf_rndc = [
[0x0000, 0x0000, 0x0000, 0x0001], [0x0000, 0x0000, 0x0000, 0x8082], [0x8000, 0x0000, 0x0000, 0x0808a], [0x8000, 0x0000, 0x8000, 0x8000],
[0x0000, 0x0000, 0x0000, 0x808b], [0x0000, 0x0000, 0x8000, 0x0001], [0x8000, 0x0000, 0x8000, 0x08081], [0x8000, 0x0000, 0x0000, 0x8009],
Expand Down Expand Up @@ -232,7 +235,8 @@ private static function keccakf32(&$st, $rounds): void {
}
}

private static function keccak32($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string {
private static function keccak32($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string
{
$capacity /= 8;

$inlen = mb_strlen($in_raw, self::ENCODING);
Expand Down Expand Up @@ -287,21 +291,24 @@ private static function keccak32($in_raw, int $capacity, int $outputlength, $suf
return $raw_output ? $r: bin2hex($r);
}

private static function keccak($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string {
private static function keccak($in_raw, int $capacity, int $outputlength, $suffix, bool $raw_output): string
{
return self::$x64
? self::keccak64($in_raw, $capacity, $outputlength, $suffix, $raw_output)
: self::keccak32($in_raw, $capacity, $outputlength, $suffix, $raw_output);
}

public static function hash($in, int $mdlen, bool $raw_output = false): string {
public static function hash($in, int $mdlen, bool $raw_output = false): string
{
if (!in_array($mdlen, [224, 256, 384, 512], true)) {
throw new Exception('Unsupported Keccak Hash output size.');
}

return self::keccak($in, $mdlen, $mdlen, self::LFSR, $raw_output);
}

public static function shake($in, int $security_level, int $outlen, bool $raw_output = false): string {
public static function shake($in, int $security_level, int $outlen, bool $raw_output = false): string
{
if (!in_array($security_level, [128, 256], true)) {
throw new Exception('Unsupported Keccak Shake security level.');
}
Expand Down