File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,9 @@ public static function sign(
255
255
// The last non-empty line is used as the key.
256
256
$ lines = array_filter (explode ("\n" , $ key ));
257
257
$ key = base64_decode ((string ) end ($ lines ));
258
+ if (strlen ($ key ) === 0 ) {
259
+ throw new DomainException ('Key cannot be empty string ' );
260
+ }
258
261
return sodium_crypto_sign_detached ($ msg , $ key );
259
262
} catch (Exception $ e ) {
260
263
throw new DomainException ($ e ->getMessage (), 0 , $ e );
@@ -312,6 +315,12 @@ private static function verify(
312
315
// The last non-empty line is used as the key.
313
316
$ lines = array_filter (explode ("\n" , $ keyMaterial ));
314
317
$ key = base64_decode ((string ) end ($ lines ));
318
+ if (strlen ($ key ) === 0 ) {
319
+ throw new DomainException ('Key cannot be empty string ' );
320
+ }
321
+ if (strlen ($ signature ) === 0 ) {
322
+ throw new DomainException ('Signature cannot be empty string ' );
323
+ }
315
324
return sodium_crypto_sign_verify_detached ($ signature , $ msg , $ key );
316
325
} catch (Exception $ e ) {
317
326
throw new DomainException ($ e ->getMessage (), 0 , $ e );
You can’t perform that action at this time.
0 commit comments