@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @param array $context |
| 12 | 12 | * @return void |
| 13 | 13 | */ |
| 14 | - public function alert($message, array $context = []); |
|
| 14 | + public function alert( $message, array $context = [ ] ); |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Log a critical message to the logs. |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param array $context |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | - public function critical($message, array $context = []); |
|
| 23 | + public function critical( $message, array $context = [ ] ); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Log an error message to the logs. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param array $context |
| 30 | 30 | * @return void |
| 31 | 31 | */ |
| 32 | - public function error($message, array $context = []); |
|
| 32 | + public function error( $message, array $context = [ ] ); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Log a warning message to the logs. |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param array $context |
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | - public function warning($message, array $context = []); |
|
| 41 | + public function warning( $message, array $context = [ ] ); |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Log a notice to the logs. |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param array $context |
| 48 | 48 | * @return void |
| 49 | 49 | */ |
| 50 | - public function notice($message, array $context = []); |
|
| 50 | + public function notice( $message, array $context = [ ] ); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Log an informational message to the logs. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param array $context |
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | - public function info($message, array $context = []); |
|
| 59 | + public function info( $message, array $context = [ ] ); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Log a debug message to the logs. |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param array $context |
| 66 | 66 | * @return void |
| 67 | 67 | */ |
| 68 | - public function debug($message, array $context = []); |
|
| 68 | + public function debug( $message, array $context = [ ] ); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Log a message to the logs. |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param array $context |
| 76 | 76 | * @return void |
| 77 | 77 | */ |
| 78 | - public function log($level, $message, array $context = []); |
|
| 78 | + public function log( $level, $message, array $context = [ ] ); |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Register a file log handler. |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param string $level |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function useFiles($path, $level = 'debug'); |
|
| 87 | + public function useFiles( $path, $level = 'debug' ); |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Register a daily file log handler. |
@@ -94,5 +94,5 @@ discard block |
||
| 94 | 94 | * @param string $level |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - public function useDailyFiles($path, $days = 0, $level = 'debug'); |
|
| 97 | + public function useDailyFiles( $path, $days = 0, $level = 'debug' ); |
|
| 98 | 98 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // The image source has ?raw=1; don't check for valid image extensions. |
| 55 | - $image_atts['validate_src'] = false; |
|
| 55 | + $image_atts[ 'validate_src' ] = false; |
|
| 56 | 56 | |
| 57 | 57 | return $image_atts; |
| 58 | 58 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $atts = wp_parse_args( $atts, $defaults ); |
| 67 | 67 | |
| 68 | - foreach( $atts as $key => $val ) { |
|
| 68 | + foreach ( $atts as $key => $val ) { |
|
| 69 | 69 | $this->{$key} = $val; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $this->class = !empty( $this->class ) ? esc_attr( implode( ' ', (array)$this->class ) ) : $this->class; |
|
| 72 | + $this->class = ! empty( $this->class ) ? esc_attr( implode( ' ', (array)$this->class ) ) : $this->class; |
|
| 73 | 73 | |
| 74 | 74 | $this->set_image_size(); |
| 75 | 75 | |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function validate_image_src() { |
| 87 | 87 | |
| 88 | - if ( !$this->validate_src ) { return true; } |
|
| 88 | + if ( ! $this->validate_src ) { return true; } |
|
| 89 | 89 | |
| 90 | 90 | $info = pathinfo( $this->src ); |
| 91 | 91 | |
| 92 | 92 | $image_exts = self::get_image_extensions(); |
| 93 | 93 | |
| 94 | - return isset( $info['extension'] ) && in_array( strtolower( $info['extension'] ), $image_exts); |
|
| 94 | + return isset( $info[ 'extension' ] ) && in_array( strtolower( $info[ 'extension' ] ), $image_exts ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | $image_exts = apply_filters( 'gravityview_image_extensions', array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'webp' ) ); |
| 111 | 111 | |
| 112 | - return (array) $image_exts; |
|
| 112 | + return (array)$image_exts; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,16 +125,16 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | // And there is no string size passed |
| 127 | 127 | // And we want to get the image size using PHP |
| 128 | - if ( empty( $string ) && !empty( $this->getimagesize ) ) { |
|
| 128 | + if ( empty( $string ) && ! empty( $this->getimagesize ) ) { |
|
| 129 | 129 | |
| 130 | 130 | $image_size = @getimagesize( $this->src ); |
| 131 | 131 | |
| 132 | 132 | // If it didn't return a response, it may be a HTTPS/SSL error |
| 133 | - if ( empty( $image_size[0] ) ) { |
|
| 133 | + if ( empty( $image_size[ 0 ] ) ) { |
|
| 134 | 134 | $image_size = @getimagesize( set_url_scheme( $this->src, 'http' ) ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( !empty( $image_size ) ) { |
|
| 137 | + if ( ! empty( $image_size ) ) { |
|
| 138 | 138 | list( $width, $height ) = $image_size; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -147,33 +147,33 @@ discard block |
||
| 147 | 147 | * @param array $image_sizes Array of image sizes with the key being the size slug, and the value being an array with `width` and `height` defined, in pixels |
| 148 | 148 | */ |
| 149 | 149 | $image_sizes = apply_filters( 'gravityview_image_sizes', array( |
| 150 | - 'tiny' => array('width' => 40, 'height' => 30), |
|
| 151 | - 'small' => array('width' => 100, 'height' => 75), |
|
| 152 | - 'medium' => array('width' => 250, 'height' => 188), |
|
| 153 | - 'large' => array('width' => 448, 'height' => 336), |
|
| 150 | + 'tiny' => array( 'width' => 40, 'height' => 30 ), |
|
| 151 | + 'small' => array( 'width' => 100, 'height' => 75 ), |
|
| 152 | + 'medium' => array( 'width' => 250, 'height' => 188 ), |
|
| 153 | + 'large' => array( 'width' => 448, 'height' => 336 ), |
|
| 154 | 154 | ) ); |
| 155 | 155 | |
| 156 | - switch( $this->size ) { |
|
| 156 | + switch ( $this->size ) { |
|
| 157 | 157 | case 'tiny': |
| 158 | - extract($image_sizes['tiny']); |
|
| 158 | + extract( $image_sizes[ 'tiny' ] ); |
|
| 159 | 159 | break; |
| 160 | 160 | case 'small': |
| 161 | 161 | case 's': |
| 162 | 162 | case 'thumb': |
| 163 | - extract($image_sizes['small']); |
|
| 163 | + extract( $image_sizes[ 'small' ] ); |
|
| 164 | 164 | break; |
| 165 | 165 | case 'm': |
| 166 | 166 | case 'medium': |
| 167 | - extract($image_sizes['medium']); |
|
| 167 | + extract( $image_sizes[ 'medium' ] ); |
|
| 168 | 168 | break; |
| 169 | 169 | case 'large': |
| 170 | 170 | case 'l': |
| 171 | - extract($image_sizes['large']); |
|
| 171 | + extract( $image_sizes[ 'large' ] ); |
|
| 172 | 172 | break; |
| 173 | 173 | default: |
| 174 | 174 | // Verify that the passed sizes are integers. |
| 175 | - $width = !empty( $width ) ? intval( $width ) : intval( $this->width ); |
|
| 176 | - $height = !empty( $height ) ? intval( $height ) : intval( $this->height ); |
|
| 175 | + $width = ! empty( $width ) ? intval( $width ) : intval( $this->width ); |
|
| 176 | + $height = ! empty( $height ) ? intval( $height ) : intval( $this->height ); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) { |
|
| 3 | +if ( class_exists( 'ParagonIE_Sodium_Core_ChaCha20_Ctx', false ) ) { |
|
| 4 | 4 | return; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -27,40 +27,40 @@ discard block |
||
| 27 | 27 | * @throws SodiumException |
| 28 | 28 | * @throws TypeError |
| 29 | 29 | */ |
| 30 | - public function __construct($key = '', $iv = '', $counter = '') |
|
| 30 | + public function __construct( $key = '', $iv = '', $counter = '' ) |
|
| 31 | 31 | { |
| 32 | - if (self::strlen($key) !== 32) { |
|
| 33 | - throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.'); |
|
| 32 | + if ( self::strlen( $key ) !== 32 ) { |
|
| 33 | + throw new InvalidArgumentException( 'ChaCha20 expects a 256-bit key.' ); |
|
| 34 | 34 | } |
| 35 | - if (self::strlen($iv) !== 8) { |
|
| 36 | - throw new InvalidArgumentException('ChaCha20 expects a 64-bit nonce.'); |
|
| 35 | + if ( self::strlen( $iv ) !== 8 ) { |
|
| 36 | + throw new InvalidArgumentException( 'ChaCha20 expects a 64-bit nonce.' ); |
|
| 37 | 37 | } |
| 38 | - $this->container = new SplFixedArray(16); |
|
| 38 | + $this->container = new SplFixedArray( 16 ); |
|
| 39 | 39 | |
| 40 | 40 | /* "expand 32-byte k" as per ChaCha20 spec */ |
| 41 | - $this->container[0] = new ParagonIE_Sodium_Core32_Int32(array(0x6170, 0x7865)); |
|
| 42 | - $this->container[1] = new ParagonIE_Sodium_Core32_Int32(array(0x3320, 0x646e)); |
|
| 43 | - $this->container[2] = new ParagonIE_Sodium_Core32_Int32(array(0x7962, 0x2d32)); |
|
| 44 | - $this->container[3] = new ParagonIE_Sodium_Core32_Int32(array(0x6b20, 0x6574)); |
|
| 41 | + $this->container[ 0 ] = new ParagonIE_Sodium_Core32_Int32( array( 0x6170, 0x7865 ) ); |
|
| 42 | + $this->container[ 1 ] = new ParagonIE_Sodium_Core32_Int32( array( 0x3320, 0x646e ) ); |
|
| 43 | + $this->container[ 2 ] = new ParagonIE_Sodium_Core32_Int32( array( 0x7962, 0x2d32 ) ); |
|
| 44 | + $this->container[ 3 ] = new ParagonIE_Sodium_Core32_Int32( array( 0x6b20, 0x6574 ) ); |
|
| 45 | 45 | |
| 46 | - $this->container[4] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4)); |
|
| 47 | - $this->container[5] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 4, 4)); |
|
| 48 | - $this->container[6] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 8, 4)); |
|
| 49 | - $this->container[7] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4)); |
|
| 50 | - $this->container[8] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4)); |
|
| 51 | - $this->container[9] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4)); |
|
| 52 | - $this->container[10] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4)); |
|
| 53 | - $this->container[11] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4)); |
|
| 46 | + $this->container[ 4 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 0, 4 ) ); |
|
| 47 | + $this->container[ 5 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 4, 4 ) ); |
|
| 48 | + $this->container[ 6 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 8, 4 ) ); |
|
| 49 | + $this->container[ 7 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 12, 4 ) ); |
|
| 50 | + $this->container[ 8 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 16, 4 ) ); |
|
| 51 | + $this->container[ 9 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 20, 4 ) ); |
|
| 52 | + $this->container[ 10 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 24, 4 ) ); |
|
| 53 | + $this->container[ 11 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $key, 28, 4 ) ); |
|
| 54 | 54 | |
| 55 | - if (empty($counter)) { |
|
| 56 | - $this->container[12] = new ParagonIE_Sodium_Core32_Int32(); |
|
| 57 | - $this->container[13] = new ParagonIE_Sodium_Core32_Int32(); |
|
| 55 | + if ( empty( $counter ) ) { |
|
| 56 | + $this->container[ 12 ] = new ParagonIE_Sodium_Core32_Int32(); |
|
| 57 | + $this->container[ 13 ] = new ParagonIE_Sodium_Core32_Int32(); |
|
| 58 | 58 | } else { |
| 59 | - $this->container[12] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 0, 4)); |
|
| 60 | - $this->container[13] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($counter, 4, 4)); |
|
| 59 | + $this->container[ 12 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $counter, 0, 4 ) ); |
|
| 60 | + $this->container[ 13 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $counter, 4, 4 ) ); |
|
| 61 | 61 | } |
| 62 | - $this->container[14] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 0, 4)); |
|
| 63 | - $this->container[15] = ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($iv, 4, 4)); |
|
| 62 | + $this->container[ 14 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $iv, 0, 4 ) ); |
|
| 63 | + $this->container[ 15 ] = ParagonIE_Sodium_Core32_Int32::fromReverseString( self::substr( $iv, 4, 4 ) ); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | * @param int|ParagonIE_Sodium_Core32_Int32 $value |
| 71 | 71 | * @return void |
| 72 | 72 | */ |
| 73 | - #[ReturnTypeWillChange] |
|
| 74 | - public function offsetSet($offset, $value) |
|
| 73 | + #[ReturnTypeWillChange ] |
|
| 74 | + public function offsetSet( $offset, $value ) |
|
| 75 | 75 | { |
| 76 | - if (!is_int($offset)) { |
|
| 77 | - throw new InvalidArgumentException('Expected an integer'); |
|
| 76 | + if ( ! is_int( $offset ) ) { |
|
| 77 | + throw new InvalidArgumentException( 'Expected an integer' ); |
|
| 78 | 78 | } |
| 79 | - if ($value instanceof ParagonIE_Sodium_Core32_Int32) { |
|
| 79 | + if ( $value instanceof ParagonIE_Sodium_Core32_Int32 ) { |
|
| 80 | 80 | /* |
| 81 | 81 | } elseif (is_int($value)) { |
| 82 | 82 | $value = ParagonIE_Sodium_Core32_Int32::fromInt($value); |
| 83 | 83 | */ |
| 84 | 84 | } else { |
| 85 | - throw new InvalidArgumentException('Expected an integer'); |
|
| 85 | + throw new InvalidArgumentException( 'Expected an integer' ); |
|
| 86 | 86 | } |
| 87 | - $this->container[$offset] = $value; |
|
| 87 | + $this->container[ $offset ] = $value; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * @return bool |
| 95 | 95 | * @psalm-suppress MixedArrayOffset |
| 96 | 96 | */ |
| 97 | - #[ReturnTypeWillChange] |
|
| 98 | - public function offsetExists($offset) |
|
| 97 | + #[ReturnTypeWillChange ] |
|
| 98 | + public function offsetExists( $offset ) |
|
| 99 | 99 | { |
| 100 | - return isset($this->container[$offset]); |
|
| 100 | + return isset( $this->container[ $offset ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | * @return void |
| 108 | 108 | * @psalm-suppress MixedArrayOffset |
| 109 | 109 | */ |
| 110 | - #[ReturnTypeWillChange] |
|
| 111 | - public function offsetUnset($offset) |
|
| 110 | + #[ReturnTypeWillChange ] |
|
| 111 | + public function offsetUnset( $offset ) |
|
| 112 | 112 | { |
| 113 | - unset($this->container[$offset]); |
|
| 113 | + unset( $this->container[ $offset ] ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * @return mixed|null |
| 121 | 121 | * @psalm-suppress MixedArrayOffset |
| 122 | 122 | */ |
| 123 | - #[ReturnTypeWillChange] |
|
| 124 | - public function offsetGet($offset) |
|
| 123 | + #[ReturnTypeWillChange ] |
|
| 124 | + public function offsetGet( $offset ) |
|
| 125 | 125 | { |
| 126 | - return isset($this->container[$offset]) |
|
| 127 | - ? $this->container[$offset] |
|
| 126 | + return isset( $this->container[ $offset ] ) |
|
| 127 | + ? $this->container[ $offset ] |
|
| 128 | 128 | : null; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) { |
|
| 3 | +if ( class_exists( 'ParagonIE_Sodium_Core_ChaCha20_Ctx', false ) ) { |
|
| 4 | 4 | return; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -26,39 +26,39 @@ discard block |
||
| 26 | 26 | * @throws InvalidArgumentException |
| 27 | 27 | * @throws TypeError |
| 28 | 28 | */ |
| 29 | - public function __construct($key = '', $iv = '', $counter = '') |
|
| 29 | + public function __construct( $key = '', $iv = '', $counter = '' ) |
|
| 30 | 30 | { |
| 31 | - if (self::strlen($key) !== 32) { |
|
| 32 | - throw new InvalidArgumentException('ChaCha20 expects a 256-bit key.'); |
|
| 31 | + if ( self::strlen( $key ) !== 32 ) { |
|
| 32 | + throw new InvalidArgumentException( 'ChaCha20 expects a 256-bit key.' ); |
|
| 33 | 33 | } |
| 34 | - if (self::strlen($iv) !== 8) { |
|
| 35 | - throw new InvalidArgumentException('ChaCha20 expects a 64-bit nonce.'); |
|
| 34 | + if ( self::strlen( $iv ) !== 8 ) { |
|
| 35 | + throw new InvalidArgumentException( 'ChaCha20 expects a 64-bit nonce.' ); |
|
| 36 | 36 | } |
| 37 | - $this->container = new SplFixedArray(16); |
|
| 37 | + $this->container = new SplFixedArray( 16 ); |
|
| 38 | 38 | |
| 39 | 39 | /* "expand 32-byte k" as per ChaCha20 spec */ |
| 40 | - $this->container[0] = 0x61707865; |
|
| 41 | - $this->container[1] = 0x3320646e; |
|
| 42 | - $this->container[2] = 0x79622d32; |
|
| 43 | - $this->container[3] = 0x6b206574; |
|
| 44 | - $this->container[4] = self::load_4(self::substr($key, 0, 4)); |
|
| 45 | - $this->container[5] = self::load_4(self::substr($key, 4, 4)); |
|
| 46 | - $this->container[6] = self::load_4(self::substr($key, 8, 4)); |
|
| 47 | - $this->container[7] = self::load_4(self::substr($key, 12, 4)); |
|
| 48 | - $this->container[8] = self::load_4(self::substr($key, 16, 4)); |
|
| 49 | - $this->container[9] = self::load_4(self::substr($key, 20, 4)); |
|
| 50 | - $this->container[10] = self::load_4(self::substr($key, 24, 4)); |
|
| 51 | - $this->container[11] = self::load_4(self::substr($key, 28, 4)); |
|
| 40 | + $this->container[ 0 ] = 0x61707865; |
|
| 41 | + $this->container[ 1 ] = 0x3320646e; |
|
| 42 | + $this->container[ 2 ] = 0x79622d32; |
|
| 43 | + $this->container[ 3 ] = 0x6b206574; |
|
| 44 | + $this->container[ 4 ] = self::load_4( self::substr( $key, 0, 4 ) ); |
|
| 45 | + $this->container[ 5 ] = self::load_4( self::substr( $key, 4, 4 ) ); |
|
| 46 | + $this->container[ 6 ] = self::load_4( self::substr( $key, 8, 4 ) ); |
|
| 47 | + $this->container[ 7 ] = self::load_4( self::substr( $key, 12, 4 ) ); |
|
| 48 | + $this->container[ 8 ] = self::load_4( self::substr( $key, 16, 4 ) ); |
|
| 49 | + $this->container[ 9 ] = self::load_4( self::substr( $key, 20, 4 ) ); |
|
| 50 | + $this->container[ 10 ] = self::load_4( self::substr( $key, 24, 4 ) ); |
|
| 51 | + $this->container[ 11 ] = self::load_4( self::substr( $key, 28, 4 ) ); |
|
| 52 | 52 | |
| 53 | - if (empty($counter)) { |
|
| 54 | - $this->container[12] = 0; |
|
| 55 | - $this->container[13] = 0; |
|
| 53 | + if ( empty( $counter ) ) { |
|
| 54 | + $this->container[ 12 ] = 0; |
|
| 55 | + $this->container[ 13 ] = 0; |
|
| 56 | 56 | } else { |
| 57 | - $this->container[12] = self::load_4(self::substr($counter, 0, 4)); |
|
| 58 | - $this->container[13] = self::load_4(self::substr($counter, 4, 4)); |
|
| 57 | + $this->container[ 12 ] = self::load_4( self::substr( $counter, 0, 4 ) ); |
|
| 58 | + $this->container[ 13 ] = self::load_4( self::substr( $counter, 4, 4 ) ); |
|
| 59 | 59 | } |
| 60 | - $this->container[14] = self::load_4(self::substr($iv, 0, 4)); |
|
| 61 | - $this->container[15] = self::load_4(self::substr($iv, 4, 4)); |
|
| 60 | + $this->container[ 14 ] = self::load_4( self::substr( $iv, 0, 4 ) ); |
|
| 61 | + $this->container[ 15 ] = self::load_4( self::substr( $iv, 4, 4 ) ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | * @psalm-suppress MixedArrayOffset |
| 71 | 71 | */ |
| 72 | - #[ReturnTypeWillChange] |
|
| 73 | - public function offsetSet($offset, $value) |
|
| 72 | + #[ReturnTypeWillChange ] |
|
| 73 | + public function offsetSet( $offset, $value ) |
|
| 74 | 74 | { |
| 75 | - if (!is_int($offset)) { |
|
| 76 | - throw new InvalidArgumentException('Expected an integer'); |
|
| 75 | + if ( ! is_int( $offset ) ) { |
|
| 76 | + throw new InvalidArgumentException( 'Expected an integer' ); |
|
| 77 | 77 | } |
| 78 | - if (!is_int($value)) { |
|
| 79 | - throw new InvalidArgumentException('Expected an integer'); |
|
| 78 | + if ( ! is_int( $value ) ) { |
|
| 79 | + throw new InvalidArgumentException( 'Expected an integer' ); |
|
| 80 | 80 | } |
| 81 | - $this->container[$offset] = $value; |
|
| 81 | + $this->container[ $offset ] = $value; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | * @param int $offset |
| 88 | 88 | * @return bool |
| 89 | 89 | */ |
| 90 | - #[ReturnTypeWillChange] |
|
| 91 | - public function offsetExists($offset) |
|
| 90 | + #[ReturnTypeWillChange ] |
|
| 91 | + public function offsetExists( $offset ) |
|
| 92 | 92 | { |
| 93 | - return isset($this->container[$offset]); |
|
| 93 | + return isset( $this->container[ $offset ] ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | * @return void |
| 101 | 101 | * @psalm-suppress MixedArrayOffset |
| 102 | 102 | */ |
| 103 | - #[ReturnTypeWillChange] |
|
| 104 | - public function offsetUnset($offset) |
|
| 103 | + #[ReturnTypeWillChange ] |
|
| 104 | + public function offsetUnset( $offset ) |
|
| 105 | 105 | { |
| 106 | - unset($this->container[$offset]); |
|
| 106 | + unset( $this->container[ $offset ] ); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | * @return mixed|null |
| 114 | 114 | * @psalm-suppress MixedArrayOffset |
| 115 | 115 | */ |
| 116 | - #[ReturnTypeWillChange] |
|
| 117 | - public function offsetGet($offset) |
|
| 116 | + #[ReturnTypeWillChange ] |
|
| 117 | + public function offsetGet( $offset ) |
|
| 118 | 118 | { |
| 119 | - return isset($this->container[$offset]) |
|
| 120 | - ? $this->container[$offset] |
|
| 119 | + return isset( $this->container[ $offset ] ) |
|
| 120 | + ? $this->container[ $offset ] |
|
| 121 | 121 | : null; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | * @return string |
| 19 | 19 | * @throws TypeError |
| 20 | 20 | */ |
| 21 | - public static function encode($src) |
|
| 21 | + public static function encode( $src ) |
|
| 22 | 22 | { |
| 23 | - return self::doEncode($src, true); |
|
| 23 | + return self::doEncode( $src, true ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * @return string |
| 33 | 33 | * @throws TypeError |
| 34 | 34 | */ |
| 35 | - public static function encodeUnpadded($src) |
|
| 35 | + public static function encodeUnpadded( $src ) |
|
| 36 | 36 | { |
| 37 | - return self::doEncode($src, false); |
|
| 37 | + return self::doEncode( $src, false ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,43 +43,43 @@ discard block |
||
| 43 | 43 | * @return string |
| 44 | 44 | * @throws TypeError |
| 45 | 45 | */ |
| 46 | - protected static function doEncode($src, $pad = true) |
|
| 46 | + protected static function doEncode( $src, $pad = true ) |
|
| 47 | 47 | { |
| 48 | 48 | $dest = ''; |
| 49 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 49 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 50 | 50 | // Main loop (no padding): |
| 51 | - for ($i = 0; $i + 3 <= $srcLen; $i += 3) { |
|
| 51 | + for ( $i = 0; $i + 3 <= $srcLen; $i += 3 ) { |
|
| 52 | 52 | /** @var array<int, int> $chunk */ |
| 53 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 3)); |
|
| 54 | - $b0 = $chunk[1]; |
|
| 55 | - $b1 = $chunk[2]; |
|
| 56 | - $b2 = $chunk[3]; |
|
| 53 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, 3 ) ); |
|
| 54 | + $b0 = $chunk[ 1 ]; |
|
| 55 | + $b1 = $chunk[ 2 ]; |
|
| 56 | + $b2 = $chunk[ 3 ]; |
|
| 57 | 57 | |
| 58 | 58 | $dest .= |
| 59 | - self::encode6Bits( $b0 >> 2 ) . |
|
| 60 | - self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . |
|
| 61 | - self::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) . |
|
| 62 | - self::encode6Bits( $b2 & 63); |
|
| 59 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 60 | + self::encode6Bits( ( ( $b0 << 4 ) | ( $b1 >> 4 ) ) & 63 ) . |
|
| 61 | + self::encode6Bits( ( ( $b1 << 2 ) | ( $b2 >> 6 ) ) & 63 ) . |
|
| 62 | + self::encode6Bits( $b2 & 63 ); |
|
| 63 | 63 | } |
| 64 | 64 | // The last chunk, which may have padding: |
| 65 | - if ($i < $srcLen) { |
|
| 65 | + if ( $i < $srcLen ) { |
|
| 66 | 66 | /** @var array<int, int> $chunk */ |
| 67 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i)); |
|
| 68 | - $b0 = $chunk[1]; |
|
| 69 | - if ($i + 1 < $srcLen) { |
|
| 70 | - $b1 = $chunk[2]; |
|
| 67 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, $srcLen - $i ) ); |
|
| 68 | + $b0 = $chunk[ 1 ]; |
|
| 69 | + if ( $i + 1 < $srcLen ) { |
|
| 70 | + $b1 = $chunk[ 2 ]; |
|
| 71 | 71 | $dest .= |
| 72 | - self::encode6Bits($b0 >> 2) . |
|
| 73 | - self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . |
|
| 74 | - self::encode6Bits(($b1 << 2) & 63); |
|
| 75 | - if ($pad) { |
|
| 72 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 73 | + self::encode6Bits( ( ( $b0 << 4 ) | ( $b1 >> 4 ) ) & 63 ) . |
|
| 74 | + self::encode6Bits( ( $b1 << 2 ) & 63 ); |
|
| 75 | + if ( $pad ) { |
|
| 76 | 76 | $dest .= '='; |
| 77 | 77 | } |
| 78 | 78 | } else { |
| 79 | 79 | $dest .= |
| 80 | - self::encode6Bits( $b0 >> 2) . |
|
| 81 | - self::encode6Bits(($b0 << 4) & 63); |
|
| 82 | - if ($pad) { |
|
| 80 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 81 | + self::encode6Bits( ( $b0 << 4 ) & 63 ); |
|
| 82 | + if ( $pad ) { |
|
| 83 | 83 | $dest .= '=='; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -99,86 +99,86 @@ discard block |
||
| 99 | 99 | * @throws TypeError |
| 100 | 100 | * @psalm-suppress RedundantCondition |
| 101 | 101 | */ |
| 102 | - public static function decode($src, $strictPadding = false) |
|
| 102 | + public static function decode( $src, $strictPadding = false ) |
|
| 103 | 103 | { |
| 104 | 104 | // Remove padding |
| 105 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 106 | - if ($srcLen === 0) { |
|
| 105 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 106 | + if ( $srcLen === 0 ) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($strictPadding) { |
|
| 111 | - if (($srcLen & 3) === 0) { |
|
| 112 | - if ($src[$srcLen - 1] === '=') { |
|
| 110 | + if ( $strictPadding ) { |
|
| 111 | + if ( ( $srcLen & 3 ) === 0 ) { |
|
| 112 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 113 | 113 | $srcLen--; |
| 114 | - if ($src[$srcLen - 1] === '=') { |
|
| 114 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 115 | 115 | $srcLen--; |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | - if (($srcLen & 3) === 1) { |
|
| 119 | + if ( ( $srcLen & 3 ) === 1 ) { |
|
| 120 | 120 | throw new RangeException( |
| 121 | 121 | 'Incorrect padding' |
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | - if ($src[$srcLen - 1] === '=') { |
|
| 124 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 125 | 125 | throw new RangeException( |
| 126 | 126 | 'Incorrect padding' |
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | } else { |
| 130 | - $src = rtrim($src, '='); |
|
| 131 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 130 | + $src = rtrim( $src, '=' ); |
|
| 131 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $err = 0; |
| 135 | 135 | $dest = ''; |
| 136 | 136 | // Main loop (no padding): |
| 137 | - for ($i = 0; $i + 4 <= $srcLen; $i += 4) { |
|
| 137 | + for ( $i = 0; $i + 4 <= $srcLen; $i += 4 ) { |
|
| 138 | 138 | /** @var array<int, int> $chunk */ |
| 139 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 4)); |
|
| 140 | - $c0 = self::decode6Bits($chunk[1]); |
|
| 141 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 142 | - $c2 = self::decode6Bits($chunk[3]); |
|
| 143 | - $c3 = self::decode6Bits($chunk[4]); |
|
| 139 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, 4 ) ); |
|
| 140 | + $c0 = self::decode6Bits( $chunk[ 1 ] ); |
|
| 141 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 142 | + $c2 = self::decode6Bits( $chunk[ 3 ] ); |
|
| 143 | + $c3 = self::decode6Bits( $chunk[ 4 ] ); |
|
| 144 | 144 | |
| 145 | 145 | $dest .= pack( |
| 146 | 146 | 'CCC', |
| 147 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff), |
|
| 148 | - ((($c1 << 4) | ($c2 >> 2)) & 0xff), |
|
| 149 | - ((($c2 << 6) | $c3) & 0xff) |
|
| 147 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ), |
|
| 148 | + ( ( ( $c1 << 4 ) | ( $c2 >> 2 ) ) & 0xff ), |
|
| 149 | + ( ( ( $c2 << 6 ) | $c3 ) & 0xff ) |
|
| 150 | 150 | ); |
| 151 | - $err |= ($c0 | $c1 | $c2 | $c3) >> 8; |
|
| 151 | + $err |= ( $c0 | $c1 | $c2 | $c3 ) >> 8; |
|
| 152 | 152 | } |
| 153 | 153 | // The last chunk, which may have padding: |
| 154 | - if ($i < $srcLen) { |
|
| 154 | + if ( $i < $srcLen ) { |
|
| 155 | 155 | /** @var array<int, int> $chunk */ |
| 156 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i)); |
|
| 157 | - $c0 = self::decode6Bits($chunk[1]); |
|
| 156 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, $srcLen - $i ) ); |
|
| 157 | + $c0 = self::decode6Bits( $chunk[ 1 ] ); |
|
| 158 | 158 | |
| 159 | - if ($i + 2 < $srcLen) { |
|
| 160 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 161 | - $c2 = self::decode6Bits($chunk[3]); |
|
| 159 | + if ( $i + 2 < $srcLen ) { |
|
| 160 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 161 | + $c2 = self::decode6Bits( $chunk[ 3 ] ); |
|
| 162 | 162 | $dest .= pack( |
| 163 | 163 | 'CC', |
| 164 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff), |
|
| 165 | - ((($c1 << 4) | ($c2 >> 2)) & 0xff) |
|
| 164 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ), |
|
| 165 | + ( ( ( $c1 << 4 ) | ( $c2 >> 2 ) ) & 0xff ) |
|
| 166 | 166 | ); |
| 167 | - $err |= ($c0 | $c1 | $c2) >> 8; |
|
| 168 | - } elseif ($i + 1 < $srcLen) { |
|
| 169 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 167 | + $err |= ( $c0 | $c1 | $c2 ) >> 8; |
|
| 168 | + } elseif ( $i + 1 < $srcLen ) { |
|
| 169 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 170 | 170 | $dest .= pack( |
| 171 | 171 | 'C', |
| 172 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff) |
|
| 172 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ) |
|
| 173 | 173 | ); |
| 174 | - $err |= ($c0 | $c1) >> 8; |
|
| 175 | - } elseif ($i < $srcLen && $strictPadding) { |
|
| 174 | + $err |= ( $c0 | $c1 ) >> 8; |
|
| 175 | + } elseif ( $i < $srcLen && $strictPadding ) { |
|
| 176 | 176 | $err |= 1; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | /** @var bool $check */ |
| 180 | - $check = ($err === 0); |
|
| 181 | - if (!$check) { |
|
| 180 | + $check = ( $err === 0 ); |
|
| 181 | + if ( ! $check ) { |
|
| 182 | 182 | throw new RangeException( |
| 183 | 183 | 'Base64::decode() only expects characters in the correct base64 alphabet' |
| 184 | 184 | ); |
@@ -198,24 +198,24 @@ discard block |
||
| 198 | 198 | * @param int $src |
| 199 | 199 | * @return int |
| 200 | 200 | */ |
| 201 | - protected static function decode6Bits($src) |
|
| 201 | + protected static function decode6Bits( $src ) |
|
| 202 | 202 | { |
| 203 | 203 | $ret = -1; |
| 204 | 204 | |
| 205 | 205 | // if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64 |
| 206 | - $ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64); |
|
| 206 | + $ret += ( ( ( 0x40 - $src ) & ( $src - 0x5b ) ) >> 8 ) & ( $src - 64 ); |
|
| 207 | 207 | |
| 208 | 208 | // if ($src > 0x60 && $src < 0x7b) $ret += $src - 0x61 + 26 + 1; // -70 |
| 209 | - $ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 70); |
|
| 209 | + $ret += ( ( ( 0x60 - $src ) & ( $src - 0x7b ) ) >> 8 ) & ( $src - 70 ); |
|
| 210 | 210 | |
| 211 | 211 | // if ($src > 0x2f && $src < 0x3a) $ret += $src - 0x30 + 52 + 1; // 5 |
| 212 | - $ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 5); |
|
| 212 | + $ret += ( ( ( 0x2f - $src ) & ( $src - 0x3a ) ) >> 8 ) & ( $src + 5 ); |
|
| 213 | 213 | |
| 214 | 214 | // if ($src == 0x2b) $ret += 62 + 1; |
| 215 | - $ret += (((0x2a - $src) & ($src - 0x2c)) >> 8) & 63; |
|
| 215 | + $ret += ( ( ( 0x2a - $src ) & ( $src - 0x2c ) ) >> 8 ) & 63; |
|
| 216 | 216 | |
| 217 | 217 | // if ($src == 0x2f) ret += 63 + 1; |
| 218 | - $ret += (((0x2e - $src) & ($src - 0x30)) >> 8) & 64; |
|
| 218 | + $ret += ( ( ( 0x2e - $src ) & ( $src - 0x30 ) ) >> 8 ) & 64; |
|
| 219 | 219 | |
| 220 | 220 | return $ret; |
| 221 | 221 | } |
@@ -227,22 +227,22 @@ discard block |
||
| 227 | 227 | * @param int $src |
| 228 | 228 | * @return string |
| 229 | 229 | */ |
| 230 | - protected static function encode6Bits($src) |
|
| 230 | + protected static function encode6Bits( $src ) |
|
| 231 | 231 | { |
| 232 | 232 | $diff = 0x41; |
| 233 | 233 | |
| 234 | 234 | // if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6 |
| 235 | - $diff += ((25 - $src) >> 8) & 6; |
|
| 235 | + $diff += ( ( 25 - $src ) >> 8 ) & 6; |
|
| 236 | 236 | |
| 237 | 237 | // if ($src > 51) $diff += 0x30 - 0x61 - 26; // -75 |
| 238 | - $diff -= ((51 - $src) >> 8) & 75; |
|
| 238 | + $diff -= ( ( 51 - $src ) >> 8 ) & 75; |
|
| 239 | 239 | |
| 240 | 240 | // if ($src > 61) $diff += 0x2b - 0x30 - 10; // -15 |
| 241 | - $diff -= ((61 - $src) >> 8) & 15; |
|
| 241 | + $diff -= ( ( 61 - $src ) >> 8 ) & 15; |
|
| 242 | 242 | |
| 243 | 243 | // if ($src > 62) $diff += 0x2f - 0x2b - 1; // 3 |
| 244 | - $diff += ((62 - $src) >> 8) & 3; |
|
| 244 | + $diff += ( ( 62 - $src ) >> 8 ) & 3; |
|
| 245 | 245 | |
| 246 | - return pack('C', $src + $diff); |
|
| 246 | + return pack( 'C', $src + $diff ); |
|
| 247 | 247 | } |
| 248 | 248 | } |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | * @return string |
| 19 | 19 | * @throws TypeError |
| 20 | 20 | */ |
| 21 | - public static function encode($src) |
|
| 21 | + public static function encode( $src ) |
|
| 22 | 22 | { |
| 23 | - return self::doEncode($src, true); |
|
| 23 | + return self::doEncode( $src, true ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * @return string |
| 33 | 33 | * @throws TypeError |
| 34 | 34 | */ |
| 35 | - public static function encodeUnpadded($src) |
|
| 35 | + public static function encodeUnpadded( $src ) |
|
| 36 | 36 | { |
| 37 | - return self::doEncode($src, false); |
|
| 37 | + return self::doEncode( $src, false ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,43 +43,43 @@ discard block |
||
| 43 | 43 | * @return string |
| 44 | 44 | * @throws TypeError |
| 45 | 45 | */ |
| 46 | - protected static function doEncode($src, $pad = true) |
|
| 46 | + protected static function doEncode( $src, $pad = true ) |
|
| 47 | 47 | { |
| 48 | 48 | $dest = ''; |
| 49 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 49 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 50 | 50 | // Main loop (no padding): |
| 51 | - for ($i = 0; $i + 3 <= $srcLen; $i += 3) { |
|
| 51 | + for ( $i = 0; $i + 3 <= $srcLen; $i += 3 ) { |
|
| 52 | 52 | /** @var array<int, int> $chunk */ |
| 53 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 3)); |
|
| 54 | - $b0 = $chunk[1]; |
|
| 55 | - $b1 = $chunk[2]; |
|
| 56 | - $b2 = $chunk[3]; |
|
| 53 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, 3 ) ); |
|
| 54 | + $b0 = $chunk[ 1 ]; |
|
| 55 | + $b1 = $chunk[ 2 ]; |
|
| 56 | + $b2 = $chunk[ 3 ]; |
|
| 57 | 57 | |
| 58 | 58 | $dest .= |
| 59 | - self::encode6Bits( $b0 >> 2 ) . |
|
| 60 | - self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . |
|
| 61 | - self::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) . |
|
| 62 | - self::encode6Bits( $b2 & 63); |
|
| 59 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 60 | + self::encode6Bits( ( ( $b0 << 4 ) | ( $b1 >> 4 ) ) & 63 ) . |
|
| 61 | + self::encode6Bits( ( ( $b1 << 2 ) | ( $b2 >> 6 ) ) & 63 ) . |
|
| 62 | + self::encode6Bits( $b2 & 63 ); |
|
| 63 | 63 | } |
| 64 | 64 | // The last chunk, which may have padding: |
| 65 | - if ($i < $srcLen) { |
|
| 65 | + if ( $i < $srcLen ) { |
|
| 66 | 66 | /** @var array<int, int> $chunk */ |
| 67 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i)); |
|
| 68 | - $b0 = $chunk[1]; |
|
| 69 | - if ($i + 1 < $srcLen) { |
|
| 70 | - $b1 = $chunk[2]; |
|
| 67 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, $srcLen - $i ) ); |
|
| 68 | + $b0 = $chunk[ 1 ]; |
|
| 69 | + if ( $i + 1 < $srcLen ) { |
|
| 70 | + $b1 = $chunk[ 2 ]; |
|
| 71 | 71 | $dest .= |
| 72 | - self::encode6Bits($b0 >> 2) . |
|
| 73 | - self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) . |
|
| 74 | - self::encode6Bits(($b1 << 2) & 63); |
|
| 75 | - if ($pad) { |
|
| 72 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 73 | + self::encode6Bits( ( ( $b0 << 4 ) | ( $b1 >> 4 ) ) & 63 ) . |
|
| 74 | + self::encode6Bits( ( $b1 << 2 ) & 63 ); |
|
| 75 | + if ( $pad ) { |
|
| 76 | 76 | $dest .= '='; |
| 77 | 77 | } |
| 78 | 78 | } else { |
| 79 | 79 | $dest .= |
| 80 | - self::encode6Bits( $b0 >> 2) . |
|
| 81 | - self::encode6Bits(($b0 << 4) & 63); |
|
| 82 | - if ($pad) { |
|
| 80 | + self::encode6Bits( $b0 >> 2 ) . |
|
| 81 | + self::encode6Bits( ( $b0 << 4 ) & 63 ); |
|
| 82 | + if ( $pad ) { |
|
| 83 | 83 | $dest .= '=='; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -99,86 +99,86 @@ discard block |
||
| 99 | 99 | * @throws TypeError |
| 100 | 100 | * @psalm-suppress RedundantCondition |
| 101 | 101 | */ |
| 102 | - public static function decode($src, $strictPadding = false) |
|
| 102 | + public static function decode( $src, $strictPadding = false ) |
|
| 103 | 103 | { |
| 104 | 104 | // Remove padding |
| 105 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 106 | - if ($srcLen === 0) { |
|
| 105 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 106 | + if ( $srcLen === 0 ) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($strictPadding) { |
|
| 111 | - if (($srcLen & 3) === 0) { |
|
| 112 | - if ($src[$srcLen - 1] === '=') { |
|
| 110 | + if ( $strictPadding ) { |
|
| 111 | + if ( ( $srcLen & 3 ) === 0 ) { |
|
| 112 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 113 | 113 | $srcLen--; |
| 114 | - if ($src[$srcLen - 1] === '=') { |
|
| 114 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 115 | 115 | $srcLen--; |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | - if (($srcLen & 3) === 1) { |
|
| 119 | + if ( ( $srcLen & 3 ) === 1 ) { |
|
| 120 | 120 | throw new RangeException( |
| 121 | 121 | 'Incorrect padding' |
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | - if ($src[$srcLen - 1] === '=') { |
|
| 124 | + if ( $src[ $srcLen - 1 ] === '=' ) { |
|
| 125 | 125 | throw new RangeException( |
| 126 | 126 | 'Incorrect padding' |
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | } else { |
| 130 | - $src = rtrim($src, '='); |
|
| 131 | - $srcLen = ParagonIE_Sodium_Core_Util::strlen($src); |
|
| 130 | + $src = rtrim( $src, '=' ); |
|
| 131 | + $srcLen = ParagonIE_Sodium_Core_Util::strlen( $src ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $err = 0; |
| 135 | 135 | $dest = ''; |
| 136 | 136 | // Main loop (no padding): |
| 137 | - for ($i = 0; $i + 4 <= $srcLen; $i += 4) { |
|
| 137 | + for ( $i = 0; $i + 4 <= $srcLen; $i += 4 ) { |
|
| 138 | 138 | /** @var array<int, int> $chunk */ |
| 139 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 4)); |
|
| 140 | - $c0 = self::decode6Bits($chunk[1]); |
|
| 141 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 142 | - $c2 = self::decode6Bits($chunk[3]); |
|
| 143 | - $c3 = self::decode6Bits($chunk[4]); |
|
| 139 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, 4 ) ); |
|
| 140 | + $c0 = self::decode6Bits( $chunk[ 1 ] ); |
|
| 141 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 142 | + $c2 = self::decode6Bits( $chunk[ 3 ] ); |
|
| 143 | + $c3 = self::decode6Bits( $chunk[ 4 ] ); |
|
| 144 | 144 | |
| 145 | 145 | $dest .= pack( |
| 146 | 146 | 'CCC', |
| 147 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff), |
|
| 148 | - ((($c1 << 4) | ($c2 >> 2)) & 0xff), |
|
| 149 | - ((($c2 << 6) | $c3) & 0xff) |
|
| 147 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ), |
|
| 148 | + ( ( ( $c1 << 4 ) | ( $c2 >> 2 ) ) & 0xff ), |
|
| 149 | + ( ( ( $c2 << 6 ) | $c3 ) & 0xff ) |
|
| 150 | 150 | ); |
| 151 | - $err |= ($c0 | $c1 | $c2 | $c3) >> 8; |
|
| 151 | + $err |= ( $c0 | $c1 | $c2 | $c3 ) >> 8; |
|
| 152 | 152 | } |
| 153 | 153 | // The last chunk, which may have padding: |
| 154 | - if ($i < $srcLen) { |
|
| 154 | + if ( $i < $srcLen ) { |
|
| 155 | 155 | /** @var array<int, int> $chunk */ |
| 156 | - $chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i)); |
|
| 157 | - $c0 = self::decode6Bits($chunk[1]); |
|
| 156 | + $chunk = unpack( 'C*', ParagonIE_Sodium_Core_Util::substr( $src, $i, $srcLen - $i ) ); |
|
| 157 | + $c0 = self::decode6Bits( $chunk[ 1 ] ); |
|
| 158 | 158 | |
| 159 | - if ($i + 2 < $srcLen) { |
|
| 160 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 161 | - $c2 = self::decode6Bits($chunk[3]); |
|
| 159 | + if ( $i + 2 < $srcLen ) { |
|
| 160 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 161 | + $c2 = self::decode6Bits( $chunk[ 3 ] ); |
|
| 162 | 162 | $dest .= pack( |
| 163 | 163 | 'CC', |
| 164 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff), |
|
| 165 | - ((($c1 << 4) | ($c2 >> 2)) & 0xff) |
|
| 164 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ), |
|
| 165 | + ( ( ( $c1 << 4 ) | ( $c2 >> 2 ) ) & 0xff ) |
|
| 166 | 166 | ); |
| 167 | - $err |= ($c0 | $c1 | $c2) >> 8; |
|
| 168 | - } elseif ($i + 1 < $srcLen) { |
|
| 169 | - $c1 = self::decode6Bits($chunk[2]); |
|
| 167 | + $err |= ( $c0 | $c1 | $c2 ) >> 8; |
|
| 168 | + } elseif ( $i + 1 < $srcLen ) { |
|
| 169 | + $c1 = self::decode6Bits( $chunk[ 2 ] ); |
|
| 170 | 170 | $dest .= pack( |
| 171 | 171 | 'C', |
| 172 | - ((($c0 << 2) | ($c1 >> 4)) & 0xff) |
|
| 172 | + ( ( ( $c0 << 2 ) | ( $c1 >> 4 ) ) & 0xff ) |
|
| 173 | 173 | ); |
| 174 | - $err |= ($c0 | $c1) >> 8; |
|
| 175 | - } elseif ($i < $srcLen && $strictPadding) { |
|
| 174 | + $err |= ( $c0 | $c1 ) >> 8; |
|
| 175 | + } elseif ( $i < $srcLen && $strictPadding ) { |
|
| 176 | 176 | $err |= 1; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | /** @var bool $check */ |
| 180 | - $check = ($err === 0); |
|
| 181 | - if (!$check) { |
|
| 180 | + $check = ( $err === 0 ); |
|
| 181 | + if ( ! $check ) { |
|
| 182 | 182 | throw new RangeException( |
| 183 | 183 | 'Base64::decode() only expects characters in the correct base64 alphabet' |
| 184 | 184 | ); |
@@ -197,24 +197,24 @@ discard block |
||
| 197 | 197 | * @param int $src |
| 198 | 198 | * @return int |
| 199 | 199 | */ |
| 200 | - protected static function decode6Bits($src) |
|
| 200 | + protected static function decode6Bits( $src ) |
|
| 201 | 201 | { |
| 202 | 202 | $ret = -1; |
| 203 | 203 | |
| 204 | 204 | // if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64 |
| 205 | - $ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64); |
|
| 205 | + $ret += ( ( ( 0x40 - $src ) & ( $src - 0x5b ) ) >> 8 ) & ( $src - 64 ); |
|
| 206 | 206 | |
| 207 | 207 | // if ($src > 0x60 && $src < 0x7b) $ret += $src - 0x61 + 26 + 1; // -70 |
| 208 | - $ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 70); |
|
| 208 | + $ret += ( ( ( 0x60 - $src ) & ( $src - 0x7b ) ) >> 8 ) & ( $src - 70 ); |
|
| 209 | 209 | |
| 210 | 210 | // if ($src > 0x2f && $src < 0x3a) $ret += $src - 0x30 + 52 + 1; // 5 |
| 211 | - $ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 5); |
|
| 211 | + $ret += ( ( ( 0x2f - $src ) & ( $src - 0x3a ) ) >> 8 ) & ( $src + 5 ); |
|
| 212 | 212 | |
| 213 | 213 | // if ($src == 0x2c) $ret += 62 + 1; |
| 214 | - $ret += (((0x2c - $src) & ($src - 0x2e)) >> 8) & 63; |
|
| 214 | + $ret += ( ( ( 0x2c - $src ) & ( $src - 0x2e ) ) >> 8 ) & 63; |
|
| 215 | 215 | |
| 216 | 216 | // if ($src == 0x5f) ret += 63 + 1; |
| 217 | - $ret += (((0x5e - $src) & ($src - 0x60)) >> 8) & 64; |
|
| 217 | + $ret += ( ( ( 0x5e - $src ) & ( $src - 0x60 ) ) >> 8 ) & 64; |
|
| 218 | 218 | |
| 219 | 219 | return $ret; |
| 220 | 220 | } |
@@ -226,22 +226,22 @@ discard block |
||
| 226 | 226 | * @param int $src |
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | - protected static function encode6Bits($src) |
|
| 229 | + protected static function encode6Bits( $src ) |
|
| 230 | 230 | { |
| 231 | 231 | $diff = 0x41; |
| 232 | 232 | |
| 233 | 233 | // if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6 |
| 234 | - $diff += ((25 - $src) >> 8) & 6; |
|
| 234 | + $diff += ( ( 25 - $src ) >> 8 ) & 6; |
|
| 235 | 235 | |
| 236 | 236 | // if ($src > 51) $diff += 0x30 - 0x61 - 26; // -75 |
| 237 | - $diff -= ((51 - $src) >> 8) & 75; |
|
| 237 | + $diff -= ( ( 51 - $src ) >> 8 ) & 75; |
|
| 238 | 238 | |
| 239 | 239 | // if ($src > 61) $diff += 0x2d - 0x30 - 10; // -13 |
| 240 | - $diff -= ((61 - $src) >> 8) & 13; |
|
| 240 | + $diff -= ( ( 61 - $src ) >> 8 ) & 13; |
|
| 241 | 241 | |
| 242 | 242 | // if ($src > 62) $diff += 0x5f - 0x2b - 1; // 3 |
| 243 | - $diff += ((62 - $src) >> 8) & 49; |
|
| 243 | + $diff += ( ( 62 - $src ) >> 8 ) & 49; |
|
| 244 | 244 | |
| 245 | - return pack('C', $src + $diff); |
|
| 245 | + return pack( 'C', $src + $diff ); |
|
| 246 | 246 | } |
| 247 | 247 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (class_exists('ParagonIE_Sodium_Core_Curve25519_Fe', false)) { |
|
| 3 | +if ( class_exists( 'ParagonIE_Sodium_Core_Curve25519_Fe', false ) ) { |
|
| 4 | 4 | return; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -28,25 +28,25 @@ discard block |
||
| 28 | 28 | * @param bool $save_indexes |
| 29 | 29 | * @return self |
| 30 | 30 | */ |
| 31 | - public static function fromArray($array, $save_indexes = null) |
|
| 31 | + public static function fromArray( $array, $save_indexes = null ) |
|
| 32 | 32 | { |
| 33 | - $count = count($array); |
|
| 34 | - if ($save_indexes) { |
|
| 35 | - $keys = array_keys($array); |
|
| 33 | + $count = count( $array ); |
|
| 34 | + if ( $save_indexes ) { |
|
| 35 | + $keys = array_keys( $array ); |
|
| 36 | 36 | } else { |
| 37 | - $keys = range(0, $count - 1); |
|
| 37 | + $keys = range( 0, $count - 1 ); |
|
| 38 | 38 | } |
| 39 | - $array = array_values($array); |
|
| 39 | + $array = array_values( $array ); |
|
| 40 | 40 | /** @var array<int, int> $keys */ |
| 41 | 41 | |
| 42 | 42 | $obj = new ParagonIE_Sodium_Core_Curve25519_Fe(); |
| 43 | - if ($save_indexes) { |
|
| 44 | - for ($i = 0; $i < $count; ++$i) { |
|
| 45 | - $obj->offsetSet($keys[$i], $array[$i]); |
|
| 43 | + if ( $save_indexes ) { |
|
| 44 | + for ( $i = 0; $i < $count; ++$i ) { |
|
| 45 | + $obj->offsetSet( $keys[ $i ], $array[ $i ] ); |
|
| 46 | 46 | } |
| 47 | 47 | } else { |
| 48 | - for ($i = 0; $i < $count; ++$i) { |
|
| 49 | - $obj->offsetSet($i, $array[$i]); |
|
| 48 | + for ( $i = 0; $i < $count; ++$i ) { |
|
| 49 | + $obj->offsetSet( $i, $array[ $i ] ); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | return $obj; |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | * @return void |
| 61 | 61 | * @psalm-suppress MixedArrayOffset |
| 62 | 62 | */ |
| 63 | - #[ReturnTypeWillChange] |
|
| 64 | - public function offsetSet($offset, $value) |
|
| 63 | + #[ReturnTypeWillChange ] |
|
| 64 | + public function offsetSet( $offset, $value ) |
|
| 65 | 65 | { |
| 66 | - if (!is_int($value)) { |
|
| 67 | - throw new InvalidArgumentException('Expected an integer'); |
|
| 66 | + if ( ! is_int( $value ) ) { |
|
| 67 | + throw new InvalidArgumentException( 'Expected an integer' ); |
|
| 68 | 68 | } |
| 69 | - if (is_null($offset)) { |
|
| 70 | - $this->container[] = $value; |
|
| 69 | + if ( is_null( $offset ) ) { |
|
| 70 | + $this->container[ ] = $value; |
|
| 71 | 71 | } else { |
| 72 | - $this->container[$offset] = $value; |
|
| 72 | + $this->container[ $offset ] = $value; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | * @return bool |
| 81 | 81 | * @psalm-suppress MixedArrayOffset |
| 82 | 82 | */ |
| 83 | - #[ReturnTypeWillChange] |
|
| 84 | - public function offsetExists($offset) |
|
| 83 | + #[ReturnTypeWillChange ] |
|
| 84 | + public function offsetExists( $offset ) |
|
| 85 | 85 | { |
| 86 | - return isset($this->container[$offset]); |
|
| 86 | + return isset( $this->container[ $offset ] ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | * @return void |
| 94 | 94 | * @psalm-suppress MixedArrayOffset |
| 95 | 95 | */ |
| 96 | - #[ReturnTypeWillChange] |
|
| 97 | - public function offsetUnset($offset) |
|
| 96 | + #[ReturnTypeWillChange ] |
|
| 97 | + public function offsetUnset( $offset ) |
|
| 98 | 98 | { |
| 99 | - unset($this->container[$offset]); |
|
| 99 | + unset( $this->container[ $offset ] ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * @return int |
| 107 | 107 | * @psalm-suppress MixedArrayOffset |
| 108 | 108 | */ |
| 109 | - #[ReturnTypeWillChange] |
|
| 110 | - public function offsetGet($offset) |
|
| 109 | + #[ReturnTypeWillChange ] |
|
| 110 | + public function offsetGet( $offset ) |
|
| 111 | 111 | { |
| 112 | - if (!isset($this->container[$offset])) { |
|
| 113 | - $this->container[$offset] = 0; |
|
| 112 | + if ( ! isset( $this->container[ $offset ] ) ) { |
|
| 113 | + $this->container[ $offset ] = 0; |
|
| 114 | 114 | } |
| 115 | - return (int) ($this->container[$offset]); |
|
| 115 | + return (int)( $this->container[ $offset ] ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,6 +122,6 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function __debugInfo() |
| 124 | 124 | { |
| 125 | - return array(implode(', ', $this->container)); |
|
| 125 | + return array( implode( ', ', $this->container ) ); |
|
| 126 | 126 | } |
| 127 | 127 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (class_exists('ParagonIE_Sodium_Core_HChaCha20', false)) { |
|
| 3 | +if ( class_exists( 'ParagonIE_Sodium_Core_HChaCha20', false ) ) { |
|
| 4 | 4 | return; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -16,34 +16,34 @@ discard block |
||
| 16 | 16 | * @return string |
| 17 | 17 | * @throws TypeError |
| 18 | 18 | */ |
| 19 | - public static function hChaCha20($in = '', $key = '', $c = null) |
|
| 19 | + public static function hChaCha20( $in = '', $key = '', $c = null ) |
|
| 20 | 20 | { |
| 21 | 21 | $ctx = array(); |
| 22 | 22 | |
| 23 | - if ($c === null) { |
|
| 24 | - $ctx[0] = 0x61707865; |
|
| 25 | - $ctx[1] = 0x3320646e; |
|
| 26 | - $ctx[2] = 0x79622d32; |
|
| 27 | - $ctx[3] = 0x6b206574; |
|
| 23 | + if ( $c === null ) { |
|
| 24 | + $ctx[ 0 ] = 0x61707865; |
|
| 25 | + $ctx[ 1 ] = 0x3320646e; |
|
| 26 | + $ctx[ 2 ] = 0x79622d32; |
|
| 27 | + $ctx[ 3 ] = 0x6b206574; |
|
| 28 | 28 | } else { |
| 29 | - $ctx[0] = self::load_4(self::substr($c, 0, 4)); |
|
| 30 | - $ctx[1] = self::load_4(self::substr($c, 4, 4)); |
|
| 31 | - $ctx[2] = self::load_4(self::substr($c, 8, 4)); |
|
| 32 | - $ctx[3] = self::load_4(self::substr($c, 12, 4)); |
|
| 29 | + $ctx[ 0 ] = self::load_4( self::substr( $c, 0, 4 ) ); |
|
| 30 | + $ctx[ 1 ] = self::load_4( self::substr( $c, 4, 4 ) ); |
|
| 31 | + $ctx[ 2 ] = self::load_4( self::substr( $c, 8, 4 ) ); |
|
| 32 | + $ctx[ 3 ] = self::load_4( self::substr( $c, 12, 4 ) ); |
|
| 33 | 33 | } |
| 34 | - $ctx[4] = self::load_4(self::substr($key, 0, 4)); |
|
| 35 | - $ctx[5] = self::load_4(self::substr($key, 4, 4)); |
|
| 36 | - $ctx[6] = self::load_4(self::substr($key, 8, 4)); |
|
| 37 | - $ctx[7] = self::load_4(self::substr($key, 12, 4)); |
|
| 38 | - $ctx[8] = self::load_4(self::substr($key, 16, 4)); |
|
| 39 | - $ctx[9] = self::load_4(self::substr($key, 20, 4)); |
|
| 40 | - $ctx[10] = self::load_4(self::substr($key, 24, 4)); |
|
| 41 | - $ctx[11] = self::load_4(self::substr($key, 28, 4)); |
|
| 42 | - $ctx[12] = self::load_4(self::substr($in, 0, 4)); |
|
| 43 | - $ctx[13] = self::load_4(self::substr($in, 4, 4)); |
|
| 44 | - $ctx[14] = self::load_4(self::substr($in, 8, 4)); |
|
| 45 | - $ctx[15] = self::load_4(self::substr($in, 12, 4)); |
|
| 46 | - return self::hChaCha20Bytes($ctx); |
|
| 34 | + $ctx[ 4 ] = self::load_4( self::substr( $key, 0, 4 ) ); |
|
| 35 | + $ctx[ 5 ] = self::load_4( self::substr( $key, 4, 4 ) ); |
|
| 36 | + $ctx[ 6 ] = self::load_4( self::substr( $key, 8, 4 ) ); |
|
| 37 | + $ctx[ 7 ] = self::load_4( self::substr( $key, 12, 4 ) ); |
|
| 38 | + $ctx[ 8 ] = self::load_4( self::substr( $key, 16, 4 ) ); |
|
| 39 | + $ctx[ 9 ] = self::load_4( self::substr( $key, 20, 4 ) ); |
|
| 40 | + $ctx[ 10 ] = self::load_4( self::substr( $key, 24, 4 ) ); |
|
| 41 | + $ctx[ 11 ] = self::load_4( self::substr( $key, 28, 4 ) ); |
|
| 42 | + $ctx[ 12 ] = self::load_4( self::substr( $in, 0, 4 ) ); |
|
| 43 | + $ctx[ 13 ] = self::load_4( self::substr( $in, 4, 4 ) ); |
|
| 44 | + $ctx[ 14 ] = self::load_4( self::substr( $in, 8, 4 ) ); |
|
| 45 | + $ctx[ 15 ] = self::load_4( self::substr( $in, 12, 4 ) ); |
|
| 46 | + return self::hChaCha20Bytes( $ctx ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,58 +51,58 @@ discard block |
||
| 51 | 51 | * @return string |
| 52 | 52 | * @throws TypeError |
| 53 | 53 | */ |
| 54 | - protected static function hChaCha20Bytes(array $ctx) |
|
| 54 | + protected static function hChaCha20Bytes( array $ctx ) |
|
| 55 | 55 | { |
| 56 | - $x0 = (int) $ctx[0]; |
|
| 57 | - $x1 = (int) $ctx[1]; |
|
| 58 | - $x2 = (int) $ctx[2]; |
|
| 59 | - $x3 = (int) $ctx[3]; |
|
| 60 | - $x4 = (int) $ctx[4]; |
|
| 61 | - $x5 = (int) $ctx[5]; |
|
| 62 | - $x6 = (int) $ctx[6]; |
|
| 63 | - $x7 = (int) $ctx[7]; |
|
| 64 | - $x8 = (int) $ctx[8]; |
|
| 65 | - $x9 = (int) $ctx[9]; |
|
| 66 | - $x10 = (int) $ctx[10]; |
|
| 67 | - $x11 = (int) $ctx[11]; |
|
| 68 | - $x12 = (int) $ctx[12]; |
|
| 69 | - $x13 = (int) $ctx[13]; |
|
| 70 | - $x14 = (int) $ctx[14]; |
|
| 71 | - $x15 = (int) $ctx[15]; |
|
| 56 | + $x0 = (int)$ctx[ 0 ]; |
|
| 57 | + $x1 = (int)$ctx[ 1 ]; |
|
| 58 | + $x2 = (int)$ctx[ 2 ]; |
|
| 59 | + $x3 = (int)$ctx[ 3 ]; |
|
| 60 | + $x4 = (int)$ctx[ 4 ]; |
|
| 61 | + $x5 = (int)$ctx[ 5 ]; |
|
| 62 | + $x6 = (int)$ctx[ 6 ]; |
|
| 63 | + $x7 = (int)$ctx[ 7 ]; |
|
| 64 | + $x8 = (int)$ctx[ 8 ]; |
|
| 65 | + $x9 = (int)$ctx[ 9 ]; |
|
| 66 | + $x10 = (int)$ctx[ 10 ]; |
|
| 67 | + $x11 = (int)$ctx[ 11 ]; |
|
| 68 | + $x12 = (int)$ctx[ 12 ]; |
|
| 69 | + $x13 = (int)$ctx[ 13 ]; |
|
| 70 | + $x14 = (int)$ctx[ 14 ]; |
|
| 71 | + $x15 = (int)$ctx[ 15 ]; |
|
| 72 | 72 | |
| 73 | - for ($i = 0; $i < 10; ++$i) { |
|
| 73 | + for ( $i = 0; $i < 10; ++$i ) { |
|
| 74 | 74 | # QUARTERROUND( x0, x4, x8, x12) |
| 75 | - list($x0, $x4, $x8, $x12) = self::quarterRound($x0, $x4, $x8, $x12); |
|
| 75 | + list( $x0, $x4, $x8, $x12 ) = self::quarterRound( $x0, $x4, $x8, $x12 ); |
|
| 76 | 76 | |
| 77 | 77 | # QUARTERROUND( x1, x5, x9, x13) |
| 78 | - list($x1, $x5, $x9, $x13) = self::quarterRound($x1, $x5, $x9, $x13); |
|
| 78 | + list( $x1, $x5, $x9, $x13 ) = self::quarterRound( $x1, $x5, $x9, $x13 ); |
|
| 79 | 79 | |
| 80 | 80 | # QUARTERROUND( x2, x6, x10, x14) |
| 81 | - list($x2, $x6, $x10, $x14) = self::quarterRound($x2, $x6, $x10, $x14); |
|
| 81 | + list( $x2, $x6, $x10, $x14 ) = self::quarterRound( $x2, $x6, $x10, $x14 ); |
|
| 82 | 82 | |
| 83 | 83 | # QUARTERROUND( x3, x7, x11, x15) |
| 84 | - list($x3, $x7, $x11, $x15) = self::quarterRound($x3, $x7, $x11, $x15); |
|
| 84 | + list( $x3, $x7, $x11, $x15 ) = self::quarterRound( $x3, $x7, $x11, $x15 ); |
|
| 85 | 85 | |
| 86 | 86 | # QUARTERROUND( x0, x5, x10, x15) |
| 87 | - list($x0, $x5, $x10, $x15) = self::quarterRound($x0, $x5, $x10, $x15); |
|
| 87 | + list( $x0, $x5, $x10, $x15 ) = self::quarterRound( $x0, $x5, $x10, $x15 ); |
|
| 88 | 88 | |
| 89 | 89 | # QUARTERROUND( x1, x6, x11, x12) |
| 90 | - list($x1, $x6, $x11, $x12) = self::quarterRound($x1, $x6, $x11, $x12); |
|
| 90 | + list( $x1, $x6, $x11, $x12 ) = self::quarterRound( $x1, $x6, $x11, $x12 ); |
|
| 91 | 91 | |
| 92 | 92 | # QUARTERROUND( x2, x7, x8, x13) |
| 93 | - list($x2, $x7, $x8, $x13) = self::quarterRound($x2, $x7, $x8, $x13); |
|
| 93 | + list( $x2, $x7, $x8, $x13 ) = self::quarterRound( $x2, $x7, $x8, $x13 ); |
|
| 94 | 94 | |
| 95 | 95 | # QUARTERROUND( x3, x4, x9, x14) |
| 96 | - list($x3, $x4, $x9, $x14) = self::quarterRound($x3, $x4, $x9, $x14); |
|
| 96 | + list( $x3, $x4, $x9, $x14 ) = self::quarterRound( $x3, $x4, $x9, $x14 ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - return self::store32_le((int) ($x0 & 0xffffffff)) . |
|
| 100 | - self::store32_le((int) ($x1 & 0xffffffff)) . |
|
| 101 | - self::store32_le((int) ($x2 & 0xffffffff)) . |
|
| 102 | - self::store32_le((int) ($x3 & 0xffffffff)) . |
|
| 103 | - self::store32_le((int) ($x12 & 0xffffffff)) . |
|
| 104 | - self::store32_le((int) ($x13 & 0xffffffff)) . |
|
| 105 | - self::store32_le((int) ($x14 & 0xffffffff)) . |
|
| 106 | - self::store32_le((int) ($x15 & 0xffffffff)); |
|
| 99 | + return self::store32_le( (int)( $x0 & 0xffffffff ) ) . |
|
| 100 | + self::store32_le( (int)( $x1 & 0xffffffff ) ) . |
|
| 101 | + self::store32_le( (int)( $x2 & 0xffffffff ) ) . |
|
| 102 | + self::store32_le( (int)( $x3 & 0xffffffff ) ) . |
|
| 103 | + self::store32_le( (int)( $x12 & 0xffffffff ) ) . |
|
| 104 | + self::store32_le( (int)( $x13 & 0xffffffff ) ) . |
|
| 105 | + self::store32_le( (int)( $x14 & 0xffffffff ) ) . |
|
| 106 | + self::store32_le( (int)( $x15 & 0xffffffff ) ); |
|
| 107 | 107 | } |
| 108 | 108 | } |