File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 17
17
"google/protobuf" : " ~3.15.8" ,
18
18
"grpc/grpc" : " ^1.35" ,
19
19
"lcobucci/jwt" : " ^3.4" ,
20
- "phpseclib/phpseclib" : " ^3.0" ,
20
+ "phpseclib/phpseclib" : " ^2.0|^ 3.0" ,
21
21
"psr/log" : " ~1.0"
22
22
},
23
23
"autoload" : {
Original file line number Diff line number Diff line change 5
5
use Lcobucci \JWT \Signer \Key as SignerKey ;
6
6
use Lcobucci \JWT \Signer \Rsa as SignerRsa ;
7
7
8
+ use phpseclib \Crypt \RSA as LegacyRSA ;
8
9
use phpseclib3 \Crypt \RSA ;
9
10
use phpseclib3 \Crypt \PublicKeyLoader ;
10
11
@@ -17,13 +18,25 @@ class Sha256 extends SignerRsa
17
18
*/
18
19
public function createHash ($ payload , SignerKey $ key )
19
20
{
20
- $ private = PublicKeyLoader::load ($ key ->getContent ());
21
-
22
- $ signature = $ private
23
- ->withPadding (RSA ::SIGNATURE_PSS )
24
- ->sign ($ payload );
25
-
26
- return $ signature ;
21
+ $ keyContent = $ key ->getContent ();
22
+
23
+ if (class_exists (LegacyRSA::class))
24
+ {
25
+ $ rsa = new LegacyRSA ;
26
+ $ rsa ->loadKey ($ keyContent );
27
+ $ rsa ->setHash ('sha256 ' );
28
+ $ rsa ->setMGFHash ('sha256 ' );
29
+ $ rsa ->setSignatureMode (LegacyRSA::SIGNATURE_PSS );
30
+
31
+ return $ rsa ->sign ($ payload );
32
+ }
33
+ else
34
+ {
35
+ $ rsa = PublicKeyLoader::load ($ keyContent );
36
+ $ rsa ->withPadding (RSA ::SIGNATURE_PSS );
37
+
38
+ return $ rsa ->sign ($ payload );
39
+ }
27
40
}
28
41
29
42
/**
You can’t perform that action at this time.
0 commit comments