1 | <?php |
||
22 | class CryptToolSodiumDep extends CryptTool { |
||
23 | /** |
||
24 | * @param string $data |
||
25 | * @param string $nonce |
||
26 | * @param string $senderPrivateKey |
||
27 | * @param string $recipientPublicKey |
||
28 | * @return string encrypted box |
||
29 | */ |
||
30 | protected function makeBox($data, $nonce, $senderPrivateKey, $recipientPublicKey) { |
||
36 | |||
37 | /** |
||
38 | * make a secret box |
||
39 | * |
||
40 | * @param $data |
||
41 | * @param $nonce |
||
42 | * @param $key |
||
43 | * @return mixed |
||
44 | */ |
||
45 | protected function makeSecretBox($data, $nonce, $key) { |
||
49 | |||
50 | |||
51 | /** |
||
52 | * @param string $box |
||
53 | * @param string $recipientPrivateKey |
||
54 | * @param string $senderPublicKey |
||
55 | * @param string $nonce |
||
56 | * @return null|string |
||
57 | */ |
||
58 | protected function openBox($box, $recipientPrivateKey, $senderPublicKey, $nonce) { |
||
64 | |||
65 | /** |
||
66 | * decrypt a secret box |
||
67 | * |
||
68 | * @param string $box as binary |
||
69 | * @param string $nonce as binary |
||
70 | * @param string $key as binary |
||
71 | * @return string as binary |
||
72 | */ |
||
73 | protected function openSecretBox($box, $nonce, $key) { |
||
77 | |||
78 | |||
79 | /** |
||
80 | * Generate a new key pair. |
||
81 | * |
||
82 | * @return KeyPair the new key pair |
||
83 | */ |
||
84 | final public function generateKeyPair() { |
||
90 | |||
91 | /** |
||
92 | * @param int $size |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function createRandom($size) { |
||
99 | |||
100 | /** |
||
101 | * Derive the public key |
||
102 | * |
||
103 | * @param string $privateKey in binary |
||
104 | * @return string public key as binary |
||
105 | */ |
||
106 | final public function derivePublicKey($privateKey) { |
||
110 | |||
111 | /** |
||
112 | * Check if implementation supported |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function isSupported() { |
||
119 | |||
120 | /** |
||
121 | * Validate crypt tool |
||
122 | * |
||
123 | * @return bool |
||
124 | * @throws Exception |
||
125 | */ |
||
126 | public function validate() { |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getName() { |
||
139 | |||
140 | /** |
||
141 | * Description of the CryptTool |
||
142 | * @return string |
||
143 | */ |
||
144 | public function getDescription() { |
||
148 | } |
||
149 |