1 | <?php |
||
20 | class CryptToolSalt extends CryptTool { |
||
21 | /** |
||
22 | * @param string $data |
||
23 | * @param string $nonce |
||
24 | * @param string $senderPrivateKey |
||
25 | * @param string $recipientPublicKey |
||
26 | * @return string encrypted box |
||
27 | */ |
||
28 | protected function makeBox($data, $nonce, $senderPrivateKey, $recipientPublicKey) { |
||
32 | |||
33 | /** |
||
34 | * @param string $data |
||
35 | * @param string $nonce |
||
36 | * @param string $key |
||
37 | * @return string encrypted secret box |
||
38 | */ |
||
39 | protected function makeSecretBox($data, $nonce, $key) { |
||
43 | |||
44 | /** |
||
45 | * @param string $box |
||
46 | * @param string $recipientPrivateKey |
||
47 | * @param string $senderPublicKey |
||
48 | * @param string $nonce |
||
49 | * @return null|string |
||
50 | */ |
||
51 | protected function openBox($box, $recipientPrivateKey, $senderPublicKey, $nonce) { |
||
65 | |||
66 | /** |
||
67 | * decrypt a secret box |
||
68 | * |
||
69 | * @param string $box as binary |
||
70 | * @param string $nonce as binary |
||
71 | * @param string $key as binary |
||
72 | * @return string as binary |
||
73 | */ |
||
74 | protected function openSecretBox($box, $nonce, $key) { |
||
83 | |||
84 | |||
85 | /** |
||
86 | * Generate a new key pair. |
||
87 | * |
||
88 | * @return KeyPair the new key pair |
||
89 | */ |
||
90 | final public function generateKeyPair() { |
||
94 | |||
95 | /** |
||
96 | * @param int $size |
||
97 | * @return string |
||
98 | */ |
||
99 | protected function createRandom($size) { |
||
102 | |||
103 | /** |
||
104 | * Derive the public key |
||
105 | * |
||
106 | * @param string $privateKey in binary |
||
107 | * @return string public key as binary |
||
108 | */ |
||
109 | final public function derivePublicKey($privateKey) { |
||
113 | |||
114 | /** |
||
115 | * @param $imageData |
||
116 | * @param $recipientPublicKey |
||
117 | * @param $senderPrivateKey |
||
118 | * @throws \Threema\Core\Exception |
||
119 | * @return EncryptResult |
||
120 | */ |
||
121 | public function encryptImageData($imageData, $recipientPublicKey, $senderPrivateKey) { |
||
140 | |||
141 | /** |
||
142 | * Check if implementation supported |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function isSupported() { |
||
148 | |||
149 | /** |
||
150 | * Validate crypt tool |
||
151 | * |
||
152 | * @return bool |
||
153 | * @throws Exception |
||
154 | */ |
||
155 | public function validate() { |
||
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getName() { |
||
172 | |||
173 | /** |
||
174 | * Description of the CryptTool |
||
175 | * @return string |
||
176 | */ |
||
177 | public function getDescription() { |
||
180 | } |
||
181 |