| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function open(string $box_bin):CryptoBoxInterface{ |
||
| 28 | $this->checkKeypair(SODIUM_CRYPTO_BOX_SECRETKEYBYTES, SODIUM_CRYPTO_BOX_PUBLICKEYBYTES); |
||
| 29 | |||
| 30 | $keypair = sodium_crypto_box_keypair_from_secretkey_and_publickey($this->keypair->secret, $this->keypair->public); |
||
| 31 | $this->message = sodium_crypto_box_seal_open($box_bin, $keypair); |
||
| 32 | |||
| 33 | sodium_memzero($keypair); |
||
| 34 | sodium_memzero($box_bin); |
||
| 35 | |||
| 36 | if($this->message === false){ |
||
| 37 | throw new CryptoException('invalid box'); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this; |
||
| 41 | } |
||
| 44 |