Passed
Push — master ( 4361d6...b604d5 )
by Roeland
12:05 queued 10s
created

Crypt::hasSignature()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 8
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 17
rs 8.8333
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Bjoern Schiessle <[email protected]>
6
 * @author Björn Schießle <[email protected]>
7
 * @author Christoph Wurst <[email protected]>
8
 * @author Clark Tomlinson <[email protected]>
9
 * @author Joas Schilling <[email protected]>
10
 * @author Lukas Reschke <[email protected]>
11
 * @author Morris Jobke <[email protected]>
12
 * @author Stefan Weiberg <[email protected]>
13
 * @author Thomas Müller <[email protected]>
14
 *
15
 * @license AGPL-3.0
16
 *
17
 * This code is free software: you can redistribute it and/or modify
18
 * it under the terms of the GNU Affero General Public License, version 3,
19
 * as published by the Free Software Foundation.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License, version 3,
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>
28
 *
29
 */
30
31
namespace OCA\Encryption\Crypto;
32
33
use OC\Encryption\Exceptions\DecryptionFailedException;
34
use OC\Encryption\Exceptions\EncryptionFailedException;
35
use OC\ServerNotAvailableException;
36
use OCA\Encryption\Exceptions\MultiKeyDecryptException;
37
use OCA\Encryption\Exceptions\MultiKeyEncryptException;
38
use OCP\Encryption\Exceptions\GenericEncryptionException;
39
use OCP\IConfig;
40
use OCP\IL10N;
41
use OCP\ILogger;
42
use OCP\IUserSession;
43
44
/**
45
 * Class Crypt provides the encryption implementation of the default Nextcloud
46
 * encryption module. As default AES-256-CTR is used, it does however offer support
47
 * for the following modes:
48
 *
49
 * - AES-256-CTR
50
 * - AES-128-CTR
51
 * - AES-256-CFB
52
 * - AES-128-CFB
53
 *
54
 * For integrity protection Encrypt-Then-MAC using HMAC-SHA256 is used.
55
 *
56
 * @package OCA\Encryption\Crypto
57
 */
58
class Crypt {
59
	public const DEFAULT_CIPHER = 'AES-256-CTR';
60
	// default cipher from old Nextcloud versions
61
	public const LEGACY_CIPHER = 'AES-128-CFB';
62
63
	// default key format, old Nextcloud version encrypted the private key directly
64
	// with the user password
65
	public const LEGACY_KEY_FORMAT = 'password';
66
67
	public const HEADER_START = 'HBEGIN';
68
	public const HEADER_END = 'HEND';
69
70
	/** @var ILogger */
71
	private $logger;
72
73
	/** @var string */
74
	private $user;
75
76
	/** @var IConfig */
77
	private $config;
78
79
	/** @var array */
80
	private $supportedKeyFormats;
81
82
	/** @var IL10N */
83
	private $l;
84
85
	/** @var array */
86
	private $supportedCiphersAndKeySize = [
87
		'AES-256-CTR' => 32,
88
		'AES-128-CTR' => 16,
89
		'AES-256-CFB' => 32,
90
		'AES-128-CFB' => 16,
91
	];
92
93
	/** @var bool */
94
	private $supportLegacy;
95
96
	/**
97
	 * @param ILogger $logger
98
	 * @param IUserSession $userSession
99
	 * @param IConfig $config
100
	 * @param IL10N $l
101
	 */
102
	public function __construct(ILogger $logger, IUserSession $userSession, IConfig $config, IL10N $l) {
103
		$this->logger = $logger;
104
		$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : '"no user given"';
105
		$this->config = $config;
106
		$this->l = $l;
107
		$this->supportedKeyFormats = ['hash', 'password'];
108
109
		$this->supportLegacy = $this->config->getSystemValueBool('encryption.legacy_format_support', false);
110
	}
111
112
	/**
113
	 * create new private/public key-pair for user
114
	 *
115
	 * @return array|bool
116
	 */
117
	public function createKeyPair() {
118
		$log = $this->logger;
119
		$res = $this->getOpenSSLPKey();
120
121
		if (!$res) {
0 ignored issues
show
introduced by
$res is of type resource, thus it always evaluated to false.
Loading history...
122
			$log->error("Encryption Library couldn't generate users key-pair for {$this->user}",
123
				['app' => 'encryption']);
124
125
			if (openssl_error_string()) {
126
				$log->error('Encryption library openssl_pkey_new() fails: ' . openssl_error_string(),
127
					['app' => 'encryption']);
128
			}
129
		} elseif (openssl_pkey_export($res,
130
			$privateKey,
131
			null,
132
			$this->getOpenSSLConfig())) {
133
			$keyDetails = openssl_pkey_get_details($res);
134
			$publicKey = $keyDetails['key'];
135
136
			return [
137
				'publicKey' => $publicKey,
138
				'privateKey' => $privateKey
139
			];
140
		}
141
		$log->error('Encryption library couldn\'t export users private key, please check your servers OpenSSL configuration.' . $this->user,
142
			['app' => 'encryption']);
143
		if (openssl_error_string()) {
144
			$log->error('Encryption Library:' . openssl_error_string(),
145
				['app' => 'encryption']);
146
		}
147
148
		return false;
149
	}
150
151
	/**
152
	 * Generates a new private key
153
	 *
154
	 * @return resource
155
	 */
156
	public function getOpenSSLPKey() {
157
		$config = $this->getOpenSSLConfig();
158
		return openssl_pkey_new($config);
159
	}
160
161
	/**
162
	 * get openSSL Config
163
	 *
164
	 * @return array
165
	 */
166
	private function getOpenSSLConfig() {
167
		$config = ['private_key_bits' => 4096];
168
		$config = array_merge(
169
			$config,
170
			$this->config->getSystemValue('openssl', [])
171
		);
172
		return $config;
173
	}
174
175
	/**
176
	 * @param string $plainContent
177
	 * @param string $passPhrase
178
	 * @param int $version
179
	 * @param int $position
180
	 * @return false|string
181
	 * @throws EncryptionFailedException
182
	 */
183
	public function symmetricEncryptFileContent($plainContent, $passPhrase, $version, $position) {
184
		if (!$plainContent) {
185
			$this->logger->error('Encryption Library, symmetrical encryption failed no content given',
186
				['app' => 'encryption']);
187
			return false;
188
		}
189
190
		$iv = $this->generateIv();
191
192
		$encryptedContent = $this->encrypt($plainContent,
193
			$iv,
194
			$passPhrase,
195
			$this->getCipher());
196
197
		// Create a signature based on the key as well as the current version
198
		$sig = $this->createSignature($encryptedContent, $passPhrase.'_'.$version.'_'.$position);
199
200
		// combine content to encrypt the IV identifier and actual IV
201
		$catFile = $this->concatIV($encryptedContent, $iv);
202
		$catFile = $this->concatSig($catFile, $sig);
203
		return $this->addPadding($catFile);
204
	}
205
206
	/**
207
	 * generate header for encrypted file
208
	 *
209
	 * @param string $keyFormat (can be 'hash' or 'password')
210
	 * @return string
211
	 * @throws \InvalidArgumentException
212
	 */
213
	public function generateHeader($keyFormat = 'hash') {
214
		if (in_array($keyFormat, $this->supportedKeyFormats, true) === false) {
215
			throw new \InvalidArgumentException('key format "' . $keyFormat . '" is not supported');
216
		}
217
218
		$cipher = $this->getCipher();
219
220
		$header = self::HEADER_START
221
			. ':cipher:' . $cipher
222
			. ':keyFormat:' . $keyFormat
223
			. ':' . self::HEADER_END;
224
225
		return $header;
226
	}
227
228
	/**
229
	 * @param string $plainContent
230
	 * @param string $iv
231
	 * @param string $passPhrase
232
	 * @param string $cipher
233
	 * @return string
234
	 * @throws EncryptionFailedException
235
	 */
236
	private function encrypt($plainContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
237
		$encryptedContent = openssl_encrypt($plainContent,
238
			$cipher,
239
			$passPhrase,
240
			false,
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type integer expected by parameter $options of openssl_encrypt(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

240
			/** @scrutinizer ignore-type */ false,
Loading history...
241
			$iv);
242
243
		if (!$encryptedContent) {
244
			$error = 'Encryption (symmetric) of content failed';
245
			$this->logger->error($error . openssl_error_string(),
246
				['app' => 'encryption']);
247
			throw new EncryptionFailedException($error);
248
		}
249
250
		return $encryptedContent;
251
	}
252
253
	/**
254
	 * return Cipher either from config.php or the default cipher defined in
255
	 * this class
256
	 *
257
	 * @return string
258
	 */
259
	public function getCipher() {
260
		$cipher = $this->config->getSystemValue('cipher', self::DEFAULT_CIPHER);
261
		if (!isset($this->supportedCiphersAndKeySize[$cipher])) {
262
			$this->logger->warning(
263
					sprintf(
264
							'Unsupported cipher (%s) defined in config.php supported. Falling back to %s',
265
							$cipher,
266
							self::DEFAULT_CIPHER
267
					),
268
				['app' => 'encryption']);
269
			$cipher = self::DEFAULT_CIPHER;
270
		}
271
272
		// Workaround for OpenSSL 0.9.8. Fallback to an old cipher that should work.
273
		if (OPENSSL_VERSION_NUMBER < 0x1000101f) {
274
			if ($cipher === 'AES-256-CTR' || $cipher === 'AES-128-CTR') {
275
				$cipher = self::LEGACY_CIPHER;
276
			}
277
		}
278
279
		return $cipher;
280
	}
281
282
	/**
283
	 * get key size depending on the cipher
284
	 *
285
	 * @param string $cipher
286
	 * @return int
287
	 * @throws \InvalidArgumentException
288
	 */
289
	protected function getKeySize($cipher) {
290
		if (isset($this->supportedCiphersAndKeySize[$cipher])) {
291
			return $this->supportedCiphersAndKeySize[$cipher];
292
		}
293
294
		throw new \InvalidArgumentException(
295
			sprintf(
296
					'Unsupported cipher (%s) defined.',
297
					$cipher
298
			)
299
		);
300
	}
301
302
	/**
303
	 * get legacy cipher
304
	 *
305
	 * @return string
306
	 */
307
	public function getLegacyCipher() {
308
		if (!$this->supportLegacy) {
309
			throw new ServerNotAvailableException('Legacy cipher is no longer supported!');
310
		}
311
312
		return self::LEGACY_CIPHER;
313
	}
314
315
	/**
316
	 * @param string $encryptedContent
317
	 * @param string $iv
318
	 * @return string
319
	 */
320
	private function concatIV($encryptedContent, $iv) {
321
		return $encryptedContent . '00iv00' . $iv;
322
	}
323
324
	/**
325
	 * @param string $encryptedContent
326
	 * @param string $signature
327
	 * @return string
328
	 */
329
	private function concatSig($encryptedContent, $signature) {
330
		return $encryptedContent . '00sig00' . $signature;
331
	}
332
333
	/**
334
	 * Note: This is _NOT_ a padding used for encryption purposes. It is solely
335
	 * used to achieve the PHP stream size. It has _NOTHING_ to do with the
336
	 * encrypted content and is not used in any crypto primitive.
337
	 *
338
	 * @param string $data
339
	 * @return string
340
	 */
341
	private function addPadding($data) {
342
		return $data . 'xxx';
343
	}
344
345
	/**
346
	 * generate password hash used to encrypt the users private key
347
	 *
348
	 * @param string $password
349
	 * @param string $cipher
350
	 * @param string $uid only used for user keys
351
	 * @return string
352
	 */
353
	protected function generatePasswordHash($password, $cipher, $uid = '') {
354
		$instanceId = $this->config->getSystemValue('instanceid');
355
		$instanceSecret = $this->config->getSystemValue('secret');
356
		$salt = hash('sha256', $uid . $instanceId . $instanceSecret, true);
357
		$keySize = $this->getKeySize($cipher);
358
359
		$hash = hash_pbkdf2(
360
			'sha256',
361
			$password,
362
			$salt,
363
			100000,
364
			$keySize,
365
			true
366
		);
367
368
		return $hash;
369
	}
370
371
	/**
372
	 * encrypt private key
373
	 *
374
	 * @param string $privateKey
375
	 * @param string $password
376
	 * @param string $uid for regular users, empty for system keys
377
	 * @return false|string
378
	 */
379
	public function encryptPrivateKey($privateKey, $password, $uid = '') {
380
		$cipher = $this->getCipher();
381
		$hash = $this->generatePasswordHash($password, $cipher, $uid);
382
		$encryptedKey = $this->symmetricEncryptFileContent(
383
			$privateKey,
384
			$hash,
385
			0,
386
			0
387
		);
388
389
		return $encryptedKey;
390
	}
391
392
	/**
393
	 * @param string $privateKey
394
	 * @param string $password
395
	 * @param string $uid for regular users, empty for system keys
396
	 * @return false|string
397
	 */
398
	public function decryptPrivateKey($privateKey, $password = '', $uid = '') {
399
		$header = $this->parseHeader($privateKey);
400
401
		if (isset($header['cipher'])) {
402
			$cipher = $header['cipher'];
403
		} else {
404
			$cipher = $this->getLegacyCipher();
405
		}
406
407
		if (isset($header['keyFormat'])) {
408
			$keyFormat = $header['keyFormat'];
409
		} else {
410
			$keyFormat = self::LEGACY_KEY_FORMAT;
411
		}
412
413
		if ($keyFormat === 'hash') {
414
			$password = $this->generatePasswordHash($password, $cipher, $uid);
415
		}
416
417
		// If we found a header we need to remove it from the key we want to decrypt
418
		if (!empty($header)) {
419
			$privateKey = substr($privateKey,
420
				strpos($privateKey,
421
					self::HEADER_END) + strlen(self::HEADER_END));
422
		}
423
424
		$plainKey = $this->symmetricDecryptFileContent(
425
			$privateKey,
426
			$password,
427
			$cipher,
428
			0
429
		);
430
431
		if ($this->isValidPrivateKey($plainKey) === false) {
432
			return false;
433
		}
434
435
		return $plainKey;
436
	}
437
438
	/**
439
	 * check if it is a valid private key
440
	 *
441
	 * @param string $plainKey
442
	 * @return bool
443
	 */
444
	protected function isValidPrivateKey($plainKey) {
445
		$res = openssl_get_privatekey($plainKey);
446
		if (is_resource($res)) {
447
			$sslInfo = openssl_pkey_get_details($res);
448
			if (isset($sslInfo['key'])) {
449
				return true;
450
			}
451
		}
452
453
		return false;
454
	}
455
456
	/**
457
	 * @param string $keyFileContents
458
	 * @param string $passPhrase
459
	 * @param string $cipher
460
	 * @param int $version
461
	 * @param int $position
462
	 * @return string
463
	 * @throws DecryptionFailedException
464
	 */
465
	public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $cipher = self::DEFAULT_CIPHER, $version = 0, $position = 0) {
466
		if ($keyFileContents == '') {
467
			return '';
468
		}
469
470
		$catFile = $this->splitMetaData($keyFileContents, $cipher);
471
472
		if ($catFile['signature'] !== false) {
473
			try {
474
				// First try the new format
475
				$this->checkSignature($catFile['encrypted'], $passPhrase . '_' . $version . '_' . $position, $catFile['signature']);
476
			} catch (GenericEncryptionException $e) {
477
				// For compatibility with old files check the version without _
478
				$this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);
479
			}
480
		}
481
482
		return $this->decrypt($catFile['encrypted'],
483
			$catFile['iv'],
484
			$passPhrase,
485
			$cipher);
486
	}
487
488
	/**
489
	 * check for valid signature
490
	 *
491
	 * @param string $data
492
	 * @param string $passPhrase
493
	 * @param string $expectedSignature
494
	 * @throws GenericEncryptionException
495
	 */
496
	private function checkSignature($data, $passPhrase, $expectedSignature) {
497
		$enforceSignature = !$this->config->getSystemValue('encryption_skip_signature_check', false);
498
499
		$signature = $this->createSignature($data, $passPhrase);
500
		$isCorrectHash = hash_equals($expectedSignature, $signature);
501
502
		if (!$isCorrectHash && $enforceSignature) {
503
			throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature'));
504
		} elseif (!$isCorrectHash && !$enforceSignature) {
505
			$this->logger->info("Signature check skipped", ['app' => 'encryption']);
506
		}
507
	}
508
509
	/**
510
	 * create signature
511
	 *
512
	 * @param string $data
513
	 * @param string $passPhrase
514
	 * @return string
515
	 */
516
	private function createSignature($data, $passPhrase) {
517
		$passPhrase = hash('sha512', $passPhrase . 'a', true);
518
		return hash_hmac('sha256', $data, $passPhrase);
519
	}
520
521
522
	/**
523
	 * remove padding
524
	 *
525
	 * @param string $padded
526
	 * @param bool $hasSignature did the block contain a signature, in this case we use a different padding
527
	 * @return string|false
528
	 */
529
	private function removePadding($padded, $hasSignature = false) {
530
		if ($hasSignature === false && substr($padded, -2) === 'xx') {
531
			return substr($padded, 0, -2);
532
		} elseif ($hasSignature === true && substr($padded, -3) === 'xxx') {
533
			return substr($padded, 0, -3);
534
		}
535
		return false;
536
	}
537
538
	/**
539
	 * split meta data from encrypted file
540
	 * Note: for now, we assume that the meta data always start with the iv
541
	 *       followed by the signature, if available
542
	 *
543
	 * @param string $catFile
544
	 * @param string $cipher
545
	 * @return array
546
	 */
547
	private function splitMetaData($catFile, $cipher) {
548
		if ($this->hasSignature($catFile, $cipher)) {
549
			$catFile = $this->removePadding($catFile, true);
550
			$meta = substr($catFile, -93);
551
			$iv = substr($meta, strlen('00iv00'), 16);
552
			$sig = substr($meta, 22 + strlen('00sig00'));
553
			$encrypted = substr($catFile, 0, -93);
554
		} else {
555
			$catFile = $this->removePadding($catFile);
556
			$meta = substr($catFile, -22);
557
			$iv = substr($meta, -16);
558
			$sig = false;
559
			$encrypted = substr($catFile, 0, -22);
560
		}
561
562
		return [
563
			'encrypted' => $encrypted,
564
			'iv' => $iv,
565
			'signature' => $sig
566
		];
567
	}
568
569
	/**
570
	 * check if encrypted block is signed
571
	 *
572
	 * @param string $catFile
573
	 * @param string $cipher
574
	 * @return bool
575
	 * @throws GenericEncryptionException
576
	 */
577
	private function hasSignature($catFile, $cipher) {
578
		$skipSignatureCheck = $this->config->getSystemValue('encryption_skip_signature_check', false);
579
580
		$meta = substr($catFile, -93);
581
		$signaturePosition = strpos($meta, '00sig00');
582
583
		// If we no longer support the legacy format then everything needs a signature
584
		if (!$skipSignatureCheck && !$this->supportLegacy && $signaturePosition === false) {
585
			throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
586
		}
587
588
		// enforce signature for the new 'CTR' ciphers
589
		if (!$skipSignatureCheck && $signaturePosition === false && stripos($cipher, 'ctr') !== false) {
590
			throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
591
		}
592
593
		return ($signaturePosition !== false);
594
	}
595
596
597
	/**
598
	 * @param string $encryptedContent
599
	 * @param string $iv
600
	 * @param string $passPhrase
601
	 * @param string $cipher
602
	 * @return string
603
	 * @throws DecryptionFailedException
604
	 */
605
	private function decrypt($encryptedContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
606
		$plainContent = openssl_decrypt($encryptedContent,
607
			$cipher,
608
			$passPhrase,
609
			false,
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type integer expected by parameter $options of openssl_decrypt(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

609
			/** @scrutinizer ignore-type */ false,
Loading history...
610
			$iv);
611
612
		if ($plainContent) {
613
			return $plainContent;
614
		} else {
615
			throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . openssl_error_string());
616
		}
617
	}
618
619
	/**
620
	 * @param string $data
621
	 * @return array
622
	 */
623
	protected function parseHeader($data) {
624
		$result = [];
625
626
		if (substr($data, 0, strlen(self::HEADER_START)) === self::HEADER_START) {
627
			$endAt = strpos($data, self::HEADER_END);
628
			$header = substr($data, 0, $endAt + strlen(self::HEADER_END));
629
630
			// +1 not to start with an ':' which would result in empty element at the beginning
631
			$exploded = explode(':',
632
				substr($header, strlen(self::HEADER_START) + 1));
633
634
			$element = array_shift($exploded);
635
636
			while ($element !== self::HEADER_END) {
637
				$result[$element] = array_shift($exploded);
638
				$element = array_shift($exploded);
639
			}
640
		}
641
642
		return $result;
643
	}
644
645
	/**
646
	 * generate initialization vector
647
	 *
648
	 * @return string
649
	 * @throws GenericEncryptionException
650
	 */
651
	private function generateIv() {
652
		return random_bytes(16);
653
	}
654
655
	/**
656
	 * Generate a cryptographically secure pseudo-random 256-bit ASCII key, used
657
	 * as file key
658
	 *
659
	 * @return string
660
	 * @throws \Exception
661
	 */
662
	public function generateFileKey() {
663
		return random_bytes(32);
664
	}
665
666
	/**
667
	 * @param $encKeyFile
668
	 * @param $shareKey
669
	 * @param $privateKey
670
	 * @return string
671
	 * @throws MultiKeyDecryptException
672
	 */
673
	public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) {
674
		if (!$encKeyFile) {
675
			throw new MultiKeyDecryptException('Cannot multikey decrypt empty plain content');
676
		}
677
678
		if (openssl_open($encKeyFile, $plainContent, $shareKey, $privateKey)) {
679
			return $plainContent;
680
		} else {
681
			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
682
		}
683
	}
684
685
	/**
686
	 * @param string $plainContent
687
	 * @param array $keyFiles
688
	 * @return array
689
	 * @throws MultiKeyEncryptException
690
	 */
691
	public function multiKeyEncrypt($plainContent, array $keyFiles) {
692
		// openssl_seal returns false without errors if plaincontent is empty
693
		// so trigger our own error
694
		if (empty($plainContent)) {
695
			throw new MultiKeyEncryptException('Cannot multikeyencrypt empty plain content');
696
		}
697
698
		// Set empty vars to be set by openssl by reference
699
		$sealed = '';
700
		$shareKeys = [];
701
		$mappedShareKeys = [];
702
703
		if (openssl_seal($plainContent, $sealed, $shareKeys, $keyFiles)) {
704
			$i = 0;
705
706
			// Ensure each shareKey is labelled with its corresponding key id
707
			foreach ($keyFiles as $userId => $publicKey) {
708
				$mappedShareKeys[$userId] = $shareKeys[$i];
709
				$i++;
710
			}
711
712
			return [
713
				'keys' => $mappedShareKeys,
714
				'data' => $sealed
715
			];
716
		} else {
717
			throw new MultiKeyEncryptException('multikeyencryption failed ' . openssl_error_string());
718
		}
719
	}
720
}
721