You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

enigma_subkey.php 2.2KB

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