File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ protected function getNextChar(string $c): string
137137 );
138138 }
139139
140- public function testUnpadded ()
140+ public function testUnpadded (): void
141141 {
142142 for ($ i = 1 ; $ i < 32 ; ++$ i ) {
143143 $ random = random_bytes ($ i );
@@ -160,11 +160,27 @@ public static function invalidCharactersProvider(): array
160160 ];
161161 }
162162
163+ /**
164+ * Detect issue underlying #67 with ext-sodium
165+ *
166+ * @return void
167+ * @throws Exception
168+ */
169+ public function testStrictPaddingSodium (): void
170+ {
171+ for ($ i = 1 ; $ i < 32 ; ++$ i ) {
172+ $ random = random_bytes ($ i );
173+ $ encoded = Base64::encode ($ random );
174+ $ decoded = Base64::decode ($ encoded , true );
175+ $ this ->assertSame ($ decoded , $ random );
176+ }
177+ }
178+
163179 /**
164180 * @dataProvider invalidCharactersProvider
165181 */
166182 #[DataProvider("invalidCharactersProvider " )]
167- public function testInvalidCharacters (string $ encoded )
183+ public function testInvalidCharacters (string $ encoded ): void
168184 {
169185 $ this ->expectException (RangeException::class);
170186 Base64::decode ($ encoded );
Original file line number Diff line number Diff line change @@ -120,6 +120,22 @@ public static function invalidCharactersProvider(): array
120120 ];
121121 }
122122
123+ /**
124+ * Detect issue underlying #67 with ext-sodium
125+ *
126+ * @return void
127+ * @throws Exception
128+ */
129+ public function testStrictPaddingSodium (): void
130+ {
131+ for ($ i = 1 ; $ i < 32 ; ++$ i ) {
132+ $ random = random_bytes ($ i );
133+ $ encoded = Base64UrlSafe::encode ($ random );
134+ $ decoded = Base64UrlSafe::decode ($ encoded , true );
135+ $ this ->assertSame ($ decoded , $ random );
136+ }
137+ }
138+
123139 /**
124140 * @dataProvider invalidCharactersProvider
125141 */
You can’t perform that action at this time.
0 commit comments