]> git.donarmstrong.com Git - roundcube.git/blob - plugins/enigma/lib/enigma_driver.php
Imported Upstream version 0.6+dfsg
[roundcube.git] / plugins / enigma / lib / enigma_driver.php
1 <?php
2 /*
3  +-------------------------------------------------------------------------+
4  | Abstract driver for the Enigma Plugin                                   |
5  |                                                                         |
6  | This program is free software; you can redistribute it and/or modify    |
7  | it under the terms of the GNU General Public License version 2          |
8  | as published by the Free Software Foundation.                           |
9  |                                                                         |
10  | This program is distributed in the hope that it will be useful,         |
11  | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
12  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
13  | GNU General Public License for more details.                            |
14  |                                                                         |
15  | You should have received a copy of the GNU General Public License along |
16  | with this program; if not, write to the Free Software Foundation, Inc., |
17  | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.             |
18  |                                                                         |
19  +-------------------------------------------------------------------------+
20  | Author: Aleksander Machniak <alec@alec.pl>                              |
21  +-------------------------------------------------------------------------+
22 */
23
24 abstract class enigma_driver
25 {
26     /**
27      * Class constructor.
28      *
29      * @param string User name (email address)
30      */
31     abstract function __construct($user);
32
33     /**
34      * Driver initialization.
35      *
36      * @return mixed NULL on success, enigma_error on failure
37      */
38     abstract function init();
39
40     /**
41      * Encryption.
42      */
43     abstract function encrypt($text, $keys);
44
45     /**
46      * Decryption..
47      */
48     abstract function decrypt($text, $key, $passwd);
49
50     /**
51      * Signing.
52      */
53     abstract function sign($text, $key, $passwd);
54
55     /**
56      * Signature verification.
57      *
58      * @param string Message body
59      * @param string Signature, if message is of type PGP/MIME and body doesn't contain it
60      *
61      * @return mixed Signature information (enigma_signature) or enigma_error
62      */
63     abstract function verify($text, $signature);
64
65     /**
66      * Key/Cert file import.
67      *
68      * @param string  File name or file content
69      * @param bollean True if first argument is a filename
70      *
71      * @return mixed Import status array or enigma_error
72      */
73     abstract function import($content, $isfile=false);
74
75     /**
76      * Keys listing.
77      *
78      * @param string Optional pattern for key ID, user ID or fingerprint
79      *
80      * @return mixed Array of enigma_key objects or enigma_error
81      */
82     abstract function list_keys($pattern='');
83     
84     /**
85      * Single key information.
86      *
87      * @param string Key ID, user ID or fingerprint
88      *
89      * @return mixed Key (enigma_key) object or enigma_error
90      */
91     abstract function get_key($keyid);
92
93     /**
94      * Key pair generation.
95      *
96      * @param array Key/User data
97      *
98      * @return mixed Key (enigma_key) object or enigma_error
99      */
100     abstract function gen_key($data);
101     
102     /**
103      * Key deletion.
104      */
105     abstract function del_key($keyid);
106 }