| | |
| | | $key = $this->find_key($from, true); |
| | | |
| | | if (empty($key)) { |
| | | return new enigma_error(enigma_error::E_KEYNOTFOUND); |
| | | return new enigma_error(enigma_error::KEYNOTFOUND); |
| | | } |
| | | |
| | | // check if we have password for this key |
| | |
| | | if ($pass === null) { |
| | | // ask for password |
| | | $error = array('missing' => array($key->id => $key->name)); |
| | | return new enigma_error(enigma_error::E_BADPASS, '', $error); |
| | | return new enigma_error(enigma_error::BADPASS, '', $error); |
| | | } |
| | | |
| | | // select mode |
| | |
| | | $result = $this->pgp_sign($body, $key->id, $pass, $pgp_mode); |
| | | |
| | | if ($result !== true) { |
| | | if ($result->getCode() == enigma_error::E_BADPASS) { |
| | | if ($result->getCode() == enigma_error::BADPASS) { |
| | | // ask for password |
| | | $error = array('missing' => array($key->id => $key->name)); |
| | | return new enigma_error(enigma_error::E_BADPASS, '', $error); |
| | | return new enigma_error(enigma_error::BADPASS, '', $error); |
| | | } |
| | | |
| | | return $result; |
| | |
| | | } |
| | | |
| | | if (empty($recipients)) { |
| | | return new enigma_error(enigma_error::E_KEYNOTFOUND); |
| | | return new enigma_error(enigma_error::KEYNOTFOUND); |
| | | } |
| | | |
| | | $recipients = array_unique($recipients); |
| | |
| | | $key = $this->find_key($email); |
| | | |
| | | if (empty($key)) { |
| | | return new enigma_error(enigma_error::E_KEYNOTFOUND, '', array( |
| | | return new enigma_error(enigma_error::KEYNOTFOUND, '', array( |
| | | 'missing' => $email |
| | | )); |
| | | } |
| | |
| | | */ |
| | | private function parse_plain_signed(&$p, $body) |
| | | { |
| | | if (!$this->rc->config->get('enigma_signatures', true)) { |
| | | return; |
| | | } |
| | | |
| | | $this->load_pgp_driver(); |
| | | $part = $p['structure']; |
| | | |
| | | // Verify signature |
| | | if ($this->rc->action == 'show' || $this->rc->action == 'preview') { |
| | | if ($this->rc->config->get('enigma_signatures', true)) { |
| | | $sig = $this->pgp_verify($body); |
| | | } |
| | | if ($this->rc->action == 'show' || $this->rc->action == 'preview' || $this->rc->action == 'print') { |
| | | $sig = $this->pgp_verify($body); |
| | | } |
| | | |
| | | // @TODO: Handle big bodies using (temp) files |
| | |
| | | return; |
| | | } |
| | | |
| | | if ($this->rc->action != 'show' && $this->rc->action != 'preview') { |
| | | if ($this->rc->action != 'show' && $this->rc->action != 'preview' && $this->rc->action != 'print') { |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // Verify signature |
| | | if ($this->rc->action == 'show' || $this->rc->action == 'preview') { |
| | | if ($this->rc->action == 'show' || $this->rc->action == 'preview' || $this->rc->action == 'print') { |
| | | $this->load_smime_driver(); |
| | | |
| | | $struct = $p['structure']; |
| | |
| | | // @TODO: Handle big bodies using (temp) files |
| | | $sig = $this->pgp_driver->verify($msg_body, $sig_body); |
| | | |
| | | if (($sig instanceof enigma_error) && $sig->getCode() != enigma_error::E_KEYNOTFOUND) |
| | | if (($sig instanceof enigma_error) && $sig->getCode() != enigma_error::KEYNOTFOUND) |
| | | rcube::raise_error(array( |
| | | 'code' => 600, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | |
| | | |
| | | if ($result instanceof enigma_error) { |
| | | $err_code = $result->getCode(); |
| | | if (!in_array($err_code, array(enigma_error::E_KEYNOTFOUND, enigma_error::E_BADPASS))) |
| | | if (!in_array($err_code, array(enigma_error::KEYNOTFOUND, enigma_error::BADPASS))) |
| | | rcube::raise_error(array( |
| | | 'code' => 600, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | |
| | | |
| | | if ($result instanceof enigma_error) { |
| | | $err_code = $result->getCode(); |
| | | if (!in_array($err_code, array(enigma_error::E_KEYNOTFOUND, enigma_error::E_BADPASS))) |
| | | if (!in_array($err_code, array(enigma_error::KEYNOTFOUND, enigma_error::BADPASS))) |
| | | rcube::raise_error(array( |
| | | 'code' => 600, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | |
| | | |
| | | if ($result instanceof enigma_error) { |
| | | $err_code = $result->getCode(); |
| | | if (!in_array($err_code, array(enigma_error::E_KEYNOTFOUND, enigma_error::E_BADPASS))) |
| | | if (!in_array($err_code, array(enigma_error::KEYNOTFOUND, enigma_error::BADPASS))) |
| | | rcube::raise_error(array( |
| | | 'code' => 600, 'type' => 'php', |
| | | 'file' => __FILE__, 'line' => __LINE__, |
| | |
| | | $config = @unserialize($config); |
| | | } |
| | | |
| | | $threshold = time() - $this->password_time; |
| | | $threshold = $this->password_time ? time() - $this->password_time : 0; |
| | | $keys = array(); |
| | | |
| | | // delete expired passwords |