File tree Expand file tree Collapse file tree 6 files changed +12
-19
lines changed
Expand file tree Collapse file tree 6 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,6 @@ parameters:
4545 count : 1
4646 path : src/BigInteger.php
4747
48- -
49- message : " #^Cannot cast mixed to int\\ .$#"
50- count : 1
51- path : src/Key/Ec2Key.php
52-
5348 -
5449 message : " #^Cannot cast mixed to string\\ .$#"
5550 count : 2
@@ -85,11 +80,6 @@ parameters:
8580 count : 1
8681 path : src/Key/Key.php
8782
88- -
89- message : " #^Cannot cast mixed to int\\ .$#"
90- count : 1
91- path : src/Key/OkpKey.php
92-
9383 -
9484 message : " #^Method Cose\\\\ Key\\\\ OkpKey\\ :\\ :curve\\ (\\ ) should return int\\ |string but returns mixed\\ .$#"
9585 count : 1
@@ -105,11 +95,6 @@ parameters:
10595 count : 1
10696 path : src/Key/OkpKey.php
10797
108- -
109- message : " #^Cannot cast mixed to int\\ .$#"
110- count : 1
111- path : src/Key/RsaKey.php
112-
11398 -
11499 message : " #^Method Cose\\\\ Key\\\\ RsaKey\\ :\\ :QInv\\ (\\ ) should return string but returns mixed\\ .$#"
115100 count : 1
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ abstract protected function getSignatureLength(): int;
3232
3333 private function checKey (Key $ key ): void
3434 {
35- if ($ key ->type () !== Key::TYPE_OCT ) {
35+ if ($ key ->type () !== Key::TYPE_OCT && $ key -> type () !== Key:: TYPE_NAME_OCT ) {
3636 throw new InvalidArgumentException ('Invalid key. Must be of type symmetric ' );
3737 }
3838
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class Ec2Key extends Key
8282 public function __construct (array $ data )
8383 {
8484 parent ::__construct ($ data );
85- if (! isset ( $ data [self ::TYPE ]) || ( int ) $ data [self ::TYPE ] !== self ::TYPE_EC2 ) {
85+ if ($ data [self ::TYPE ] !== self :: TYPE_EC2 && $ data [self ::TYPE ] !== self ::TYPE_NAME_EC2 ) {
8686 throw new InvalidArgumentException ('Invalid EC2 key. The key type does not correspond to an EC2 key ' );
8787 }
8888 if (! isset ($ data [self ::DATA_CURVE ], $ data [self ::DATA_X ], $ data [self ::DATA_Y ])) {
Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ class Key
1919
2020 public const TYPE_OCT = 4 ;
2121
22+ public const TYPE_NAME_OKP = 'OKP ' ;
23+
24+ public const TYPE_NAME_EC2 = 'EC ' ;
25+
26+ public const TYPE_NAME_RSA = 'RSA ' ;
27+
28+ public const TYPE_NAME_OCT = 'oct ' ;
29+
2230 public const KID = 2 ;
2331
2432 public const ALG = 3 ;
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class OkpKey extends Key
4444 public function __construct (array $ data )
4545 {
4646 parent ::__construct ($ data );
47- if (! isset ( $ data [self ::TYPE ]) || ( int ) $ data [self ::TYPE ] !== self ::TYPE_OKP ) {
47+ if ($ data [self ::TYPE ] !== self :: TYPE_OKP && $ data [self ::TYPE ] !== self ::TYPE_NAME_OKP ) {
4848 throw new InvalidArgumentException ('Invalid OKP key. The key type does not correspond to an OKP key ' );
4949 }
5050 if (! isset ($ data [self ::DATA_CURVE ], $ data [self ::DATA_X ])) {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class RsaKey extends Key
4848 public function __construct (array $ data )
4949 {
5050 parent ::__construct ($ data );
51- if (! isset ( $ data [self ::TYPE ]) || ( int ) $ data [self ::TYPE ] !== self ::TYPE_RSA ) {
51+ if ($ data [self ::TYPE ] !== self :: TYPE_RSA && $ data [self ::TYPE ] !== self ::TYPE_NAME_RSA ) {
5252 throw new InvalidArgumentException ('Invalid RSA key. The key type does not correspond to a RSA key ' );
5353 }
5454 if (! isset ($ data [self ::DATA_N ], $ data [self ::DATA_E ])) {
You can’t perform that action at this time.
0 commit comments