comparison plugins/enigma/lib/enigma_subkey.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 <?php
2
3 /**
4 +-------------------------------------------------------------------------+
5 | SubKey class for the Enigma Plugin |
6 | |
7 | Copyright (C) 2010-2015 The Roundcube Dev Team |
8 | |
9 | Licensed under the GNU General Public License version 3 or |
10 | any later version with exceptions for skins & plugins. |
11 | See the README file for a full license statement. |
12 | |
13 +-------------------------------------------------------------------------+
14 | Author: Aleksander Machniak <alec@alec.pl> |
15 +-------------------------------------------------------------------------+
16 */
17
18 class enigma_subkey
19 {
20 public $id;
21 public $fingerprint;
22 public $expires;
23 public $created;
24 public $revoked;
25 public $has_private;
26 public $algorithm;
27 public $length;
28 public $usage;
29
30
31 /**
32 * Converts internal ID to short ID
33 * Crypt_GPG uses internal, but e.g. Thunderbird's Enigmail displays short ID
34 *
35 * @return string Key ID
36 */
37 function get_short_id()
38 {
39 // E.g. 04622F2089E037A5 => 89E037A5
40 return enigma_key::format_id($this->id);
41 }
42
43 /**
44 * Getter for formatted fingerprint
45 *
46 * @return string Formatted fingerprint
47 */
48 function get_fingerprint()
49 {
50 return enigma_key::format_fingerprint($this->fingerprint);
51 }
52
53 /**
54 * Returns human-readable name of the key's algorithm
55 *
56 * @return string Algorithm name
57 */
58 function get_algorithm()
59 {
60 // http://tools.ietf.org/html/rfc4880#section-9.1
61 switch ($this->algorithm) {
62 case 1:
63 case 2:
64 case 3:
65 return 'RSA';
66 case 16:
67 case 20:
68 return 'Elgamal';
69 case 17:
70 return 'DSA';
71 case 18:
72 return 'Elliptic Curve';
73 case 19:
74 return 'ECDSA';
75 case 21:
76 return 'Diffie-Hellman';
77 }
78 }
79 }