/** * Compute O value (used for encryption) * @return string O value * @protected * @since 2.0.000 (2008-01-02) * @author Nicola Asuni */ protected function _Ovalue() { if ($this->encryptdata['mode'] < 3) { // RC4-40, RC4-128, AES-128 $tmp = TCPDF_STATIC::_md5_16($this->encryptdata['owner_password']); if ($this->encryptdata['mode'] > 0) { for ($i = 0; $i < 50; ++$i) { $tmp = TCPDF_STATIC::_md5_16($tmp); } } $owner_key = substr($tmp, 0, $this->encryptdata['Length'] / 8); $enc = TCPDF_STATIC::_RC4($owner_key, $this->encryptdata['user_password'], $this->last_enc_key, $this->last_enc_key_c); if ($this->encryptdata['mode'] > 0) { $len = strlen($owner_key); for ($i = 1; $i <= 19; ++$i) { $ek = ''; for ($j = 0; $j < $len; ++$j) { $ek .= chr(ord($owner_key[$j]) ^ $i); } $enc = TCPDF_STATIC::_RC4($ek, $enc, $this->last_enc_key, $this->last_enc_key_c); } } return $enc; } elseif ($this->encryptdata['mode'] == 3) { // AES-256 $seed = TCPDF_STATIC::_md5_16(TCPDF_STATIC::getRandomSeed()); // Owner Validation Salt $this->encryptdata['OVS'] = substr($seed, 0, 8); // Owner Key Salt $this->encryptdata['OKS'] = substr($seed, 8, 16); return hash('sha256', $this->encryptdata['owner_password'] . $this->encryptdata['OVS'] . $this->encryptdata['U'], true) . $this->encryptdata['OVS'] . $this->encryptdata['OKS']; } }