Conditions | 6 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 7.3329 |
Changes | 0 |
1 | <?php |
||
42 | 6 | public function decryptData($encryptedData, $iv, &$data) |
|
43 | { |
||
44 | 6 | if (strlen($this->sessionKey) != 24) { |
|
45 | return self::ILLEGAL_AES_KEY; |
||
46 | } |
||
47 | |||
48 | 6 | if (strlen($iv) != 24) { |
|
49 | return self::ILLEGAL_IV; |
||
50 | } |
||
51 | |||
52 | 6 | $encoder = new PKCS7Encoder(); |
|
53 | 6 | $result = $encoder->decrypt($encryptedData, $this->sessionKey, $iv); |
|
54 | |||
55 | 6 | if ($result[0] != 0) { |
|
56 | return $result[0]; |
||
57 | } |
||
58 | |||
59 | 6 | if ($result[1] == null) { |
|
60 | return self::ILLEGAL_BUFFER; |
||
61 | } |
||
62 | 6 | if ($result[1]->watermark->appid != $this->appid) { |
|
63 | return self::ILLEGAL_BUFFER; |
||
64 | } |
||
65 | 6 | $data = $result[1]; |
|
66 | |||
67 | 6 | return self::OK; |
|
68 | } |
||
69 | } |
||
70 |