Code Duplication    Length = 16-16 lines in 2 locations

apps/encryption/lib/keymanager.php 2 locations

@@ 152-167 (lines=16) @@
149
	/**
150
	 * check if key pair for public link shares exists, if not we create one
151
	 */
152
	public function validateShareKey() {
153
		$shareKey = $this->getPublicShareKey();
154
		if (empty($shareKey)) {
155
			$keyPair = $this->crypt->createKeyPair();
156
157
			// Save public key
158
			$this->keyStorage->setSystemUserKey(
159
				$this->publicShareKeyId . '.publicKey', $keyPair['publicKey'],
160
				Encryption::ID);
161
162
			// Encrypt private key empty passphrase
163
			$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], '');
164
			$header = $this->crypt->generateHeader();
165
			$this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey);
166
		}
167
	}
168
169
	/**
170
	 * check if a key pair for the master key exists, if not we create one
@@ 172-187 (lines=16) @@
169
	/**
170
	 * check if a key pair for the master key exists, if not we create one
171
	 */
172
	public function validateMasterKey() {
173
		$masterKey = $this->getPublicMasterKey();
174
		if (empty($masterKey)) {
175
			$keyPair = $this->crypt->createKeyPair();
176
177
			// Save public key
178
			$this->keyStorage->setSystemUserKey(
179
				$this->masterKeyId . '.publicKey', $keyPair['publicKey'],
180
				Encryption::ID);
181
182
			// Encrypt private key with system password
183
			$encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId);
184
			$header = $this->crypt->generateHeader();
185
			$this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey);
186
		}
187
	}
188
189
	/**
190
	 * @return bool