| | |
| | | <?php |
| | | /* |
| | | |
| | | /** |
| | | +-------------------------------------------------------------------------+ |
| | | | Engine of the Enigma Plugin | |
| | | | | |
| | |
| | | +-------------------------------------------------------------------------+ |
| | | */ |
| | | |
| | | /* |
| | | RFC2440: OpenPGP Message Format |
| | | RFC3156: MIME Security with OpenPGP |
| | | RFC3851: S/MIME |
| | | /** |
| | | * Enigma plugin engine. |
| | | * |
| | | * RFC2440: OpenPGP Message Format |
| | | * RFC3156: MIME Security with OpenPGP |
| | | * RFC3851: S/MIME |
| | | */ |
| | | |
| | | class enigma_engine |
| | | { |
| | | private $rc; |
| | |
| | | $this->rc = rcmail::get_instance(); |
| | | $this->enigma = $enigma; |
| | | |
| | | $this->password_time = $this->rc->config->get('enigma_password_time'); |
| | | $this->password_time = $this->rc->config->get('enigma_password_time') * 60; |
| | | |
| | | // this will remove passwords from session after some time |
| | | if ($this->password_time) { |
| | |
| | | return; |
| | | } |
| | | |
| | | // Verify signature |
| | | if ($this->rc->action == 'show' || $this->rc->action == 'preview') { |
| | | if ($this->rc->action != 'show' && $this->rc->action != 'preview') { |
| | | return; |
| | | } |
| | | |
| | | $this->load_pgp_driver(); |
| | | $struct = $p['structure']; |
| | | |
| | |
| | | } |
| | | else { |
| | | $this->signed_parts[$msg_part->mime_id] = $struct->mime_id; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | $this->rc->output->send(); |
| | | } |
| | | |
| | | /** |
| | | * Registers password for specified key/cert sent by the password prompt. |
| | | */ |
| | | function password_handler() |
| | | { |
| | | $keyid = rcube_utils::get_input_value('_keyid', rcube_utils::INPUT_POST); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Saves key/cert password in user session |
| | | */ |
| | | function save_password($keyid, $password) |
| | | { |
| | | // we store passwords in session for specified time |
| | |
| | | $_SESSION['enigma_pass'] = $this->rc->encrypt(serialize($config)); |
| | | } |
| | | |
| | | /** |
| | | * Returns currently stored passwords |
| | | */ |
| | | function get_passwords() |
| | | { |
| | | if ($config = $_SESSION['enigma_pass']) { |
| | |
| | | |
| | | // delete expired passwords |
| | | foreach ((array) $config as $key => $value) { |
| | | if ($pass_time && $value[1] < $threshold) { |
| | | if ($threshold && $value[1] < $threshold) { |
| | | unset($config[$key]); |
| | | $modified = true; |
| | | } |